Esempio n. 1
0
 public override async Task <PreconditionResult> CheckPermissionsAsync([NotNull] ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (context.User is IVoiceState)
     {
         return(PreconditionResult.FromSuccess());
     }
     else
     {
         return(PreconditionResult.FromError("Not in a voice channel"));
     }
 }
Esempio n. 2
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (GlobalConstants.ValidModIds.Contains(context.User.Id))
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError($"Du hast nicht die Berechtigungen, um diesen Befehl auszuführen {GlobalConstants.Glatt}")));
     }
 }
 public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (context.Guild.Id == 324282875035779072)
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError("This command can only be run on the WhizL server")));
     }
 }
Esempio n. 4
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (IsServiceLoaded(services))
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError($"Service: {reqService.Name} is not currently loaded.")));
     }
 }
Esempio n. 5
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            if ((context.Message.Author as IGuildUser).RoleIds.Contains(_roleId))
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }

            string role = context.Guild.GetRole(_roleId)?.Name;

            return(Task.FromResult(PreconditionResult.FromError($"You do not have the required role ({role ?? "undefined"}) to run this command.")));
        }
Esempio n. 6
0
        public override async Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            Player player = ChatCraft.Instance.GetPlayer(context.User);

            if (!player.isAdmin)
            {
                return(PreconditionResult.FromError("You are not an admin."));
            }

            return(PreconditionResult.FromSuccess());
        }
Esempio n. 7
0
 public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (context.User.Id == UserId)
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError(ErrorMessage)));
     }
 }
Esempio n. 8
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext ctx, CommandInfo command, IServiceProvider services)
        {
            var context = ctx as Context;

            if (context.GuildUser.RoleIds.Any(x => x == context.DbGuild.MutedRoleId))
            {
                return(Task.FromResult(PreconditionResult.FromError("You may not use this command while muted.")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
Esempio n. 9
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            ServerDatabase ServerDb = services.GetService <ServerDatabase>();

            if (ServerDb.Servers.FirstOrDefault(x => x.ServerSnowflake == context.Guild.Id) == null)
            {
                return(Task.FromResult(PreconditionResult.FromError("A server admin needs to run `!server setup` first before this command can be used")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
Esempio n. 10
0
 /// <summary>Returns a PreconditionResult after evaluating the context with the requirements.</summary>
 /// <param name="context">Command context of the current message.</param>
 /// <param name="command">Command object</param>
 /// <param name="services">Injection service object</parem>
 /// <returns>PreconditionResult</returns>
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (context.User is IGuildUser && _requiredRoleId.Any(x => (context.User as IGuildUser).RoleIds.Contains(x)))
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError("You do not have the required role or user ID")));
     }
 }
Esempio n. 11
0
        public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            var c = (DiscordSocketClient)context.Client;

            if (c.ShardId != 0)
            {
                return(Task.FromResult(PreconditionResult.FromError("Must be ran from shard #0")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (context.User.Id == ApplicationContext.BotOwner.Id) // Or more in the future
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError("This command can only be used by the developer of the bot.")));
     }
 }
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (!ChannelPokemonManager.ChannelsToSpawn.Any(x => (ulong)x.ChId == context.Channel.Id))
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError("No channel permission")));
     }
 }
Esempio n. 14
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            var config = (Configuration)services.GetService(typeof(Configuration));

            if (config.Owners.Contains(context.User.Id))
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }

            return(Task.FromResult(context.Channel.Id == 205878045859381257 ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("This must be ran in #bot-palace.")));
        }
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, ParameterInfo parameter, object value, IServiceProvider services)
        {
            var vc = value as SocketVoiceChannel;

            if (context.Guild.Id != vc.Guild.Id)
            {
                return(Task.FromResult(PreconditionResult.FromError("Cannot edit channels outside of your own guild")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
Esempio n. 16
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, ParameterInfo parameter, object value, IServiceProvider services)
        {
            var user = value as IUser;

            if (context.User.Id == user.Id)
            {
                return(Task.FromResult(PreconditionResult.FromError("You cannot run this command on yourself.")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
Esempio n. 17
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (context.User.Id == context.Client.CurrentUser.Id)
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError("User is not the bot.")));
     }
 }
Esempio n. 18
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (Module.ConstVariables.ThisTest)
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromError("Выполняется только во время тестов!")));
     }
 }
        public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider prov)
        {
            var t = context.Channel as ITextChannel;

            if (t.Topic.Contains($"[{_name}]") || context.Channel is IDMChannel)
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }
            return(Task.FromResult(
                       PreconditionResult.FromError($"Command is only available in channels containing `[{_name}]` in their topic")));
        }
Esempio n. 20
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     Logger.Debug($"Checking cooldown: {context.User.Username} {command.Name}");
     if (CommandCooldown.Audit(context))
     {
         return(Task.FromResult(
                    PreconditionResult.FromError(
                        $"{context.User.Mention}, you have to wait for another {CommandCooldown.GetCoolDown(context.User.Id).AsRoundedDuration()} to use this command.")));
     }
     return(Task.FromResult(PreconditionResult.FromSuccess()));
 }
Esempio n. 21
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            var attachment = context.Message.Attachments.FirstOrDefault();

            if (attachment == default(Attachment))
            {
                return(Task.FromResult(PreconditionResult.FromError("You must attach an image.")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
Esempio n. 22
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext ctx, CommandInfo command, IServiceProvider services)
        {
            var context = ctx as Context;

            if (!context.DbGuild.MutedRoleId.HasValue)
            {
                return(Task.FromResult(PreconditionResult.FromError(("The muted role has not been set."))));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
        // Public members

        public override async Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            if (context.Channel is IGuildChannel)
            {
                return(await Task.FromResult(PreconditionResult.FromSuccess()));
            }
            else
            {
                return(await Task.FromResult(PreconditionResult.FromError("This command can only be used in guilds.")));
            }
        }
Esempio n. 24
0
        public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IDependencyMap map)
        {
            var user = context.User as SocketGuildUser;

            if (!user.Roles.Any(r => r.Id == HostRoleId || r.Id == IsLeader.LeaderRoleId))
            {
                return(Task.FromResult(PreconditionResult.FromError("Only ZU Hosts and Leaders can use this command")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
Esempio n. 25
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, ParameterInfo parameter, object value, IServiceProvider services)
        {
            var inputString  = Convert.ToString(value);
            var isOffCommand = !string.IsNullOrEmpty(inputString) && inputString.Equals("off", StringComparison.InvariantCultureIgnoreCase);

            if (isOffCommand)
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }
            return(Task.FromResult(PreconditionResult.FromError($"The input string '{inputString}' is not equal to 'off'.")));
        }
Esempio n. 26
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (!AllowedIDS.Contains(context.User.Id))
     {
         return(Task.FromResult(PreconditionResult.FromError("No administrator permission")));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
 }
Esempio n. 27
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo commandInfo, IServiceProvider service)
        {
            var mContext = context as MinitoriContext;

            if (mContext == null || !mContext.IsHelp)
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }

            return(Task.FromResult(PreconditionResult.FromError("Help command, cannot run")));
        }
Esempio n. 28
0
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (!Constants._BOTOWNERS_.Contains(context.User.Id))
     {
         return(Task.FromResult(PreconditionResult.FromError("Command can only be run by the owner of the bot.")));
     }
     else
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
 }
Esempio n. 29
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, ParameterInfo parameter, object value, IServiceProvider services)
        {
            var user = value is IUser ? (IUser)value : null;

            if ((user != null) && (context.User.Id == user.Id))
            {
                return(Task.FromResult(PreconditionResult.FromError("You can't use this command on yourself")));
            }

            return(Task.FromResult(PreconditionResult.FromSuccess()));
        }
Esempio n. 30
0
 public override async Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
 {
     if (AllowedChannelList.Contains(context.Channel.Id))
     {
         return(await Task.FromResult(PreconditionResult.FromSuccess()));
     }
     else
     {
         return(await Task.FromResult(PreconditionResult.FromError("You cannot run such command in current room")));
     }
 }