INIT
This commit is contained in:
59
TomatenMusicCore/Prompt/Buttons/AddToQueueButton.cs
Normal file
59
TomatenMusicCore/Prompt/Buttons/AddToQueueButton.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using DSharpPlus.Entities;
|
||||
using Lavalink4NET;
|
||||
using Lavalink4NET.Player;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TomatenMusic.Music;
|
||||
using TomatenMusic.Music.Entitites;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using TomatenMusicCore.Music;
|
||||
using TomatenMusicCore.Music.Entities;
|
||||
using TomatenMusic.Prompt.Option;
|
||||
|
||||
namespace TomatenMusic.Prompt.Buttons
|
||||
{
|
||||
class AddToQueueButton : ButtonPromptOption
|
||||
{
|
||||
public TrackList Tracks { get; set; }
|
||||
|
||||
public AddToQueueButton(TrackList tracks, int row, DiscordMember requestMember)
|
||||
{
|
||||
Tracks = tracks;
|
||||
Emoji = new DiscordComponentEmoji("▶️");
|
||||
Row = row;
|
||||
Style = DSharpPlus.ButtonStyle.Secondary;
|
||||
UpdateMethod = (prompt) =>
|
||||
{
|
||||
if (requestMember.VoiceState == null || requestMember.VoiceState.Channel == null)
|
||||
prompt.Disabled = true;
|
||||
|
||||
return Task.FromResult(prompt);
|
||||
};
|
||||
Run = async (args, sender, option) =>
|
||||
{
|
||||
IAudioService audioService = TomatenMusicBot.ServiceProvider.GetRequiredService<IAudioService>();
|
||||
GuildPlayer player;
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
player = await audioService.JoinAsync<GuildPlayer>(args.Guild.Id, ((DiscordMember)args.User).VoiceState.Channel.Id, true);
|
||||
|
||||
}catch (Exception ex)
|
||||
{
|
||||
player = audioService.GetPlayer<GuildPlayer>(args.Guild.Id);
|
||||
}
|
||||
await player.PlayItemAsync(Tracks);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
60
TomatenMusicCore/Prompt/Buttons/PlayNowButton.cs
Normal file
60
TomatenMusicCore/Prompt/Buttons/PlayNowButton.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using DSharpPlus.Entities;
|
||||
using Lavalink4NET;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TomatenMusic;
|
||||
using TomatenMusic.Music;
|
||||
using TomatenMusic.Prompt;
|
||||
using TomatenMusic.Prompt.Option;
|
||||
using TomatenMusicCore.Music.Entities;
|
||||
|
||||
namespace TomatenMusicCore.Prompt.Buttons
|
||||
{
|
||||
class PlayNowButton : ButtonPromptOption
|
||||
{
|
||||
public TrackList Tracks { get; set; }
|
||||
|
||||
public PlayNowButton(TrackList tracks, int row, DiscordMember requestMember)
|
||||
{
|
||||
Tracks = tracks;
|
||||
Emoji = new DiscordComponentEmoji("▶");
|
||||
Content = "Now";
|
||||
Row = row;
|
||||
Style = DSharpPlus.ButtonStyle.Secondary;
|
||||
UpdateMethod = (prompt) =>
|
||||
{
|
||||
if (requestMember.VoiceState == null || requestMember.VoiceState.Channel == null)
|
||||
prompt.Disabled = true;
|
||||
|
||||
return Task.FromResult(prompt);
|
||||
};
|
||||
Run = async (args, sender, option) =>
|
||||
{
|
||||
IAudioService audioService = TomatenMusicBot.ServiceProvider.GetRequiredService<IAudioService>();
|
||||
GuildPlayer player;
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
player = await audioService.JoinAsync<GuildPlayer>(args.Guild.Id, ((DiscordMember)args.User).VoiceState.Channel.Id, true);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
player = audioService.GetPlayer<GuildPlayer>(args.Guild.Id);
|
||||
}
|
||||
await player.PlayNowAsync(Tracks);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user