INIT
This commit is contained in:
24
TomatenMusicCore/Commands/Checks/OnlyGuildCheck.cs
Normal file
24
TomatenMusicCore/Commands/Checks/OnlyGuildCheck.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
41
TomatenMusicCore/Commands/Checks/UserInMusicChannelCheck.cs
Normal file
41
TomatenMusicCore/Commands/Checks/UserInMusicChannelCheck.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
27
TomatenMusicCore/Commands/Checks/UserInVoiceChannelCheck.cs
Normal file
27
TomatenMusicCore/Commands/Checks/UserInVoiceChannelCheck.cs
Normal 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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user