More music stuff, more fixes
This commit is contained in:
parent
727da69c81
commit
0b1d47fc4e
@ -195,12 +195,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
if (conf.AutoDeleteSelfAssignedRoleMessages)
|
if (conf.AutoDeleteSelfAssignedRoleMessages)
|
||||||
{
|
{
|
||||||
var t = Task.Run(async () =>
|
msg.DeleteAfter(3);
|
||||||
{
|
umsg.DeleteAfter(3);
|
||||||
await Task.Delay(3000).ConfigureAwait(false);
|
|
||||||
try { await msg.DeleteAsync().ConfigureAwait(false); } catch { } // if 502 or something, i don't want bot crashing
|
|
||||||
try { await usrMsg.DeleteAsync().ConfigureAwait(false); } catch { }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,12 +238,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
if (autoDeleteSelfAssignedRoleMessages)
|
if (autoDeleteSelfAssignedRoleMessages)
|
||||||
{
|
{
|
||||||
var t = Task.Run(async () =>
|
msg.DeleteAfter(3);
|
||||||
{
|
umsg.DeleteAfter(3);
|
||||||
await Task.Delay(3000).ConfigureAwait(false);
|
|
||||||
try { await msg.DeleteAsync().ConfigureAwait(false); } catch { } // if 502 or something, i don't want bot crashing
|
|
||||||
try { await umsg.DeleteAsync().ConfigureAwait(false); } catch { }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var toDelete = await channel.SendMessageAsync(msg.SanitizeMentions()).ConfigureAwait(false);
|
var toDelete = await channel.SendMessageAsync(msg.SanitizeMentions()).ConfigureAwait(false);
|
||||||
if (conf.AutoDeleteByeMessagesTimer > 0)
|
if (conf.AutoDeleteByeMessagesTimer > 0)
|
||||||
{
|
{
|
||||||
var t = Task.Run(async () =>
|
toDelete.DeleteAfter(conf.AutoDeleteByeMessagesTimer);
|
||||||
{
|
|
||||||
await Task.Delay(conf.AutoDeleteByeMessagesTimer * 1000).ConfigureAwait(false); // 5 minutes
|
|
||||||
try { await toDelete.DeleteAsync().ConfigureAwait(false); } catch { }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { _log.Warn(ex); }
|
catch (Exception ex) { _log.Warn(ex); }
|
||||||
@ -91,11 +87,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var toDelete = await channel.SendMessageAsync(msg.SanitizeMentions()).ConfigureAwait(false);
|
var toDelete = await channel.SendMessageAsync(msg.SanitizeMentions()).ConfigureAwait(false);
|
||||||
if (conf.AutoDeleteGreetMessagesTimer > 0)
|
if (conf.AutoDeleteGreetMessagesTimer > 0)
|
||||||
{
|
{
|
||||||
var t = Task.Run(async () =>
|
toDelete.DeleteAfter(conf.AutoDeleteGreetMessagesTimer);
|
||||||
{
|
|
||||||
await Task.Delay(conf.AutoDeleteGreetMessagesTimer * 1000).ConfigureAwait(false); // 5 minutes
|
|
||||||
try { await toDelete.DeleteAsync().ConfigureAwait(false); } catch { }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { _log.Warn(ex); }
|
catch (Exception ex) { _log.Warn(ex); }
|
||||||
|
@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Games.Commands.Hangman
|
|||||||
.AddField(efb => efb.WithName("It was").WithValue(Term.Word))
|
.AddField(efb => efb.WithName("It was").WithValue(Term.Word))
|
||||||
.WithImage(eib => eib.WithUrl(Term.ImageUrl));
|
.WithImage(eib => eib.WithUrl(Term.ImageUrl));
|
||||||
if (Errors >= MaxErrors)
|
if (Errors >= MaxErrors)
|
||||||
await GameChannel.EmbedAsync(embed.WithColor(NadekoBot.ErrorColor).Build()).ConfigureAwait(false);
|
await GameChannel.EmbedAsync(embed.WithErrorColor().Build()).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await GameChannel.EmbedAsync(embed.WithOkColor().Build()).ConfigureAwait(false);
|
await GameChannel.EmbedAsync(embed.WithOkColor().Build()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -119,11 +119,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
await CurrencyHandler.AddCurrencyAsync((IGuildUser)imsg.Author, "Picked flower(s).", msgs.Count, false).ConfigureAwait(false);
|
await CurrencyHandler.AddCurrencyAsync((IGuildUser)imsg.Author, "Picked flower(s).", msgs.Count, false).ConfigureAwait(false);
|
||||||
var msg = await channel.SendConfirmAsync($"**{imsg.Author}** picked {msgs.Count}{Gambling.Gambling.CurrencySign}!").ConfigureAwait(false);
|
var msg = await channel.SendConfirmAsync($"**{imsg.Author}** picked {msgs.Count}{Gambling.Gambling.CurrencySign}!").ConfigureAwait(false);
|
||||||
var t = Task.Run(async () =>
|
msg.DeleteAfter(10);
|
||||||
{
|
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
|
||||||
try { await msg.DeleteAsync().ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
@ -172,8 +172,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var toDelete = await ch.SendConfirmAsync($"{msg.Author.Mention} cast their vote.").ConfigureAwait(false);
|
var toDelete = await ch.SendConfirmAsync($"{msg.Author.Mention} cast their vote.").ConfigureAwait(false);
|
||||||
await Task.Delay(5000);
|
toDelete.DeleteAfter(5);
|
||||||
await toDelete.DeleteAsync().ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
|
|
||||||
public float Volume { get; private set; }
|
public float Volume { get; private set; }
|
||||||
|
|
||||||
public event Func<MusicPlayer, Song, Task> OnCompleted = delegate { return Task.CompletedTask; };
|
public event Action<MusicPlayer, Song> OnCompleted = delegate { };
|
||||||
public event Func<MusicPlayer, Song, Task> OnStarted = delegate { return Task.CompletedTask; };
|
public event Action<MusicPlayer, Song> OnStarted = delegate { };
|
||||||
public event Func<bool, Task> OnPauseChanged = delegate { return Task.CompletedTask; };
|
public event Action<bool> OnPauseChanged = delegate { };
|
||||||
|
|
||||||
public IVoiceChannel PlaybackVoiceChannel { get; private set; }
|
public IVoiceChannel PlaybackVoiceChannel { get; private set; }
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
public string QueuerName { get; set; }
|
public string QueuerName { get; set; }
|
||||||
|
|
||||||
public TimeSpan TotalTime { get; set; } = TimeSpan.Zero;
|
public TimeSpan TotalTime { get; set; } = TimeSpan.Zero;
|
||||||
public TimeSpan CurrentTime => TimeSpan.FromSeconds(bytesSent / frameBytes / 1000 / milliseconds);
|
public TimeSpan CurrentTime => TimeSpan.FromSeconds(bytesSent / frameBytes / (1000 / milliseconds));
|
||||||
|
|
||||||
const int milliseconds = 20;
|
const int milliseconds = 20;
|
||||||
const int samplesPerFrame = (48000 / 1000) * milliseconds;
|
const int samplesPerFrame = (48000 / 1000) * milliseconds;
|
||||||
@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
|
|
||||||
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
||||||
|
|
||||||
public string PrettyCurrentTime => TotalTime.ToString(@"mm\:ss");
|
public string PrettyCurrentTime => CurrentTime.ToString(@"mm\:ss");
|
||||||
|
|
||||||
private string PrettyTotalTime {
|
private string PrettyTotalTime {
|
||||||
get {
|
get {
|
||||||
|
@ -15,6 +15,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Music
|
namespace NadekoBot.Modules.Music
|
||||||
{
|
{
|
||||||
@ -99,7 +100,6 @@ namespace NadekoBot.Modules.Music
|
|||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Destroy(IUserMessage umsg)
|
public async Task Destroy(IUserMessage umsg)
|
||||||
//public Task Destroy(IUserMessage umsg)
|
|
||||||
{
|
{
|
||||||
var channel = (ITextChannel)umsg.Channel;
|
var channel = (ITextChannel)umsg.Channel;
|
||||||
await channel.SendErrorAsync("This command is temporarily disabled.").ConfigureAwait(false);
|
await channel.SendErrorAsync("This command is temporarily disabled.").ConfigureAwait(false);
|
||||||
@ -135,8 +135,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, query).ConfigureAwait(false);
|
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, query).ConfigureAwait(false);
|
||||||
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
umsg.DeleteAfter(10);
|
||||||
await ((IUserMessage)umsg).DeleteAsync().ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +148,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, query, musicType: MusicType.Soundcloud).ConfigureAwait(false);
|
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, query, musicType: MusicType.Soundcloud).ConfigureAwait(false);
|
||||||
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
umsg.DeleteAfter(10);
|
||||||
await ((IUserMessage)umsg).DeleteAsync().ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +180,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
var number = 0 + startAt;
|
var number = 0 + startAt;
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithAuthor(eab => eab.WithName($"Player Queue: Page {page}")
|
.WithAuthor(eab => eab.WithName($"Player Queue - Page {page}")
|
||||||
.WithMusicIcon())
|
.WithMusicIcon())
|
||||||
.WithDescription(string.Join("\n", musicPlayer.Playlist
|
.WithDescription(string.Join("\n", musicPlayer.Playlist
|
||||||
.Skip(startAt)
|
.Skip(startAt)
|
||||||
@ -315,17 +313,21 @@ namespace NadekoBot.Modules.Music
|
|||||||
|
|
||||||
var msg =
|
var msg =
|
||||||
await channel.SendMessageAsync($"🎵 Attempting to queue **{count}** songs".SnPl(count) + "...").ConfigureAwait(false);
|
await channel.SendMessageAsync($"🎵 Attempting to queue **{count}** songs".SnPl(count) + "...").ConfigureAwait(false);
|
||||||
|
var cancelSource = new CancellationTokenSource();
|
||||||
|
|
||||||
foreach (var id in idArray)
|
var tasks = Task.WhenAll(idArray.Select(async id =>
|
||||||
{
|
{
|
||||||
|
if (cancelSource.Token.IsCancellationRequested)
|
||||||
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, id, true).ConfigureAwait(false);
|
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, id, true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (SongNotFoundException) { }
|
catch (SongNotFoundException) { }
|
||||||
catch { break; }
|
catch { try { cancelSource.Cancel(); } catch { } }
|
||||||
|
}));
|
||||||
|
|
||||||
}
|
await Task.WhenAny(tasks, Task.Delay(Timeout.Infinite, cancelSource.Token));
|
||||||
|
|
||||||
await msg.ModifyAsync(m => m.Content = "✅ Playlist queue complete.").ConfigureAwait(false);
|
await msg.ModifyAsync(m => m.Content = "✅ Playlist queue complete.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -411,8 +413,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, radio_link, musicType: MusicType.Radio).ConfigureAwait(false);
|
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, radio_link, musicType: MusicType.Radio).ConfigureAwait(false);
|
||||||
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
umsg.DeleteAfter(10);
|
||||||
await ((IUserMessage)umsg).DeleteAsync().ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,12 +460,13 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
var song = (musicPlayer.Playlist as List<Song>)?[num - 1];
|
var song = (musicPlayer.Playlist as List<Song>)?[num - 1];
|
||||||
musicPlayer.RemoveSongAt(num - 1);
|
musicPlayer.RemoveSongAt(num - 1);
|
||||||
//await channel.SendConfirmAsync($"🎵 Track {song.PrettyName} at position `#{num}` has been **removed**.").ConfigureAwait(false);
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithAuthor(eab => eab.WithName("Song Removed!").WithMusicIcon())
|
.WithAuthor(eab => eab.WithName("Song Removed!").WithMusicIcon())
|
||||||
.AddField(fb => fb.WithName("**Song Position**").WithValue($"#{num}").WithIsInline(true))
|
.AddField(fb => fb.WithName("**Song Position**").WithValue($"#{num}").WithIsInline(true))
|
||||||
.AddField(fb => fb.WithName("**Song Name**").WithValue($"**[{song.SongInfo.Title.TrimTo(70)}]({song.SongInfo.Query})** `{song.PrettyProvider} | {song.QueuerName.TrimTo(15)}`").WithIsInline(true))
|
.AddField(fb => fb.WithName("**Song Name**").WithValue($"**[{song.SongInfo.Title.TrimTo(70)}]({song.SongInfo.Query})** `{song.PrettyProvider} | {song.QueuerName.TrimTo(15)}`").WithIsInline(true))
|
||||||
.WithColor(NadekoBot.ErrorColor);
|
.WithErrorColor();
|
||||||
|
|
||||||
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,10 +663,6 @@ namespace NadekoBot.Modules.Music
|
|||||||
playlists = uow.MusicPlaylists.GetPlaylistsOnPage(num);
|
playlists = uow.MusicPlaylists.GetPlaylistsOnPage(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
//await channel.SendConfirmAsync($@"🎶 **Page {num} of saved playlists:**
|
|
||||||
|
|
||||||
//" + string.Join("\n", playlists.Select(r => $"`#{r.Id}` - **{r.Name}** by __{r.Author}__ ({r.Songs.Count} songs)"))).ConfigureAwait(false);
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithAuthor(eab => eab.WithName($"Page {num} of Saved Playlists").WithMusicIcon())
|
.WithAuthor(eab => eab.WithName($"Page {num} of Saved Playlists").WithMusicIcon())
|
||||||
.WithDescription(string.Join("\n", playlists.Select(r => $"`#{r.Id}` - **{r.Name}**\t by **`{r.Author}`**\t ({r.Songs.Count} songs)")))
|
.WithDescription(string.Join("\n", playlists.Select(r => $"`#{r.Id}` - **{r.Name}**\t by **`{r.Author}`**\t ({r.Songs.Count} songs)")))
|
||||||
@ -842,6 +840,8 @@ namespace NadekoBot.Modules.Music
|
|||||||
};
|
};
|
||||||
IUserMessage playingMessage = null;
|
IUserMessage playingMessage = null;
|
||||||
mp.OnStarted += async (player, song) =>
|
mp.OnStarted += async (player, song) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (playingMessage != null)
|
if (playingMessage != null)
|
||||||
playingMessage.DeleteAfter(0);
|
playingMessage.DeleteAfter(0);
|
||||||
@ -852,9 +852,13 @@ namespace NadekoBot.Modules.Music
|
|||||||
.WithFooter(ef => ef.WithText(song.PrettyInfo))
|
.WithFooter(ef => ef.WithText(song.PrettyInfo))
|
||||||
.Build())
|
.Build())
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
};
|
};
|
||||||
|
|
||||||
mp.OnPauseChanged += async (paused) =>
|
mp.OnPauseChanged += async (paused) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
IUserMessage pauseMessage = null;
|
IUserMessage pauseMessage = null;
|
||||||
if (paused)
|
if (paused)
|
||||||
@ -867,6 +871,8 @@ namespace NadekoBot.Modules.Music
|
|||||||
}
|
}
|
||||||
if (pauseMessage != null)
|
if (pauseMessage != null)
|
||||||
pauseMessage.DeleteAfter(15);
|
pauseMessage.DeleteAfter(15);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
};
|
};
|
||||||
return mp;
|
return mp;
|
||||||
});
|
});
|
||||||
@ -898,16 +904,8 @@ namespace NadekoBot.Modules.Music
|
|||||||
.WithFooter(ef => ef.WithText($"{resolvedSong.PrettyProvider}"))
|
.WithFooter(ef => ef.WithText($"{resolvedSong.PrettyProvider}"))
|
||||||
.Build())
|
.Build())
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
var t = Task.Run(async () =>
|
if (queuedMessage != null)
|
||||||
{
|
queuedMessage.DeleteAfter(10);
|
||||||
try
|
|
||||||
{
|
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
|
||||||
|
|
||||||
await queuedMessage.DeleteAsync().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
catch { } // if queued message sending fails, don't attempt to delete it
|
catch { } // if queued message sending fails, don't attempt to delete it
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
return matches[rng.Next(0, matches.Count)].Groups["ll"].Value;
|
return "http:" + matches[rng.Next(0, matches.Count)].Groups["ll"].Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,9 @@ namespace NadekoBot.Extensions
|
|||||||
public static EmbedBuilder WithOkColor(this EmbedBuilder eb) =>
|
public static EmbedBuilder WithOkColor(this EmbedBuilder eb) =>
|
||||||
eb.WithColor(NadekoBot.OkColor);
|
eb.WithColor(NadekoBot.OkColor);
|
||||||
|
|
||||||
|
public static EmbedBuilder WithErrorColor(this EmbedBuilder eb) =>
|
||||||
|
eb.WithColor(NadekoBot.ErrorColor);
|
||||||
|
|
||||||
public static IMessage DeleteAfter(this IUserMessage msg, int seconds)
|
public static IMessage DeleteAfter(this IUserMessage msg, int seconds)
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
|
Loading…
Reference in New Issue
Block a user