Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public StoredMessagesService(ulong guildId)
 {
     guildBotVars = BotVarManager.GetGuildBotVarCollection(guildId);
 }