Skip to content

Commit 29bf730

Browse files
authored
Merge pull request #6 from versx/multi-channels
Add support for multiple channel ids to accept commands from
2 parents 585e6cc + 49218e8 commit 29bf730

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

config.example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"token": "",
55
"guildId": 0000000001,
66
"ownerId": 0000000001,
7-
"channelId": 0000000001,
7+
"channelIds": [0000000001],
88
"commandPrefix": "!",
99
"requiredRoles": [0000000001]
1010
}

src/Bot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Bot
2626

2727
public Bot(Config config)
2828
{
29-
_logger.Trace($"WhConfig [OwnerId={config.OwnerId}, GuildId={config.GuildId}, ChannelId={config.ChannelId}]");
29+
_logger.Trace($"WhConfig [OwnerId={config.OwnerId}, GuildId={config.GuildId}, ChannelIds={string.Join(", ", config.ChannelIds)}]");
3030
_config = config;
3131

3232
AppDomain.CurrentDomain.UnhandledException += async (sender, e) =>

src/Commands/PhoneControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private bool HasRequiredRoles(DiscordMember member)
410410
private bool IsValidChannel(ulong channelId)
411411
{
412412
//If no channel id is specified allow the command to execute in all channels, otherwise only the channel specified.
413-
return _dep.Config.ChannelId == 0 || _dep.Config.ChannelId == channelId;
413+
return _dep.Config.ChannelIds.Count == 0 || _dep.Config.ChannelIds.Contains(channelId);
414414
}
415415

416416
#endregion

src/Configuration/Config.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public class Config
2626
[JsonProperty("ownerId")]
2727
public ulong OwnerId { get; set; }
2828

29-
[JsonProperty("channelId")]
30-
public ulong ChannelId { get; set; }
29+
[JsonProperty("channelIds")]
30+
public List<ulong> ChannelIds { get; set; }
3131

3232
[JsonProperty("token")]
3333
public string Token { get; set; }
@@ -44,6 +44,7 @@ public class Config
4444

4545
public Config()
4646
{
47+
ChannelIds = new List<ulong>();
4748
Host = "*";
4849
Port = 6542;
4950
RequiredRoles = new List<ulong>();

0 commit comments

Comments
 (0)