public override async Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { var ctx = context.CastTo <CustomContext>(); var lavaSocket = services.GetRequiredService <LavaSocketClient>(); var player = lavaSocket.GetPlayer(ctx.Guild.Id); if (UserHasToBeInVoice && ctx.User.VoiceChannel is null) { return(PreconditionResult.FromError("You're not connected to a voice channel.")); } if (PlayerNeeded && player is null) { if (ctx.User.VoiceChannel is null) { return(PreconditionResult.FromError("You're not connected to a voice channel.")); } if (!CreatePlayerIfNeeded) { return(PreconditionResult.FromError("I'm not connected to a voice channel.")); } var newPlayerHandler = services.GetRequiredService <NewPlayerHandler>(); await newPlayerHandler.ConnectAsync(ctx.User.VoiceChannel, ctx.Channel.CastTo <ITextChannel>()); } return(PreconditionResult.FromSuccess()); }
public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { var ctx = context.CastTo <CustomContext>(); var databaseHandler = services.GetRequiredService <DatabaseHandler>(); ulong tagManagerRoleId = databaseHandler.Get <GuildEntity>(ctx.Guild.Id).TagsManagerRoleId; if (tagManagerRoleId == default) { return(Task.FromResult(PreconditionResult.FromSuccess())); } if (ctx.User.Roles.Any(r => r.Id == tagManagerRoleId)) { return(Task.FromResult(PreconditionResult.FromSuccess())); } return(Task.FromResult(PreconditionResult.FromError("You are not allowed to do that."))); }
public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { var ctx = context.CastTo <CustomContext>(); var lavaSocket = services.GetRequiredService <LavaSocketClient>(); var player = lavaSocket.GetPlayer(ctx.Guild.Id); if (ctx.User.VoiceChannel is null) { return(Task.FromResult(PreconditionResult.FromError("You're not connected to a voice channel."))); } if (PlayerCheck && player is null) { return(Task.FromResult(PreconditionResult.FromError("There is no player created for this guild."))); } return(Task.FromResult(PreconditionResult.FromSuccess())); }
public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { var ctx = context.CastTo <CustomContext>(); var databaseHandler = services.GetRequiredService <DatabaseHandler>(); var guildEntity = databaseHandler.Get <GuildEntity>(ctx.Guild.Id); if (guildEntity.RolesRequestChannelId != default) { if (ctx.Channel.Id != guildEntity.RolesRequestChannelId) { return(Task.FromResult(PreconditionResult.FromError($"Only allowed in {ctx.Guild.GetChannel(guildEntity.RolesRequestChannelId)?.Name ?? "?"} channel."))); } } if (!guildEntity.UseRolesCommandSystem) { return(Task.FromResult(PreconditionResult.FromError($"Only allowed with bot reactions in {ctx.Guild.GetChannel(guildEntity.RolesRequestChannelId)?.Name ?? " ? "} channel."))); } return(Task.FromResult(PreconditionResult.FromSuccess())); }
public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { var ctx = context.CastTo <CustomContext>(); var databaseHandler = services.GetRequiredService <DatabaseHandler>(); var guildEntity = databaseHandler.Get <GuildEntity>(ctx.Guild.Id); if (guildEntity.AudioCommandChannelId != default) { if (ctx.Channel.Id != guildEntity.AudioCommandChannelId) { return(Task.FromResult(PreconditionResult.FromError($"Only allowed in {ctx.Guild.GetTextChannel(guildEntity.AudioCommandChannelId)?.Name ?? "?"} channel."))); } } if (guildEntity.AudioBotUserRoleId != default) { if (!ctx.User.Roles.Any(r => r.Id == guildEntity.AudioBotUserRoleId)) { return(Task.FromResult(PreconditionResult.FromError($"Only allowed with the {ctx.Guild.GetRole(guildEntity.AudioBotUserRoleId)?.Name ?? "?"} role."))); } } return(Task.FromResult(PreconditionResult.FromSuccess())); }