Skip to content

Commit 2ac125c

Browse files
committed
Add support for multiple channel ids to accept the commands
1 parent fec768b commit 2ac125c

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
@@ -2,7 +2,7 @@
22
"token": "",
33
"guildId": 0000000001,
44
"ownerId": 0000000001,
5-
"channelId": 0000000001,
5+
"channelIds": [0000000001],
66
"commandPrefix": "!",
77
"requiredRoles": [0000000001]
88
}

src/Bot.cs

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

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

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

src/Commands/PhoneControl.cs

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

417417
private Dictionary<string, string> GetDevices()

src/Configuration/Config.cs

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

23-
[JsonProperty("channelId")]
24-
public ulong ChannelId { get; set; }
23+
[JsonProperty("channelIds")]
24+
public List<ulong> ChannelIds { get; set; }
2525

2626
[JsonProperty("token")]
2727
public string Token { get; set; }
@@ -38,6 +38,7 @@ public class Config
3838

3939
public Config()
4040
{
41+
ChannelIds = new List<ulong>();
4142
RequiredRoles = new List<ulong>();
4243
}
4344

0 commit comments

Comments
 (0)