diff --git a/DiscordLab.AdvancedLogging/Commands/AddLog.cs b/DiscordLab.AdvancedLogging/Commands/AddLog.cs index 81740ac..6d0e21a 100644 --- a/DiscordLab.AdvancedLogging/Commands/AddLog.cs +++ b/DiscordLab.AdvancedLogging/Commands/AddLog.cs @@ -12,6 +12,8 @@ public class AddLog : ISlashCommand Description = "Add your own custom logger, check the documentation for more info", DefaultMemberPermissions = GuildPermission.ManageGuild }; + + public ulong GuildId { get; set; } = Plugin.Instance.Config.GuildId; public async Task Run(SocketSlashCommand command) { diff --git a/DiscordLab.AdvancedLogging/Commands/RemoveLog.cs b/DiscordLab.AdvancedLogging/Commands/RemoveLog.cs index 1216f8a..320cb9f 100644 --- a/DiscordLab.AdvancedLogging/Commands/RemoveLog.cs +++ b/DiscordLab.AdvancedLogging/Commands/RemoveLog.cs @@ -25,6 +25,8 @@ public class RemoveLog : ISlashCommand } } }; + + public ulong GuildId { get; set; } = Plugin.Instance.Config.GuildId; public async Task Run(SocketSlashCommand command) { diff --git a/DiscordLab.AdvancedLogging/Config.cs b/DiscordLab.AdvancedLogging/Config.cs index f16e4cc..235da53 100644 --- a/DiscordLab.AdvancedLogging/Config.cs +++ b/DiscordLab.AdvancedLogging/Config.cs @@ -1,10 +1,17 @@ +using System.ComponentModel; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; using Exiled.API.Interfaces; namespace DiscordLab.AdvancedLogging { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.AdvancedLogging/Handlers/DiscordBot.cs b/DiscordLab.AdvancedLogging/Handlers/DiscordBot.cs index f988568..ea31788 100644 --- a/DiscordLab.AdvancedLogging/Handlers/DiscordBot.cs +++ b/DiscordLab.AdvancedLogging/Handlers/DiscordBot.cs @@ -66,10 +66,11 @@ private void RemoveEventHandlers() private SocketTextChannel GetChannel(ulong channelId) { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = Bot.Handlers.DiscordBot.Instance.GetGuild(Plugin.Instance.Config.GuildId); + if (guild == null) return null; if (Channels.Exists(c => c.ChannelId == channelId)) return Channels.First(c => c.ChannelId == channelId).Channel; - SocketTextChannel channel = Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(channelId); + SocketTextChannel channel = guild.GetTextChannel(channelId); if (channel != null) return channel; Log.Error("Either the guild is null or the channel is null. So the status message has failed to send."); return null; diff --git a/DiscordLab.Bot/API/Features/DescriptionConstants.cs b/DiscordLab.Bot/API/Features/DescriptionConstants.cs new file mode 100644 index 0000000..446b95b --- /dev/null +++ b/DiscordLab.Bot/API/Features/DescriptionConstants.cs @@ -0,0 +1,9 @@ +namespace DiscordLab.Bot.API.Features +{ + public class DescriptionConstants + { + public const string GuildId = "The guild ID where this module will be used. If not set (value = 0), it will use the default guild ID."; + public const string IsEnabled = "Whether the module is enabled or not."; + public const string Debug = "Whether the module is in debug mode or not."; + } +} \ No newline at end of file diff --git a/DiscordLab.Bot/API/Interfaces/IDLConfig.cs b/DiscordLab.Bot/API/Interfaces/IDLConfig.cs new file mode 100644 index 0000000..cc2d9b6 --- /dev/null +++ b/DiscordLab.Bot/API/Interfaces/IDLConfig.cs @@ -0,0 +1,10 @@ +using System.ComponentModel; + +namespace DiscordLab.Bot.API.Interfaces +{ + + public interface IDLConfig + { + public ulong GuildId { get; set; } + } +} \ No newline at end of file diff --git a/DiscordLab.Bot/API/Interfaces/ISlashCommand.cs b/DiscordLab.Bot/API/Interfaces/ISlashCommand.cs index 6cc9b5f..b6d9c8b 100644 --- a/DiscordLab.Bot/API/Interfaces/ISlashCommand.cs +++ b/DiscordLab.Bot/API/Interfaces/ISlashCommand.cs @@ -8,7 +8,12 @@ public interface ISlashCommand /// /// Here you create your with the data of your command. /// - SlashCommandBuilder Data { get; } + public SlashCommandBuilder Data { get; } + + /// + /// Set the GuildId where the command should be created here, you should reference Config.GuildId. + /// + public ulong GuildId { get; set; } /// /// Here is where your slash command runs. @@ -16,6 +21,6 @@ public interface ISlashCommand /// /// This type contains information about the command that was executed. /// - Task Run(SocketSlashCommand command); + public Task Run(SocketSlashCommand command); } } \ No newline at end of file diff --git a/DiscordLab.Bot/Config.cs b/DiscordLab.Bot/Config.cs index 986375a..c119909 100644 --- a/DiscordLab.Bot/Config.cs +++ b/DiscordLab.Bot/Config.cs @@ -7,9 +7,9 @@ public class Config : IConfig { public bool IsEnabled { get; set; } = true; public bool Debug { get; set; } = false; - [Description("The token of the bot.")] public string Token { get; set; } = "token"; - - [Description("The guild where the bot will be used.")] + [Description("The token of the bot.")] + public string Token { get; set; } = "token"; + [Description("The default guild where the bot will be used. You can set this individually for each module, but if a module doesn't have a guild id set, it will use this one.")] public ulong GuildId { get; set; } = new(); } } \ No newline at end of file diff --git a/DiscordLab.Bot/Handlers/DiscordBot.cs b/DiscordLab.Bot/Handlers/DiscordBot.cs index 5325304..c9e1305 100644 --- a/DiscordLab.Bot/Handlers/DiscordBot.cs +++ b/DiscordLab.Bot/Handlers/DiscordBot.cs @@ -12,7 +12,7 @@ public class DiscordBot : IRegisterable public DiscordSocketClient Client { get; private set; } - public SocketGuild Guild; + private SocketGuild _guild; public void Init() { @@ -54,14 +54,20 @@ private async Task StopClient() await Client.StopAsync(); } + public SocketGuild GetGuild(ulong id) + { + return id == 0 ? _guild : Client.GetGuild(id); + } + private async Task Ready() { - Guild = Client.GetGuild(Plugin.Instance.Config.GuildId); + _guild = Client.GetGuild(Plugin.Instance.Config.GuildId); foreach (ISlashCommand command in SlashCommandLoader.Commands) { try { - await Guild.CreateApplicationCommandAsync(command.Data.Build()); + SocketGuild guild = GetGuild(command.GuildId); + await guild.CreateApplicationCommandAsync(command.Data.Build()); } catch (Exception e) { diff --git a/DiscordLab.BotStatus/Config.cs b/DiscordLab.BotStatus/Config.cs index 5cfbf66..811e82a 100644 --- a/DiscordLab.BotStatus/Config.cs +++ b/DiscordLab.BotStatus/Config.cs @@ -1,11 +1,14 @@ using System.ComponentModel; +using DiscordLab.Bot.API.Features; using Exiled.API.Interfaces; namespace DiscordLab.BotStatus { public class Config : IConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; [Description("Set the Discord bot's status to orange when the server is empty.")] diff --git a/DiscordLab.ConnectionLogs/Config.cs b/DiscordLab.ConnectionLogs/Config.cs index f83769c..67ef283 100644 --- a/DiscordLab.ConnectionLogs/Config.cs +++ b/DiscordLab.ConnectionLogs/Config.cs @@ -1,11 +1,16 @@ using System.ComponentModel; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; using Exiled.API.Interfaces; namespace DiscordLab.ConnectionLogs { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; [Description("The channel where the join logs will be sent.")] @@ -16,5 +21,8 @@ public class Config : IConfig [Description("The channel where the round start logs will be sent.")] public ulong RoundStartChannelId { get; set; } = new(); + + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.ConnectionLogs/Handlers/DiscordBot.cs b/DiscordLab.ConnectionLogs/Handlers/DiscordBot.cs index 74d7362..69b4de0 100644 --- a/DiscordLab.ConnectionLogs/Handlers/DiscordBot.cs +++ b/DiscordLab.ConnectionLogs/Handlers/DiscordBot.cs @@ -26,29 +26,37 @@ public void Unregister() LeaveChannel = null; RoundStartChannel = null; } + + public SocketGuild GetGuild() + { + return Bot.Handlers.DiscordBot.Instance.Client.GetGuild(Plugin.Instance.Config.GuildId); + } public SocketTextChannel GetJoinChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = GetGuild(); + if (guild == null) return null; if (Plugin.Instance.Config.JoinChannelId == 0) return null; return JoinChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.JoinChannelId); + guild.GetTextChannel(Plugin.Instance.Config.JoinChannelId); } public SocketTextChannel GetLeaveChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = GetGuild(); + if (guild == null) return null; if (Plugin.Instance.Config.LeaveChannelId == 0) return null; return LeaveChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.LeaveChannelId); + guild.GetTextChannel(Plugin.Instance.Config.LeaveChannelId); } public SocketTextChannel GetRoundStartChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = GetGuild(); + if (guild == null) return null; if (Plugin.Instance.Config.RoundStartChannelId == 0) return null; return RoundStartChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.RoundStartChannelId); + guild.GetTextChannel(Plugin.Instance.Config.RoundStartChannelId); } } } \ No newline at end of file diff --git a/DiscordLab.DeathLogs/Config.cs b/DiscordLab.DeathLogs/Config.cs index 2319c17..dc29e59 100644 --- a/DiscordLab.DeathLogs/Config.cs +++ b/DiscordLab.DeathLogs/Config.cs @@ -1,11 +1,15 @@ using System.ComponentModel; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; using Exiled.API.Interfaces; namespace DiscordLab.DeathLogs { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; [Description("The channel where the normal death logs will be sent.")] @@ -24,5 +28,8 @@ public class Config : IConfig [Description("If this is true, then the plugin will ignore the cuff state of the player and send the death logs to the normal death logs channel.")] public bool ScpIgnoreCuffed { get; set; } = true; + + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.DeathLogs/Handlers/DiscordBot.cs b/DiscordLab.DeathLogs/Handlers/DiscordBot.cs index 92d598f..6dc85e7 100644 --- a/DiscordLab.DeathLogs/Handlers/DiscordBot.cs +++ b/DiscordLab.DeathLogs/Handlers/DiscordBot.cs @@ -24,36 +24,45 @@ public void Unregister() SelfChannel = null; TeamKillChannel = null; } + + public SocketGuild GetGuild() + { + return Bot.Handlers.DiscordBot.Instance.Client.GetGuild(Plugin.Instance.Config.GuildId); + } public SocketTextChannel GetChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = GetGuild(); + if (GetGuild() == null) return null; if (Plugin.Instance.Config.ChannelId == 0) return null; - return Channel ??= Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.ChannelId); + return Channel ??= guild.GetTextChannel(Plugin.Instance.Config.ChannelId); } public SocketTextChannel GetCuffedChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = GetGuild(); + if (guild == null) return null; if (Plugin.Instance.Config.CuffedChannelId == 0) return null; return CuffedChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.CuffedChannelId); + guild.GetTextChannel(Plugin.Instance.Config.CuffedChannelId); } public SocketTextChannel GetSelfChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = GetGuild(); + if (guild == null) return null; if (Plugin.Instance.Config.SelfChannelId == 0) return null; return SelfChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.SelfChannelId); + guild.GetTextChannel(Plugin.Instance.Config.SelfChannelId); } public SocketTextChannel GetTeamKillChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = GetGuild(); + if (guild == null) return null; if (Plugin.Instance.Config.TeamKillChannelId == 0) return null; return TeamKillChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.TeamKillChannelId); + guild.GetTextChannel(Plugin.Instance.Config.TeamKillChannelId); } } } \ No newline at end of file diff --git a/DiscordLab.Moderation/Commands/Ban.cs b/DiscordLab.Moderation/Commands/Ban.cs index fe8584f..0069a92 100644 --- a/DiscordLab.Moderation/Commands/Ban.cs +++ b/DiscordLab.Moderation/Commands/Ban.cs @@ -40,6 +40,8 @@ public class Ban : ISlashCommand } } }; + + public ulong GuildId { get; set; } = Plugin.Instance.Config.GuildId; public async Task Run(SocketSlashCommand command) { @@ -50,7 +52,7 @@ public async Task Run(SocketSlashCommand command) string duration = command.Data.Options .First(option => option.Name == Translation.BanCommandDurationOptionName).Value.ToString(); - string response = Server.ExecuteCommand($"oban {user} {duration} {reason}"); + string response = Server.ExecuteCommand($"/oban {user} {duration} {reason}"); if (!response.Contains("has been banned")) { await command.RespondAsync(Translation.FailedExecuteCommand.Replace("{reason}", response), diff --git a/DiscordLab.Moderation/Commands/SendCommand.cs b/DiscordLab.Moderation/Commands/SendCommand.cs index f6b3dd0..9cd641d 100644 --- a/DiscordLab.Moderation/Commands/SendCommand.cs +++ b/DiscordLab.Moderation/Commands/SendCommand.cs @@ -26,6 +26,8 @@ public class SendCommand : ISlashCommand } }; + public ulong GuildId { get; set; } = Plugin.Instance.Config.GuildId; + public async Task Run(SocketSlashCommand command) { string commandToExecute = command.Data.Options.First(option => option.Name == Translation.SendCommandCommandOptionName) diff --git a/DiscordLab.Moderation/Commands/Unban.cs b/DiscordLab.Moderation/Commands/Unban.cs index 738c0a7..ab35295 100644 --- a/DiscordLab.Moderation/Commands/Unban.cs +++ b/DiscordLab.Moderation/Commands/Unban.cs @@ -26,13 +26,15 @@ public class Unban : ISlashCommand } } }; + + public ulong GuildId { get; set; } = Plugin.Instance.Config.GuildId; public async Task Run(SocketSlashCommand command) { string user = command.Data.Options.First(option => option.Name == Translation.BanCommandUserOptionName) .Value.ToString(); - string response = Server.ExecuteCommand($"unban id {user}"); + string response = Server.ExecuteCommand($"/unban id {user}"); if (!response.Contains("Done")) { await command.RespondAsync(Translation.FailedExecuteCommand.Replace("{reason}", response), diff --git a/DiscordLab.Moderation/Config.cs b/DiscordLab.Moderation/Config.cs index 4853fd7..e9cbaee 100644 --- a/DiscordLab.Moderation/Config.cs +++ b/DiscordLab.Moderation/Config.cs @@ -1,10 +1,18 @@ -using Exiled.API.Interfaces; +using System.ComponentModel; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; +using Exiled.API.Interfaces; namespace DiscordLab.Moderation { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; + + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.ModerationLogs/Config.cs b/DiscordLab.ModerationLogs/Config.cs index 20023cf..6430137 100644 --- a/DiscordLab.ModerationLogs/Config.cs +++ b/DiscordLab.ModerationLogs/Config.cs @@ -1,11 +1,15 @@ using System.ComponentModel; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; using Exiled.API.Interfaces; namespace DiscordLab.ModerationLogs { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; [Description("The channel where the ban logs will be sent.")] @@ -49,5 +53,8 @@ public class Config : IConfig [Description("The hex color code of the report embed. Do not add the #.")] public string ReportColor { get; set; } = "3498DB"; + + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.ModerationLogs/Handlers/DiscordBot.cs b/DiscordLab.ModerationLogs/Handlers/DiscordBot.cs index e8efcb8..b61c0d9 100644 --- a/DiscordLab.ModerationLogs/Handlers/DiscordBot.cs +++ b/DiscordLab.ModerationLogs/Handlers/DiscordBot.cs @@ -20,6 +20,8 @@ public class DiscordBot : IRegisterable private SocketTextChannel AdminChatChannel { get; set; } private SocketTextChannel ReportChannel { get; set; } + private SocketGuild Guild { get; set; } + public void Init() { Instance = this; @@ -36,60 +38,65 @@ public void Unregister() ReportChannel = null; } + private SocketGuild GetGuild() + { + return Guild ??= Bot.Handlers.DiscordBot.Instance.GetGuild(Plugin.Instance.Config.GuildId); + } + public SocketTextChannel GetBanChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + if (GetGuild() == null) return null; if (Plugin.Instance.Config.BanChannelId == 0) return null; return BanChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.BanChannelId); + Guild.GetTextChannel(Plugin.Instance.Config.BanChannelId); } public SocketTextChannel GetUnbanChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + if (GetGuild() == null) return null; if (Plugin.Instance.Config.UnbanChannelId == 0) return null; return UnbanChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.UnbanChannelId); + Guild.GetTextChannel(Plugin.Instance.Config.UnbanChannelId); } public SocketTextChannel GetKickChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + if (GetGuild() == null) return null; if (Plugin.Instance.Config.KickChannelId == 0) return null; return KickChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.KickChannelId); + Guild.GetTextChannel(Plugin.Instance.Config.KickChannelId); } public SocketTextChannel GetMuteChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + if (GetGuild() == null) return null; if (Plugin.Instance.Config.MuteChannelId == 0) return null; return MuteChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.MuteChannelId); + Guild.GetTextChannel(Plugin.Instance.Config.MuteChannelId); } public SocketTextChannel GetUnmuteChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + if (GetGuild() == null) return null; if (Plugin.Instance.Config.UnmuteChannelId == 0) return null; return UnmuteChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.UnmuteChannelId); + Guild.GetTextChannel(Plugin.Instance.Config.UnmuteChannelId); } public SocketTextChannel GetAdminChatChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + if (GetGuild() == null) return null; if (Plugin.Instance.Config.AdminChatChannelId == 0) return null; return AdminChatChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.AdminChatChannelId); + Guild.GetTextChannel(Plugin.Instance.Config.AdminChatChannelId); } public SocketTextChannel GetReportChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + if (GetGuild() == null) return null; if (Plugin.Instance.Config.ReportChannelId == 0) return null; return ReportChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.ReportChannelId); + Guild.GetTextChannel(Plugin.Instance.Config.ReportChannelId); } diff --git a/DiscordLab.SCPSwap/Config.cs b/DiscordLab.SCPSwap/Config.cs index 471baeb..484f861 100644 --- a/DiscordLab.SCPSwap/Config.cs +++ b/DiscordLab.SCPSwap/Config.cs @@ -1,13 +1,19 @@ using System.ComponentModel; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; using Exiled.API.Interfaces; namespace DiscordLab.SCPSwap { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; [Description("The channel where the swap logs will be sent.")] public ulong ChannelId { get; set; } = new(); + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.SCPSwap/Handlers/DiscordBot.cs b/DiscordLab.SCPSwap/Handlers/DiscordBot.cs index f013e23..0a7b41b 100644 --- a/DiscordLab.SCPSwap/Handlers/DiscordBot.cs +++ b/DiscordLab.SCPSwap/Handlers/DiscordBot.cs @@ -21,9 +21,10 @@ public void Unregister() public SocketTextChannel GetChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = Bot.Handlers.DiscordBot.Instance.GetGuild(Plugin.Instance.Config.GuildId); + if (guild == null) return null; if (Plugin.Instance.Config.ChannelId == 0) return null; - return Channel ??= Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.ChannelId); + return Channel ??= guild.GetTextChannel(Plugin.Instance.Config.ChannelId); } } } \ No newline at end of file diff --git a/DiscordLab.StatusChannel/Config.cs b/DiscordLab.StatusChannel/Config.cs index 99c11b6..868b297 100644 --- a/DiscordLab.StatusChannel/Config.cs +++ b/DiscordLab.StatusChannel/Config.cs @@ -1,12 +1,16 @@ using System.ComponentModel; using Discord; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; using Exiled.API.Interfaces; namespace DiscordLab.StatusChannel { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; [Description("The channel where the status message will be sent / edited.")] @@ -14,5 +18,8 @@ public class Config : IConfig [Description("The hex color code of the embed. Do not add the #.")] public string Color { get; set; } = "3498DB"; + + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.StatusChannel/Handlers/DiscordBot.cs b/DiscordLab.StatusChannel/Handlers/DiscordBot.cs index 55c65b2..b22257d 100644 --- a/DiscordLab.StatusChannel/Handlers/DiscordBot.cs +++ b/DiscordLab.StatusChannel/Handlers/DiscordBot.cs @@ -28,10 +28,11 @@ public void Unregister() private SocketTextChannel GetChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = Bot.Handlers.DiscordBot.Instance.GetGuild(Plugin.Instance.Config.GuildId); + if (guild == null) return null; if (Plugin.Instance.Config.ChannelId == 0) return null; return StatusChannel ??= - Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.ChannelId); + guild.GetTextChannel(Plugin.Instance.Config.ChannelId); } public void SetStatusMessage(IEnumerable players = null) diff --git a/DiscordLab.XPSystem/Commands/GetLevel.cs b/DiscordLab.XPSystem/Commands/GetLevel.cs index cd7a48b..6e44e6d 100644 --- a/DiscordLab.XPSystem/Commands/GetLevel.cs +++ b/DiscordLab.XPSystem/Commands/GetLevel.cs @@ -25,6 +25,8 @@ public class GetLevel : ISlashCommand } } }; + + public ulong GuildId { get; set; } = Plugin.Instance.Config.GuildId; public async Task Run(SocketSlashCommand command) { diff --git a/DiscordLab.XPSystem/Config.cs b/DiscordLab.XPSystem/Config.cs index b7d9867..556a59d 100644 --- a/DiscordLab.XPSystem/Config.cs +++ b/DiscordLab.XPSystem/Config.cs @@ -1,12 +1,16 @@ using System.ComponentModel; using Discord; +using DiscordLab.Bot.API.Features; +using DiscordLab.Bot.API.Interfaces; using Exiled.API.Interfaces; namespace DiscordLab.XPSystem { - public class Config : IConfig + public class Config : IConfig, IDLConfig { + [Description(DescriptionConstants.IsEnabled)] public bool IsEnabled { get; set; } = true; + [Description(DescriptionConstants.Debug)] public bool Debug { get; set; } = false; [Description("The channel ID to send the level up messages to.")] @@ -14,5 +18,8 @@ public class Config : IConfig [Description("The hex color code of the embed. Do not include the #.")] public string Color { get; set; } = "3498DB"; + + [Description(DescriptionConstants.GuildId)] + public ulong GuildId { get; set; } } } \ No newline at end of file diff --git a/DiscordLab.XPSystem/Handlers/DiscordBot.cs b/DiscordLab.XPSystem/Handlers/DiscordBot.cs index 602efdd..3b4815b 100644 --- a/DiscordLab.XPSystem/Handlers/DiscordBot.cs +++ b/DiscordLab.XPSystem/Handlers/DiscordBot.cs @@ -24,9 +24,10 @@ public void Unregister() public SocketTextChannel GetChannel() { - if (Bot.Handlers.DiscordBot.Instance.Guild == null) return null; + SocketGuild guild = Bot.Handlers.DiscordBot.Instance.GetGuild(Plugin.Instance.Config.GuildId); + if (Bot.Handlers.DiscordBot.Instance.GetGuild(Plugin.Instance.Config.GuildId) == null) return null; if (Plugin.Instance.Config.ChannelId == 0) return null; - return Channel ??= Bot.Handlers.DiscordBot.Instance.Guild.GetTextChannel(Plugin.Instance.Config.ChannelId); + return Channel ??= guild.GetTextChannel(Plugin.Instance.Config.ChannelId); } } } \ No newline at end of file diff --git a/DiscordLab.sln.DotSettings b/DiscordLab.sln.DotSettings new file mode 100644 index 0000000..ee7219b --- /dev/null +++ b/DiscordLab.sln.DotSettings @@ -0,0 +1,3 @@ + + ERROR + BlockScoped \ No newline at end of file