\CayciV2Bot\CayciV2Bot\Core\AudioModule.cs

Return Back
using System.Threading.Tasks;
using CayciV2Bot.Services;
using Discord;
using Discord.Commands;

namespace CayciV2Bot.Core
{
public class AudioModule : ModuleBase<SocketCommandContext>
{
public AudioService AudioService { get; set; }
private const string _err = "This command must be ran from within a server";

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("join", RunMode = RunMode.Async)]
[Alias("j")]
public async Task JoinAsync()
{
AudioService._client = Context.Client;
await AudioService.JoinAsync((Context.User as IGuildUser)?.VoiceChannel, Context.Channel);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("play", RunMode = RunMode.Async)]
[Alias("p")]
public async Task PlayAsync([Remainder] string item)
{
AudioService._client = Context.Client;
await AudioService.AddAsync(Context.Guild, (Context.User as IGuildUser)?.VoiceChannel, Context.Channel, Context.User as IGuildUser, item, false);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("playlist", RunMode = RunMode.Async)]
[Alias("pl")]
public async Task PlayListAsync([Remainder] string item)
{
AudioService._client = Context.Client;
await AudioService.AddPlayListAsync(Context.Guild, (Context.User as IGuildUser)?.VoiceChannel, Context.Channel, Context.User as IGuildUser, item);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("playnext", RunMode = RunMode.Async)]
[Alias("pn")]
public async Task PlayNextAsync([Remainder] string item)
{
AudioService._client = Context.Client;
await AudioService.AddAsync(Context.Guild, (Context.User as IGuildUser)?.VoiceChannel, Context.Channel, Context.User as IGuildUser, item, isNext: true);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("movetonext")]
[Alias("mn")]
public async Task MoveToNextAsync(int pos)
{
AudioService._client = Context.Client;
await AudioService.QMoveToTopAsync(Context.Guild, Context.Channel, pos);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("nowplaying")]
[Alias("np")]
public async Task NowPlayingAsync()
{
AudioService._client = Context.Client;
await AudioService.GetNowPlayingAsync(Context.Guild, Context.Channel);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("skip")]
[Alias("s")]
public async Task SkipAsync()
{
AudioService._client = Context.Client;
await AudioService.SkipAsync(Context.Guild, Context.Channel);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("queue")]
[Alias("q")]
public async Task QueueAsync()
{
AudioService._client = Context.Client;
await AudioService.GetQueueAsync(Context.Guild, Context.Channel);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("shuffle")]
[Alias("sf")]
public async Task ShuffleAsync()
{
AudioService._client = Context.Client;
await AudioService.QShuffleAsync(Context.Guild, Context.Channel);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("remove")]
[Alias("rm")]
public async Task RemoveAsync(int pos)
{
AudioService._client = Context.Client;
await AudioService.QRemoveAsync(Context.Guild, Context.Channel, pos);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("removeall")]
[Alias("rma")]
public async Task RemoveAllAsync()
{
AudioService._client = Context.Client;
await AudioService.QRemoveAllAsync(Context.Guild, Context.Channel);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("stop", RunMode = RunMode.Async)]
public async Task StopAsync()
{
AudioService._client = Context.Client;
await AudioService.StopAsync(Context.Guild, Context.Channel);
}

[RequireContext(ContextType.Guild, ErrorMessage = _err)]
[Command("leave", RunMode = RunMode.Async)]
public async Task LeaveAsync()
{
AudioService._client = Context.Client;
await AudioService.LeaveAsync(Context.Guild, Context.Channel);
}
}
}