public override bool PreconditionCheckGuild(IGuildCommandContext context, out string message) { GuildBotVarCollection BotVarCollection = BotVarManager.GetGuildBotVarCollection(context.Guild.Id); if (!BotVarCollection.TryGetBotVar(BotVarId, out ulong roleId)) { message = $"The guild config variable `{BotVarId}` has to be set to the correct role id!"; return(false); } bool hasRole = context.GuildUser.Roles.Any(role => { if (role.Id == roleId) { if (roleMention == null) { roleMention = role.Mention; } return(true); } return(false); }); if (!hasRole) { message = $"You do not have required role {(roleMention == null ? Markdown.InlineCodeBlock(roleId) : roleMention)}!"; } else { message = null; } return(hasRole); }
public static GuildChannelMeta GetDefaultOrSaved(ulong guildId, ulong channelId) { GuildBotVarCollection guildBotVarCollection = BotVarManager.GetGuildBotVarCollection(guildId); if (!guildBotVarCollection.TryGetBotVar($"{channelId}.meta", out GuildChannelMeta channelMeta)) { channelMeta = GetDefault(guildId); } return(channelMeta); }
public static GuildChannelMeta GetDefault(ulong guildId) { if (!guildDefaults.TryGetValue(guildId, out GuildChannelMeta guildDefault)) { GuildBotVarCollection guildBotVarCollection = BotVarManager.GetGuildBotVarCollection(guildId); if (!guildBotVarCollection.TryGetBotVar("defaultguildchannelmeta", out guildDefault)) { guildDefault = new GuildChannelMeta(); } guildDefaults.Add(guildId, guildDefault); guildBotVarCollection.SubscribeToBotVarUpdateEvent(OnBotVarUpdated, "defaultguildchannelmeta"); } return(guildDefault); }
public StoredMessagesService(ulong guildId) { guildBotVars = BotVarManager.GetGuildBotVarCollection(guildId); }