Added default stuff to db. Added NadekoRandom class. Cleanup.
This commit is contained in:
@@ -61,7 +61,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//public async Task Scsc(IUserMessage msg)
|
||||
//{
|
||||
// var channel = (ITextChannel)msg.Channel;
|
||||
// var token = new Random().Next();
|
||||
// var token = new NadekoRandom().Next();
|
||||
// var set = new HashSet<ITextChannel>();
|
||||
// if (Subscribers.TryAdd(token, set))
|
||||
// {
|
||||
|
@@ -1,220 +0,0 @@
|
||||
//using Discord;
|
||||
//using Discord.Commands;
|
||||
//using NadekoBot.Classes;
|
||||
//using NadekoBot.Extensions;
|
||||
//using NadekoBot.Modules.Permissions.Classes;
|
||||
//using System;
|
||||
//using System.Collections.Concurrent;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
////todo DB
|
||||
////todo Add flags for every event
|
||||
//namespace NadekoBot.Modules.Administration
|
||||
//{
|
||||
// public class LogCommand : DiscordCommand
|
||||
// {
|
||||
// private string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】";
|
||||
|
||||
// private ConcurrentBag<KeyValuePair<Channel, string>> voicePresenceUpdates = new ConcurrentBag<KeyValuePair<Channel, string>>();
|
||||
|
||||
// public LogCommand(DiscordModule module) : base(module)
|
||||
// {
|
||||
// NadekoBot.Client.MessageReceived += MsgRecivd;
|
||||
// NadekoBot.Client.MessageDeleted += MsgDltd;
|
||||
// NadekoBot.Client.MessageUpdated += MsgUpdtd;
|
||||
// NadekoBot.Client.UserUpdated += UsrUpdtd;
|
||||
// NadekoBot.Client.UserBanned += UsrBanned;
|
||||
// NadekoBot.Client.UserLeft += UsrLeft;
|
||||
// NadekoBot.Client.UserJoined += UsrJoined;
|
||||
// NadekoBot.Client.UserUnbanned += UsrUnbanned;
|
||||
// NadekoBot.Client.ChannelCreated += ChannelCreated;
|
||||
// NadekoBot.Client.ChannelDestroyed += ChannelDestroyed;
|
||||
// NadekoBot.Client.ChannelUpdated += ChannelUpdated;
|
||||
|
||||
// // start the userpresence queue
|
||||
|
||||
|
||||
// private async void MsgRecivd(object sender, MessageEventArgs e)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (e.Server == null || e.Channel.IsPrivate || umsg.Author.Id == NadekoBot.Client.CurrentUser.Id)
|
||||
// return;
|
||||
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||
// var chId = config.LogServerChannel;
|
||||
// if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
||||
// return;
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// return;
|
||||
// if (!string.IsNullOrWhiteSpace(e.Message.Text))
|
||||
// {
|
||||
// await ch.SendMessageAsync(
|
||||
// $@"🕔`{prettyCurrentTime}` **New Message** `#{e.Channel.Name}`
|
||||
//👤`{umsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// await ch.SendMessageAsync(
|
||||
// $@"🕔`{prettyCurrentTime}` **File Uploaded** `#{e.Channel.Name}`
|
||||
//👤`{umsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
|
||||
// }
|
||||
|
||||
// }
|
||||
// catch { }
|
||||
|
||||
// private async void UsrUpdtd(object sender, UserUpdatedEventArgs e)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||
// if (chId == null)
|
||||
// return;
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// return;
|
||||
// string str = $"🕔`{prettyCurrentTime}`";
|
||||
// if (e.Before.Name != e.After.Name)
|
||||
// str += $"**Name Changed**👤`{e.Before?.ToString()}`\n\t\t`New:`{e.After.ToString()}`";
|
||||
// else if (e.Before.Nickname != e.After.Nickname)
|
||||
// str += $"**Nickname Changed**👤`{e.Before?.ToString()}`\n\t\t`Old:` {e.Before.Nickname}#{e.Before.Discriminator}\n\t\t`New:` {e.After.Nickname}#{e.After.Discriminator}";
|
||||
// else if (e.Before.AvatarUrl != e.After.AvatarUrl)
|
||||
// str += $"**Avatar Changed**👤`{e.Before?.ToString()}`\n\t {await e.Before.AvatarUrl.ShortenUrl()} `=>` {await e.After.AvatarUrl.ShortenUrl()}";
|
||||
// else if (!e.Before.Roles.SequenceEqual(e.After.Roles))
|
||||
// {
|
||||
// if (e.Before.Roles.Count() < e.After.Roles.Count())
|
||||
// {
|
||||
// var diffRoles = e.After.Roles.Where(r => !e.Before.Roles.Contains(r)).Select(r => "`" + r.Name + "`");
|
||||
// str += $"**User's Roles changed ⚔➕**👤`{e.Before?.ToString()}`\n\tNow has {string.Join(", ", diffRoles)} role.";
|
||||
// }
|
||||
// else if (e.Before.Roles.Count() > e.After.Roles.Count())
|
||||
// {
|
||||
// var diffRoles = e.Before.Roles.Where(r => !e.After.Roles.Contains(r)).Select(r => "`" + r.Name + "`");
|
||||
// str += $"**User's Roles changed ⚔➖**👤`{e.Before?.ToString()}`\n\tNo longer has {string.Join(", ", diffRoles)} role.";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("SEQUENCE NOT EQUAL BUT NO DIFF ROLES - REPORT TO KWOTH on #NADEKOLOG server");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// }
|
||||
// else
|
||||
// return;
|
||||
// await ch.SendMessageAsync(str).ConfigureAwait(false);
|
||||
// }
|
||||
// catch { }
|
||||
// }
|
||||
|
||||
// public override void Init(CommandGroupBuilder cgb)
|
||||
// {
|
||||
|
||||
// cgb.CreateCommand(Module.Prefix + "spmom")
|
||||
// .Description($"Toggles whether mentions of other offline users on your server will send a pm to them. **Needs Manage Server Permissions.**| `{Prefix}spmom`")
|
||||
// .AddCheck(SimpleCheckers.ManageServer())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var specificConfig = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||
// specificConfig.SendPrivateMessageOnMention =
|
||||
// !specificConfig.SendPrivateMessageOnMention;
|
||||
// if (specificConfig.SendPrivateMessageOnMention)
|
||||
// await channel.SendMessageAsync(":ok: I will send private messages " +
|
||||
// "to mentioned offline users.").ConfigureAwait(false);
|
||||
// else
|
||||
// await channel.SendMessageAsync(":ok: I won't send private messages " +
|
||||
// "to mentioned offline users anymore.").ConfigureAwait(false);
|
||||
// });
|
||||
|
||||
// cgb.CreateCommand(Module.Prefix + "logserver")
|
||||
// .Description($"Toggles logging in this channel. Logs every message sent/deleted/edited on the server. **Bot Owner Only!** | `{Prefix}logserver`")
|
||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||
// .AddCheck(SimpleCheckers.ManageServer())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||
// if (chId == null)
|
||||
// {
|
||||
// SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = e.Channel.Id;
|
||||
// await channel.SendMessageAsync($"❗**I WILL BEGIN LOGGING SERVER ACTIVITY IN THIS CHANNEL**❗").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// return;
|
||||
|
||||
// SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = null;
|
||||
// await channel.SendMessageAsync($"❗**NO LONGER LOGGING IN {ch.Mention} CHANNEL**❗").ConfigureAwait(false);
|
||||
// });
|
||||
|
||||
|
||||
// cgb.CreateCommand(Prefix + "logignore")
|
||||
// .Description($"Toggles whether the {Prefix}logserver command ignores this channel. Useful if you have hidden admin channel and public log channel. **Bot Owner Only!**| `{Prefix}logignore`")
|
||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||
// .AddCheck(SimpleCheckers.ManageServer())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||
// if (config.LogserverIgnoreChannels.Remove(e.Channel.Id))
|
||||
// {
|
||||
// await channel.SendMessageAsync($"`{Prefix}logserver will stop ignoring this channel.`");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// config.LogserverIgnoreChannels.Add(e.Channel.Id);
|
||||
// await channel.SendMessageAsync($"`{Prefix}logserver will ignore this channel.`");
|
||||
// }
|
||||
// });
|
||||
|
||||
// cgb.CreateCommand(Module.Prefix + "userpresence")
|
||||
// .Description($"Starts logging to this channel when someone from the server goes online/offline/idle. **Needs Manage Server Permissions.**| `{Prefix}userpresence`")
|
||||
// .AddCheck(SimpleCheckers.ManageServer())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel;
|
||||
// if (chId == null)
|
||||
// {
|
||||
// SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = e.Channel.Id;
|
||||
// await channel.SendMessageAsync($"**User presence notifications enabled.**").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = null;
|
||||
// await channel.SendMessageAsync($"**User presence notifications disabled.**").ConfigureAwait(false);
|
||||
// });
|
||||
|
||||
// cgb.CreateCommand(Module.Prefix + "voicepresence")
|
||||
// .Description($"Toggles logging to this channel whenever someone joins or leaves a voice channel you are in right now. **Needs Manage Server Permissions.**| `{Prefix}voicerpresence`")
|
||||
// .Parameter("all", ParameterType.Optional)
|
||||
// .AddCheck(SimpleCheckers.ManageServer())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
|
||||
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||
// if (all?.ToLower() == "all")
|
||||
// {
|
||||
// foreach (var voiceChannel in e.Server.VoiceChannels)
|
||||
// {
|
||||
// config.VoiceChannelLog.TryAdd(voiceChannel.Id, e.Channel.Id);
|
||||
// }
|
||||
// await channel.SendMessageAsync("Started logging user presence for **ALL** voice channels!").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (umsg.Author.VoiceChannel == null)
|
||||
// {
|
||||
// await channel.SendMessageAsync("💢 You are not in a voice channel right now. If you are, please rejoin it.").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// ulong throwaway;
|
||||
// if (!config.VoiceChannelLog.TryRemove(umsg.Author.VoiceChannel.Id, out throwaway))
|
||||
// {
|
||||
// config.VoiceChannelLog.TryAdd(umsg.Author.VoiceChannel.Id, e.Channel.Id);
|
||||
// await channel.SendMessageAsync($"`Logging user updates for` {umsg.Author.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||
// }
|
||||
// else
|
||||
// await channel.SendMessageAsync($"`Stopped logging user updates for` {umsg.Author.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//}
|
@@ -49,12 +49,14 @@ namespace NadekoBot.Modules.Administration
|
||||
t = new Timer(async (state) =>
|
||||
{
|
||||
var keys = UserPresenceUpdates.Keys.ToList();
|
||||
foreach (var key in keys)
|
||||
|
||||
await Task.WhenAll(keys.Select(key =>
|
||||
{
|
||||
List<string> messages;
|
||||
if (UserPresenceUpdates.TryRemove(key, out messages))
|
||||
try { await key.SendMessageAsync(string.Join(Environment.NewLine, messages)); } catch { } //502/403
|
||||
}
|
||||
try { return key.SendMessageAsync(string.Join(Environment.NewLine, messages)); } catch { } //502/403
|
||||
return Task.CompletedTask;
|
||||
}));
|
||||
}, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));
|
||||
|
||||
|
||||
|
@@ -130,7 +130,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
private async Task StartRace()
|
||||
{
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
Participant winner = null;
|
||||
IUserMessage msg = null;
|
||||
int place = 1;
|
||||
@@ -194,14 +194,15 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
}
|
||||
|
||||
private async Task Client_MessageReceived(IMessage imsg)
|
||||
private Task Client_MessageReceived(IMessage imsg)
|
||||
{
|
||||
var msg = imsg as IUserMessage;
|
||||
if (msg == null)
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
if (msg.IsAuthor() || !(imsg.Channel is ITextChannel) || imsg.Channel != raceChannel)
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
messagesSinceGameStarted++;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task CheckForFullGameAsync(CancellationToken cancelToken)
|
||||
|
@@ -2,6 +2,7 @@ using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -27,7 +28,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
private async Task publicRoll(IUserMessage umsg, string arg, bool ordered)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
var r = new Random();
|
||||
var r = new NadekoRandom();
|
||||
//if (string.IsNullOrWhiteSpace(arg))
|
||||
//{
|
||||
// var gen = r.Next(0, 101);
|
||||
@@ -124,11 +125,11 @@ namespace NadekoBot.Modules.Gambling
|
||||
.ToArray();
|
||||
if (arr[0] > arr[1])
|
||||
throw new ArgumentException("First argument should be bigger than the second one.");
|
||||
rolled = new Random().Next(arr[0], arr[1] + 1);
|
||||
rolled = new NadekoRandom().Next(arr[0], arr[1] + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
rolled = new Random().Next(0, int.Parse(range) + 1);
|
||||
rolled = new NadekoRandom().Next(0, int.Parse(range) + 1);
|
||||
}
|
||||
|
||||
await channel.SendMessageAsync($"{umsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false);
|
||||
|
@@ -66,7 +66,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
// var isHeads = guessStr == "HEADS" || guessStr == "H";
|
||||
// bool result = false;
|
||||
// var rng = new Random();
|
||||
// var rng = new NadekoRandom();
|
||||
// if (rng.Next(0, 2) == 1)
|
||||
// {
|
||||
// await channel.SendFileAsync("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -114,7 +116,7 @@ namespace NadekoBot.Modules.Gambling.Models
|
||||
}
|
||||
}
|
||||
}
|
||||
private Random r = new Random();
|
||||
private Random r = new NadekoRandom();
|
||||
/// <summary>
|
||||
/// Take a card from the pool, you either take it from the top if the deck is shuffled, or from a random place if the deck is in the default order.
|
||||
/// </summary>
|
||||
@@ -143,7 +145,7 @@ namespace NadekoBot.Modules.Gambling.Models
|
||||
private void Shuffle()
|
||||
{
|
||||
if (cardPool.Count <= 1) return;
|
||||
var orderedPool = cardPool.OrderBy(x => r.Next());
|
||||
var orderedPool = cardPool.Shuffle();
|
||||
cardPool = cardPool as List<Card> ?? orderedPool.ToList();
|
||||
}
|
||||
public override string ToString() => string.Concat(cardPool.Select(c => c.ToString())) + Environment.NewLine;
|
||||
|
@@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
var members = role.Members().Where(u => u.Status == UserStatus.Online);
|
||||
var membersArray = members as IUser[] ?? members.ToArray();
|
||||
var usr = membersArray[new Random().Next(0, membersArray.Length)];
|
||||
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
||||
await channel.SendMessageAsync($"**Raffled user:** {usr.Username} (id: {usr.Id})").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
await CurrencyHandler.RemoveCurrencyAsync(guildUser, "Betroll Gamble", amount, false).ConfigureAwait(false);
|
||||
|
||||
var rng = new Random().Next(0, 101);
|
||||
var rng = new NadekoRandom().Next(0, 101);
|
||||
var str = $"{guildUser.Mention} `You rolled {rng}.` ";
|
||||
if (rng < 67)
|
||||
{
|
||||
|
@@ -44,7 +44,7 @@ namespace NadekoBot.Modules.Games
|
||||
public PlantPickCommands()
|
||||
{
|
||||
NadekoBot.Client.MessageReceived += PotentialFlowerGeneration;
|
||||
rng = new Random();
|
||||
rng = new NadekoRandom();
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
|
@@ -100,11 +100,11 @@ namespace NadekoBot.Modules.Games.Trivia
|
||||
ShouldStopGame = true;
|
||||
}
|
||||
|
||||
private async Task PotentialGuess(IMessage imsg)
|
||||
private Task PotentialGuess(IMessage imsg)
|
||||
{
|
||||
var umsg = imsg as IUserMessage;
|
||||
if (umsg == null)
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
var t = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
@@ -135,6 +135,7 @@ namespace NadekoBot.Modules.Games.Trivia
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public string GetLeaderboard()
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NadekoBot.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -11,7 +12,7 @@ namespace NadekoBot.Modules.Games.Trivia
|
||||
public static TriviaQuestionPool Instance { get; } = new TriviaQuestionPool();
|
||||
public HashSet<TriviaQuestion> pool = new HashSet<TriviaQuestion>();
|
||||
|
||||
private Random rng { get; } = new Random();
|
||||
private Random rng { get; } = new NadekoRandom();
|
||||
|
||||
static TriviaQuestionPool() { }
|
||||
|
||||
@@ -36,7 +37,7 @@ namespace NadekoBot.Modules.Games.Trivia
|
||||
var tq = new TriviaQuestion(item["Question"].ToString(), item["Answer"].ToString(), item["Category"]?.ToString());
|
||||
pool.Add(tq);
|
||||
}
|
||||
var r = new Random();
|
||||
var r = new NadekoRandom();
|
||||
pool = new HashSet<TriviaQuestion>(pool.OrderBy(x => r.Next()));
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ namespace NadekoBot.Modules.Games
|
||||
var listArr = list.Split(';');
|
||||
if (listArr.Count() < 2)
|
||||
return;
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
await channel.SendMessageAsync(listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Games
|
||||
|
||||
if (string.IsNullOrWhiteSpace(question))
|
||||
return;
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
await channel.SendMessageAsync($@":question: `Question` __**{question}**__
|
||||
🎱 `8Ball Answers` __**{_8BallResponses.Shuffle().FirstOrDefault()}**__").ConfigureAwait(false);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace NadekoBot.Modules.Games
|
||||
default:
|
||||
return;
|
||||
}
|
||||
var nadekoPick = new Random().Next(0, 3);
|
||||
var nadekoPick = new NadekoRandom().Next(0, 3);
|
||||
var msg = "";
|
||||
if (pick == nadekoPick)
|
||||
msg = $"It's a draw! Both picked :{GetRPSPick(pick)}:";
|
||||
|
@@ -37,41 +37,44 @@ namespace NadekoBot.Modules.Music
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Next(IUserMessage umsg)
|
||||
public Task Next(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return Task.CompletedTask;
|
||||
if (musicPlayer.PlaybackVoiceChannel == ((IGuildUser)umsg.Author).VoiceChannel)
|
||||
musicPlayer.Next();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Stop(IUserMessage umsg)
|
||||
public Task Stop(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return Task.CompletedTask;
|
||||
if (((IGuildUser)umsg.Author).VoiceChannel == musicPlayer.PlaybackVoiceChannel)
|
||||
{
|
||||
musicPlayer.Autoplay = false;
|
||||
musicPlayer.Stop();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Destroy(IUserMessage umsg)
|
||||
public Task Destroy(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryRemove(channel.Guild.Id, out musicPlayer)) return;
|
||||
if (!MusicPlayers.TryRemove(channel.Guild.Id, out musicPlayer)) return Task.CompletedTask;
|
||||
if (((IGuildUser)umsg.Author).VoiceChannel == musicPlayer.PlaybackVoiceChannel)
|
||||
musicPlayer.Destroy();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
@@ -204,28 +207,30 @@ namespace NadekoBot.Modules.Music
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Mute(IUserMessage umsg)
|
||||
public Task Mute(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
if (((IGuildUser)umsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
musicPlayer.SetVolume(0);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Max(IUserMessage umsg)
|
||||
public Task Max(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
if (((IGuildUser)umsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
musicPlayer.SetVolume(100);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
@@ -395,7 +400,7 @@ namespace NadekoBot.Modules.Music
|
||||
var voiceChannel = ((IGuildUser)umsg.Author).VoiceChannel;
|
||||
if (voiceChannel == null || voiceChannel.Guild != channel.Guild || !MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
musicPlayer.MoveToVoiceChannel(voiceChannel);
|
||||
await musicPlayer.MoveToVoiceChannel(voiceChannel);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
|
@@ -116,7 +116,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
JToken obj;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new Random().Next(0, 9880) }").ConfigureAwait(false))[0];
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new NadekoRandom().Next(0, 9880) }").ConfigureAwait(false))[0];
|
||||
}
|
||||
await channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
JToken obj;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new Random().Next(0, 3873) }").ConfigureAwait(false))[0];
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new NadekoRandom().Next(0, 3873) }").ConfigureAwait(false))[0];
|
||||
}
|
||||
await channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
|
||||
public static async Task<string> GetDanbooruImageLink(string tag)
|
||||
{
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
|
||||
if (tag == "loli") //loli doesn't work for some reason atm
|
||||
tag = "flat_chest";
|
||||
@@ -181,7 +181,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
if (matches.Count == 0)
|
||||
return null;
|
||||
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
var match = matches[rng.Next(0, matches.Count)];
|
||||
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
|
||||
public static async Task<string> GetRule34ImageLink(string tag)
|
||||
{
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
var url =
|
||||
$"http://rule34.xxx/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
||||
using (var http = new HttpClient())
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Modules.Searches.Models;
|
||||
using NadekoBot.Services;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
@@ -86,7 +87,7 @@ namespace NadekoBot.Modules.Searches
|
||||
if (!wowJokes.Any())
|
||||
{
|
||||
}
|
||||
await channel.SendMessageAsync(wowJokes[new Random().Next(0, wowJokes.Count)].ToString());
|
||||
await channel.SendMessageAsync(wowJokes[new NadekoRandom().Next(0, wowJokes.Count)].ToString());
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
@@ -94,7 +95,7 @@ namespace NadekoBot.Modules.Searches
|
||||
public async Task MagicItem(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
var item = magicItems[rng.Next(0, magicItems.Count)].ToString();
|
||||
|
||||
await channel.SendMessageAsync(item).ConfigureAwait(false);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -52,7 +53,7 @@ namespace NadekoBot.Modules.Searches
|
||||
var dataList = data.Distinct(new ChampionNameComparer()).Take(showCount).ToList();
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"**Showing {dataList.Count} top banned champions.**");
|
||||
sb.AppendLine($"`{trashTalk[new Random().Next(0, trashTalk.Length)]}`");
|
||||
sb.AppendLine($"`{trashTalk[new NadekoRandom().Next(0, trashTalk.Length)]}`");
|
||||
for (var i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
if (i % 2 == 0 && i != 0)
|
||||
|
@@ -152,7 +152,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
{
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(query)}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&start={ rng.Next(1, 50) }&fields=items%2Flink&key={NadekoBot.Credentials.GoogleApiKey}";
|
||||
var obj = JObject.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false));
|
||||
var items = obj["items"] as JArray;
|
||||
@@ -428,7 +428,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
var allUsrs = umsg.MentionedUsers.Append(umsg.Author);
|
||||
var allUsrsArray = allUsrs.ToArray();
|
||||
var str = allUsrsArray.Aggregate("http://appear.in/", (current, usr) => current + Uri.EscapeUriString(usr.Username[0].ToString()));
|
||||
str += new Random().Next();
|
||||
str += new NadekoRandom().Next();
|
||||
foreach (var usr in allUsrsArray)
|
||||
{
|
||||
await (await (usr as IGuildUser).CreateDMChannelAsync()).SendMessageAsync(str).ConfigureAwait(false);
|
||||
@@ -457,7 +457,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
|
||||
public static async Task<string> GetSafebooruImageLink(string tag)
|
||||
{
|
||||
var rng = new Random();
|
||||
var rng = new NadekoRandom();
|
||||
var url =
|
||||
$"http://safebooru.org/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
||||
using (var http = new HttpClient())
|
||||
|
Reference in New Issue
Block a user