This commit is contained in:
Tim Müller
2022-03-29 22:12:22 +02:00
commit 147eed234f
76 changed files with 6489 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.SlashCommands;
using DSharpPlus;
using TomatenMusic.Music;
namespace TomatenMusic.Commands.Checks
{
public class OnlyGuildCheck : SlashCheckBaseAttribute
{
public override async Task<bool> ExecuteChecksAsync(InteractionContext ctx)
{
if (ctx.Guild == null)
{
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DSharpPlus.Entities.DiscordInteractionResponseBuilder().WithContent("This Command is only available on Guilds.").AsEphemeral(true));
return false;
}
return true;
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.SlashCommands;
using DSharpPlus.EventArgs;
using DSharpPlus;
using TomatenMusic.Music;
using Emzi0767.Utilities;
using Lavalink4NET;
using Microsoft.Extensions.DependencyInjection;
namespace TomatenMusic.Commands.Checks
{
public class UserInMusicChannelCheck : SlashCheckBaseAttribute
{
public bool _passIfNull { get; set; }
public UserInMusicChannelCheck(bool passIfNull = false)
{
_passIfNull = passIfNull;
}
public override async Task<bool> ExecuteChecksAsync(InteractionContext ctx)
{
IAudioService audioService = TomatenMusicBot.ServiceProvider.GetRequiredService<IAudioService>();
GuildPlayer player = audioService.GetPlayer<GuildPlayer>(ctx.Guild.Id);
bool allowed;
//TODO
if (player != null)
{
allowed = ctx.Member.VoiceState.Channel != null && ctx.Member.VoiceState.Channel.Id == player.VoiceChannelId;
}
else
allowed = _passIfNull;
if (!allowed)
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DSharpPlus.Entities.DiscordInteractionResponseBuilder().WithContent("❌ Please connect to the Bots Channel to use this Command").AsEphemeral(true));
return allowed;
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.SlashCommands;
using DSharpPlus;
using TomatenMusic.Music;
namespace TomatenMusic.Commands.Checks
{
class UserInVoiceChannelCheck : SlashCheckBaseAttribute
{
public override async Task<bool> ExecuteChecksAsync(InteractionContext ctx)
{
if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null)
{
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DSharpPlus.Entities.DiscordInteractionResponseBuilder().WithContent("You are not in a Voice Channel.").AsEphemeral(true));
return false;
}
return true;
}
}
}