Merge remote-tracking branch 'refs/remotes/Kwoth/dev' into dev

This commit is contained in:
samvaio 2017-01-06 17:27:46 +05:30
commit 1453cabda2
6 changed files with 34 additions and 33 deletions

View File

@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Music.Classes
public string PrettyVolume => $"🔉 {(int)(Volume * 100)}%"; public string PrettyVolume => $"🔉 {(int)(Volume * 100)}%";
public event Action<Song> SongRemoved = delegate { }; public event Action<Song, int> SongRemoved = delegate { };
public MusicPlayer(IVoiceChannel startingVoiceChannel, float? defaultVolume) public MusicPlayer(IVoiceChannel startingVoiceChannel, float? defaultVolume)
{ {
@ -282,7 +282,7 @@ namespace NadekoBot.Modules.Music.Classes
var song = playlist.ElementAtOrDefault(index); var song = playlist.ElementAtOrDefault(index);
if (playlist.Remove(song) && !silent) if (playlist.Remove(song) && !silent)
{ {
SongRemoved(song); SongRemoved(song, index);
} }
}); });

View File

@ -99,16 +99,16 @@ namespace NadekoBot.Modules.Music
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Destroy() public Task Destroy()
{ {
//await Context.Channel.SendErrorAsync("This command is temporarily disabled.").ConfigureAwait(false);
MusicPlayer musicPlayer; MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer)) return; if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer)) return Task.CompletedTask;
if (((IGuildUser)Context.User).VoiceChannel == musicPlayer.PlaybackVoiceChannel) if (((IGuildUser)Context.User).VoiceChannel == musicPlayer.PlaybackVoiceChannel)
if (MusicPlayers.TryRemove(Context.Guild.Id, out musicPlayer)) if (MusicPlayers.TryRemove(Context.Guild.Id, out musicPlayer))
musicPlayer.Destroy(); musicPlayer.Destroy();
return Task.CompletedTask;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -458,31 +458,16 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task Remove(int num) public Task Remove(int num)
{ {
MusicPlayer musicPlayer; MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer)) if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer))
return; return Task.CompletedTask;
if (((IGuildUser)Context.User).VoiceChannel != musicPlayer.PlaybackVoiceChannel) if (((IGuildUser)Context.User).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return; return Task.CompletedTask;
musicPlayer.SongRemoved += async (song) =>
{
try
{
var embed = new EmbedBuilder()
.WithAuthor(eab => eab.WithName("Removed song #" + num).WithMusicIcon())
.WithDescription(song.PrettyName)
.WithFooter(ef => ef.WithText(song.PrettyInfo))
.WithErrorColor();
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
}
catch { }
};
musicPlayer.RemoveSongAt(num - 1); musicPlayer.RemoveSongAt(num - 1);
return Task.CompletedTask;
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -490,8 +475,6 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota
[Priority(1)] [Priority(1)]
public async Task Remove(string all) public async Task Remove(string all)
{ {
if (all.Trim().ToUpperInvariant() != "ALL") if (all.Trim().ToUpperInvariant() != "ALL")
return; return;
MusicPlayer musicPlayer; MusicPlayer musicPlayer;
@ -868,6 +851,23 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota
} }
catch { } catch { }
}; };
mp.SongRemoved += async (song, index) =>
{
try
{
var embed = new EmbedBuilder()
.WithAuthor(eab => eab.WithName("Removed song #" + (index + 1)).WithMusicIcon())
.WithDescription(song.PrettyName)
.WithFooter(ef => ef.WithText(song.PrettyInfo))
.WithErrorColor();
await textCh.EmbedAsync(embed).ConfigureAwait(false);
}
catch { }
};
return mp; return mp;
}); });
Song resolvedSong; Song resolvedSong;

View File

@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Utility
{ {
var channel = (ITextChannel)Context.Channel; var channel = (ITextChannel)Context.Channel;
if (timeout < 0 || timeout > 3600) if ((timeout < 60 && timeout != 0) || timeout > 3600)
return; return;
Timer t; Timer t;

View File

@ -6063,7 +6063,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Rotates a roles color on an interval with a list of supplied colors. First argument is interval in seconds. Second argument is a role, followed by a space-separated list of colors in hex. Provide a rolename with a 0 interval to disable.. /// Looks up a localized string similar to Rotates a roles color on an interval with a list of supplied colors. First argument is interval in seconds (Minimum 60). Second argument is a role, followed by a space-separated list of colors in hex. Provide a rolename with a 0 interval to disable..
/// </summary> /// </summary>
public static string rotaterolecolor_desc { public static string rotaterolecolor_desc {
get { get {
@ -6072,7 +6072,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to `{0}rrc 1 MyLsdRole #ff0000 #00ff00 #0000ff` or `{0}rrc 0 MyLsdRole`. /// Looks up a localized string similar to `{0}rrc 60 MyLsdRole #ff0000 #00ff00 #0000ff` or `{0}rrc 0 MyLsdRole`.
/// </summary> /// </summary>
public static string rotaterolecolor_usage { public static string rotaterolecolor_usage {
get { get {

View File

@ -2866,9 +2866,9 @@
<value>rotaterolecolor rrc</value> <value>rotaterolecolor rrc</value>
</data> </data>
<data name="rotaterolecolor_desc" xml:space="preserve"> <data name="rotaterolecolor_desc" xml:space="preserve">
<value>Rotates a roles color on an interval with a list of supplied colors. First argument is interval in seconds. Second argument is a role, followed by a space-separated list of colors in hex. Provide a rolename with a 0 interval to disable.</value> <value>Rotates a roles color on an interval with a list of supplied colors. First argument is interval in seconds (Minimum 60). Second argument is a role, followed by a space-separated list of colors in hex. Provide a rolename with a 0 interval to disable.</value>
</data> </data>
<data name="rotaterolecolor_usage" xml:space="preserve"> <data name="rotaterolecolor_usage" xml:space="preserve">
<value>`{0}rrc 1 MyLsdRole #ff0000 #00ff00 #0000ff` or `{0}rrc 0 MyLsdRole`</value> <value>`{0}rrc 60 MyLsdRole #ff0000 #00ff00 #0000ff` or `{0}rrc 0 MyLsdRole`</value>
</data> </data>
</root> </root>

View File

@ -80,7 +80,8 @@ namespace NadekoBot
private Task Client_Log(LogMessage arg) private Task Client_Log(LogMessage arg)
{ {
_log.Warn(arg.Exception, arg.Message); _log.Warn(arg.Message);
_log.Error(arg.Exception);
return Task.CompletedTask; return Task.CompletedTask;
} }