Some replacements, main gambling file done

This commit is contained in:
Kwoth 2016-08-20 16:43:44 +02:00
parent 68454a7b2f
commit 43c9e7d04d
21 changed files with 203 additions and 230 deletions

View File

@ -238,13 +238,13 @@ namespace NadekoBot
{er.Exception}
-------------------------------------
");
Console.WriteLine($">>COMMAND ERRORED after *{(DateTime.UtcNow - dt).TotalSeconds}s*\nCmd: {e.Command.Text}\nMsg: {e.Message.Text}\nUsr: {e.User.Name} [{e.User.Id}]\nSrvr: {e.Server?.Name ?? "PRIVATE"} [{e.Server?.Id}]\n-----");
Console.WriteLine($">>COMMAND ERRORED after *{(DateTime.UtcNow - dt).TotalSeconds}s*\nCmd: {e.Command.Text}\nMsg: {e.Message.Text}\nUsr: {imsg.Author.Username} [{imsg.Author.Id}]\nSrvr: {e.Server?.Name ?? "PRIVATE"} [{e.Server?.Id}]\n-----");
}
}
else
{
Console.WriteLine($">>COMMAND ENDED after *{(DateTime.UtcNow - dt).TotalSeconds}s*\nCmd: {e.Command.Text}\nMsg: {e.Message.Text}\nUsr: {e.User.Name} [{e.User.Id}]\nSrvr: {e.Server?.Name ?? "PRIVATE"} [{e.Server?.Id}]\n-----");
Console.WriteLine($">>COMMAND ENDED after *{(DateTime.UtcNow - dt).TotalSeconds}s*\nCmd: {e.Command.Text}\nMsg: {e.Message.Text}\nUsr: {imsg.Author.Username} [{imsg.Author.Id}]\nSrvr: {e.Server?.Name ?? "PRIVATE"} [{e.Server?.Id}]\n-----");
}
}
catch { }
@ -253,7 +253,7 @@ namespace NadekoBot
private async void StatsCollector_RanCommand(object sender, CommandEventArgs e)
{
commandTracker.TryAdd(e.Message.Id, DateTime.UtcNow);
Console.WriteLine($">>COMMAND STARTED\nCmd: {e.Command.Text}\nMsg: {e.Message.Text}\nUsr: {e.User.Name} [{e.User.Id}]\nSrvr: {e.Server?.Name ?? "PRIVATE"} [{e.Server?.Id}]\n-----");
Console.WriteLine($">>COMMAND STARTED\nCmd: {e.Command.Text}\nMsg: {e.Message.Text}\nUsr: {imsg.Author.Username} [{imsg.Author.Id}]\nSrvr: {e.Server?.Name ?? "PRIVATE"} [{e.Server?.Id}]\n-----");
#if !NADEKO_RELEASE
await Task.Run(() =>
{
@ -266,8 +266,8 @@ namespace NadekoBot
ServerName = e.Server?.Name ?? "--Direct Message--",
ChannelId = (long)e.Channel.Id,
ChannelName = e.Channel.IsPrivate ? "--Direct Message" : e.Channel.Name,
UserId = (long)e.User.Id,
UserName = e.User.Name,
UserId = (long)imsg.Author.Id,
UserName = imsg.Author.Username,
CommandName = e.Command.Text,
DateAdded = DateTime.Now
});

View File

@ -23,7 +23,7 @@ namespace NadekoBot.Modules.Administration.Commands
//if (role == null)
// return;
//e.User.AddRoles(role);
//imsg.Author.AddRoles(role);
return Task.CompletedTask;
};
}

View File

@ -18,7 +18,7 @@
// {
// try
// {
// if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
// if (imsg.Author.Id == NadekoBot.Client.CurrentUser.Id) return;
// foreach (var subscriber in Subscribers)
// {
// var set = subscriber.Value;
@ -26,7 +26,7 @@
// continue;
// foreach (var chan in set.Except(new[] { e.Channel }))
// {
// await chan.SendMessage(GetText(e.Server, e.Channel, e.User, e.Message)).ConfigureAwait(false);
// await chan.SendMessage(GetText(e.Server, e.Channel, imsg.Author, e.Message)).ConfigureAwait(false);
// }
// }
// }
@ -46,9 +46,9 @@
// {
// var msg = chan.Messages
// .FirstOrDefault(m =>
// m.RawText == GetText(e.Server, e.Channel, e.User, e.Before));
// m.RawText == GetText(e.Server, e.Channel, imsg.Author, e.Before));
// if (msg != default(Message))
// await msg.Edit(GetText(e.Server, e.Channel, e.User, e.After)).ConfigureAwait(false);
// await msg.Edit(GetText(e.Server, e.Channel, imsg.Author, e.After)).ConfigureAwait(false);
// }
// }
@ -75,7 +75,7 @@
// if (Subscribers.TryAdd(token, set))
// {
// set.Add(e.Channel);
// await e.User.SendMessage("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
// await imsg.Author.SendMessage("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
// }
// });

View File

@ -23,7 +23,7 @@
// var incs = DbHandler.Instance.FindAll<Incident>(i => i.ServerId == sid && i.Read == false);
// DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return i; }));
// await e.User.SendMessage(string.Join("\n----------------------", incs.Select(i => i.Text)));
// await imsg.Author.SendMessage(string.Join("\n----------------------", incs.Select(i => i.Text)));
// });
// cgb.CreateCommand(Module.Prefix + "listallincidents")
@ -41,7 +41,7 @@
// sw.WriteLine(data);
// sw.Flush();
// sw.BaseStream.Position = 0;
// await e.User.SendFile("incidents.txt", sw.BaseStream);
// await imsg.Author.SendFile("incidents.txt", sw.BaseStream);
// });
// }
// }

View File

@ -36,17 +36,17 @@
// NadekoBot.Client.MessageReceived += async (s, e) =>
// {
// if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
// if (e.Channel.IsPrivate || imsg.Author.Id == NadekoBot.Client.CurrentUser.Id)
// return;
// if (!SpecificConfigurations.Default.Of(e.Server.Id).SendPrivateMessageOnMention) return;
// try
// {
// var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != e.User);
// var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != imsg.Author);
// if (usr?.Status != UserStatus.Offline)
// return;
// await channel.SendMessageAsync($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false);
// await usr.SendMessage(
// $"User `{e.User.Name}` mentioned you on " +
// $"User `{imsg.Author.Username}` mentioned you on " +
// $"`{e.Server.Name}` server while you were offline.\n" +
// $"`Message:` {e.Message.Text}").ConfigureAwait(false);
// }
@ -148,7 +148,7 @@
// Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return;
// await ch.SendMessage($"`{prettyCurrentTime}`♻`User was unbanned:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
// await ch.SendMessage($"`{prettyCurrentTime}`♻`User was unbanned:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// }
// catch { }
// }
@ -163,7 +163,7 @@
// Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return;
// await ch.SendMessage($"`{prettyCurrentTime}`✅`User joined:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
// await ch.SendMessage($"`{prettyCurrentTime}`✅`User joined:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// }
// catch { }
// }
@ -178,7 +178,7 @@
// Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return;
// await ch.SendMessage($"`{prettyCurrentTime}`❗`User left:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
// await ch.SendMessage($"`{prettyCurrentTime}`❗`User left:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// }
// catch { }
// }
@ -193,7 +193,7 @@
// Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return;
// await ch.SendMessage($"❗`{prettyCurrentTime}`❌`User banned:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
// await ch.SendMessage($"❗`{prettyCurrentTime}`❌`User banned:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// }
// catch { }
// }
@ -202,7 +202,7 @@
// {
// try
// {
// if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
// if (e.Server == null || e.Channel.IsPrivate || imsg.Author.Id == NadekoBot.Client.CurrentUser.Id)
// return;
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
// var chId = config.LogServerChannel;
@ -215,13 +215,13 @@
// {
// await ch.SendMessage(
// $@"🕔`{prettyCurrentTime}` **New Message** `#{e.Channel.Name}`
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
// }
// else
// {
// await ch.SendMessage(
// $@"🕔`{prettyCurrentTime}` **File Uploaded** `#{e.Channel.Name}`
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
// }
// }
@ -231,7 +231,7 @@
// {
// try
// {
// if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id)
// if (e.Server == null || e.Channel.IsPrivate || imsg.Author?.Id == NadekoBot.Client.CurrentUser.Id)
// return;
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
// var chId = config.LogServerChannel;
@ -244,13 +244,13 @@
// {
// await ch.SendMessage(
// $@"🕔`{prettyCurrentTime}` **Message** 🚮 `#{e.Channel.Name}`
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
// }
// else
// {
// await ch.SendMessage(
// $@"🕔`{prettyCurrentTime}` **File Deleted** `#{e.Channel.Name}`
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
// }
// }
// catch { }
@ -259,7 +259,7 @@
// {
// try
// {
// if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id)
// if (e.Server == null || e.Channel.IsPrivate || imsg.Author?.Id == NadekoBot.Client.CurrentUser.Id)
// return;
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
// var chId = config.LogServerChannel;
@ -270,7 +270,7 @@
// return;
// await ch.SendMessage(
// $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}`
//👤`{e.User?.ToString() ?? ("NULL")}`
//👤`{imsg.Author?.ToString() ?? ("NULL")}`
// `Old:` {e.Before.Text.Unmention()}
// `New:` {e.After.Text.Unmention()}").ConfigureAwait(false);
// }
@ -466,19 +466,19 @@
// return;
// }
// if (e.User.VoiceChannel == null)
// if (imsg.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(e.User.VoiceChannel.Id, out throwaway))
// if (!config.VoiceChannelLog.TryRemove(imsg.Author.VoiceChannel.Id, out throwaway))
// {
// config.VoiceChannelLog.TryAdd(e.User.VoiceChannel.Id, e.Channel.Id);
// await channel.SendMessageAsync($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
// config.VoiceChannelLog.TryAdd(imsg.Author.VoiceChannel.Id, e.Channel.Id);
// await channel.SendMessageAsync($"`Logging user updates for` {imsg.Author.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
// }
// else
// await channel.SendMessageAsync($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
// await channel.SendMessageAsync($"`Stopped logging user updates for` {imsg.Author.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
// });
// }
// }

View File

@ -131,12 +131,12 @@
// await channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
// return;
// }
// if (e.User.HasRole(role))
// if (imsg.Author.HasRole(role))
// {
// await channel.SendMessageAsync($":anger:You already have {role.Name} role.").ConfigureAwait(false);
// return;
// }
// var sameRoles = e.User.Roles.Where(r => config.ListOfSelfAssignableRoles.Contains(r.Id));
// var sameRoles = imsg.Author.Roles.Where(r => config.ListOfSelfAssignableRoles.Contains(r.Id));
// if (config.ExclusiveSelfAssignedRoles && sameRoles.Any())
// {
// await channel.SendMessageAsync($":anger:You already have {sameRoles.FirstOrDefault().Name} role.").ConfigureAwait(false);
@ -144,7 +144,7 @@
// }
// try
// {
// await e.User.AddRoles(role).ConfigureAwait(false);
// await imsg.Author.AddRoles(role).ConfigureAwait(false);
// }
// catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.InternalServerError)
// {
@ -187,12 +187,12 @@
// await channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
// return;
// }
// if (!e.User.HasRole(role))
// if (!imsg.Author.HasRole(role))
// {
// await channel.SendMessageAsync($":anger:You don't have {role.Name} role.").ConfigureAwait(false);
// return;
// }
// await e.User.RemoveRoles(role).ConfigureAwait(false);
// await imsg.Author.RemoveRoles(role).ConfigureAwait(false);
// var msg = await channel.SendMessageAsync($":ok:Successfuly removed {role.Name} role from you.").ConfigureAwait(false);
// await Task.Delay(3000).ConfigureAwait(false);
// await msg.Delete().ConfigureAwait(false);

View File

@ -39,7 +39,7 @@
// var controls = AnnouncementsDictionary[e.Server.Id];
// var channel = NadekoBot.Client.GetChannel(controls.ByeChannel);
// var msg = controls.ByeText.Replace("%user%", "**" + e.User.Name + "**").Trim();
// var msg = controls.ByeText.Replace("%user%", "**" + imsg.Author.Username + "**").Trim();
// if (string.IsNullOrEmpty(msg))
// return;
@ -48,7 +48,7 @@
// Greeted++;
// try
// {
// await e.User.SendMessage($"`Farewell Message From {e.Server?.Name}`\n" + msg).ConfigureAwait(false);
// await imsg.Author.SendMessage($"`Farewell Message From {e.Server?.Name}`\n" + msg).ConfigureAwait(false);
// }
// catch { }
@ -78,13 +78,13 @@
// var controls = AnnouncementsDictionary[e.Server.Id];
// var channel = NadekoBot.Client.GetChannel(controls.GreetChannel);
// var msg = controls.GreetText.Replace("%user%", e.User.Mention).Trim();
// var msg = controls.GreetText.Replace("%user%", imsg.Author.Mention).Trim();
// if (string.IsNullOrEmpty(msg))
// return;
// if (controls.GreetPM)
// {
// Greeted++;
// await e.User.SendMessage($"`Welcome Message From {e.Server.Name}`\n" + msg).ConfigureAwait(false);
// await imsg.Author.SendMessage($"`Welcome Message From {e.Server.Name}`\n" + msg).ConfigureAwait(false);
// }
// else
// {
@ -211,7 +211,7 @@
// .Description($"Toggles automatic deletion of greet and bye messages. **Needs Manage Server Permissions.**| `{Prefix}grdel`")
// .Do(async e =>
// {
// if (!e.User.ServerPermissions.ManageServer) return;
// if (!imsg.Author.ServerPermissions.ManageServer) return;
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
// if (ann.ToggleDelete())
@ -224,7 +224,7 @@
// .Description($"Toggles anouncements on the current channel when someone joins the server. **Needs Manage Server Permissions.**| `{Prefix}greet`")
// .Do(async e =>
// {
// if (!e.User.ServerPermissions.ManageServer) return;
// if (!imsg.Author.ServerPermissions.ManageServer) return;
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
// if (ann.ToggleGreet(e.Channel.Id))
@ -238,7 +238,7 @@
// .Parameter("msg", ParameterType.Unparsed)
// .Do(async e =>
// {
// if (!e.User.ServerPermissions.ManageServer) return;
// if (!imsg.Author.ServerPermissions.ManageServer) return;
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
// {
@ -257,7 +257,7 @@
// .Description($"Toggles anouncements on the current channel when someone leaves the server. | `{Prefix}bye`")
// .Do(async e =>
// {
// if (!e.User.ServerPermissions.ManageServer) return;
// if (!imsg.Author.ServerPermissions.ManageServer) return;
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
// if (ann.ToggleBye(e.Channel.Id))
@ -271,7 +271,7 @@
// .Parameter("msg", ParameterType.Unparsed)
// .Do(async e =>
// {
// if (!e.User.ServerPermissions.ManageServer) return;
// if (!imsg.Author.ServerPermissions.ManageServer) return;
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
// {
@ -289,7 +289,7 @@
// .Description($"Toggles whether the good bye messages will be sent in a PM or in the text channel. **Needs Manage Server Permissions.**| `{Prefix}byepm`")
// .Do(async e =>
// {
// if (!e.User.ServerPermissions.ManageServer) return;
// if (!imsg.Author.ServerPermissions.ManageServer) return;
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
@ -305,7 +305,7 @@
// .Description($"Toggles whether the greet messages will be sent in a PM or in the text channel. **Needs Manage Server Permissions.**| `{Prefix}greetpm`")
// .Do(async e =>
// {
// if (!e.User.ServerPermissions.ManageServer) return;
// if (!imsg.Author.ServerPermissions.ManageServer) return;
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));

View File

@ -11,7 +11,8 @@ using System.Threading.Tasks;
namespace NadekoBot.Modules.Gambling.Commands
{
class AnimalRacing : DiscordCommand
[Group]
class AnimalRacing
{
public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces = new ConcurrentDictionary<ulong, AnimalRace>();
@ -44,24 +45,24 @@ namespace NadekoBot.Modules.Gambling.Commands
if (!int.TryParse(e.GetArg("amount"), out amount) || amount < 0)
amount = 0;
var userFlowers = GamblingModule.GetUserFlowers(e.User.Id);
var userFlowers = Gambling.GetUserFlowers(imsg.Author.Id);
if (userFlowers < amount)
{
await imsg.Channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
await channel.SendMessageAsync($"{imsg.Author.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
return;
}
if (amount > 0)
await FlowersHandler.RemoveFlowers(e.User, "BetRace", (int)amount, true).ConfigureAwait(false);
await FlowersHandler.RemoveFlowers(imsg.Author, "BetRace", (int)amount, true).ConfigureAwait(false);
AnimalRace ar;
if (!AnimalRaces.TryGetValue(e.Server.Id, out ar))
{
await imsg.Channel.SendMessageAsync("No race exists on this server");
await channel.SendMessageAsync("No race exists on this server");
return;
}
await ar.JoinRace(e.User, amount);
await ar.JoinRace(imsg.Author, amount);
});
}
@ -77,7 +78,7 @@ namespace NadekoBot.Modules.Gambling.Commands
private ulong serverId;
private int messagesSinceGameStarted = 0;
public Channel raceChannel { get; set; }
public IGuildChannel raceChannel { get; set; }
public bool Started { get; private set; } = false;
public AnimalRace(ulong serverId, Channel ch)
@ -134,7 +135,7 @@ namespace NadekoBot.Modules.Gambling.Commands
{
var rng = new Random();
Participant winner = null;
Message msg = null;
IMessage msg = null;
int place = 1;
try
{
@ -196,7 +197,7 @@ namespace NadekoBot.Modules.Gambling.Commands
}
private void Client_MessageReceived(object sender, MessageEventArgs e)
private void Client_MessageReceived(IMessage imsg)
{
if (e.Message.IsAuthor || e.Channel.IsPrivate || e.Channel != raceChannel)
return;
@ -211,7 +212,7 @@ namespace NadekoBot.Modules.Gambling.Commands
}
}
public async Task<bool> JoinRace(User u, int amount = 0)
public async Task<bool> JoinRace(IGuildUser u, int amount = 0)
{
var animal = "";
if (!animals.TryDequeue(out animal))
@ -238,7 +239,7 @@ namespace NadekoBot.Modules.Gambling.Commands
public class Participant
{
public User User { get; set; }
public IGuildUser User { get; set; }
public string Animal { get; set; }
public int AmountBet { get; set; }
@ -247,7 +248,7 @@ namespace NadekoBot.Modules.Gambling.Commands
public int Place { get; set; } = 0;
public Participant(User u, string a, int amount)
public Participant(IGuildUser u, string a, int amount)
{
this.User = u;
this.Animal = a;

View File

@ -151,7 +151,7 @@ namespace NadekoBot.Modules.Gambling
rolled = new Random().Next(0, int.Parse(e.GetArg("range")) + 1);
}
await channel.SendMessageAsync($"{e.User.Mention} rolled **{rolled}**.").ConfigureAwait(false);
await channel.SendMessageAsync($"{imsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false);
}
catch (Exception ex)
{

View File

@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Gambling
await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()).ConfigureAwait(false);
if (cardObjects.Count == 5)
{
await channel.SendMessageAsync($"{e.User.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false);
await channel.SendMessageAsync($"{imsg.Author.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false);
}
}
catch (Exception ex)

View File

@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Gambling
//{
// var channel = imsg.Channel as ITextChannel;
// var usr = e.Message.MentionedUsers.FirstOrDefault() ?? e.User;
// var usr = e.Message.MentionedUsers.FirstOrDefault() ?? imsg.Author;
// var pts = GetUserFlowers(usr.Id);
// var str = $"{usr.Name} has {pts} {NadekoBot.Config.CurrencySign}";
// await channel.SendMessageAsync(str).ConfigureAwait(false);
@ -58,14 +58,14 @@ namespace NadekoBot.Modules.Gambling
// if (userFlowers < amount)
// {
// await channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
// await channel.SendMessageAsync($"{imsg.Author.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
// return;
// }
// await FlowersHandler.RemoveFlowers(e.User, "Gift", (int)amount, true).ConfigureAwait(false);
// await FlowersHandler.RemoveFlowers(imsg.Author, "Gift", (int)amount, true).ConfigureAwait(false);
// await FlowersHandler.AddFlowersAsync(receiver, "Gift", (int)amount).ConfigureAwait(false);
// await channel.SendMessageAsync($"{e.User.Mention} successfully sent {amount} {NadekoBot.Config.CurrencyName}s to {receiver.Mention}!").ConfigureAwait(false);
// await channel.SendMessageAsync($"{imsg.Author.Mention} successfully sent {amount} {NadekoBot.Config.CurrencyName}s to {receiver.Mention}!").ConfigureAwait(false);
//}
@ -87,122 +87,94 @@ namespace NadekoBot.Modules.Gambling
// await FlowersHandler.AddFlowersAsync(usrId, $"Awarded by bot owner. ({imsg.Author.Username}/{imsg.Author.Id})", (int)amount).ConfigureAwait(false);
// await channel.SendMessageAsync($"{e.User.Mention} successfully awarded {amount} {NadekoBot.Config.CurrencyName}s to <@{usrId}>!").ConfigureAwait(false);
// await channel.SendMessageAsync($"{imsg.Author.Mention} successfully awarded {amount} {NadekoBot.Config.CurrencyName}s to <@{usrId}>!").ConfigureAwait(false);
//}
////todo owner only
////todo DB
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
//[RequireContext(ContextType.Guild)]
//public Task Take(IMessage imsg, long amount, [Remainder] IGuildUser user) =>
// Take(imsg, amount, user.Id);
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task Take(IMessage imsg, long amount, [Remainder] IGuildUser ownedPerson)
{
var channel = imsg.Channel as ITextChannel;
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
//[RequireContext(ContextType.Guild)]
//public async Task Take(IMessage imsg, long amount, [Remainder] ulong usrId)
//{
// var channel = imsg.Channel as ITextChannel;
// if (amount <= 0)
// return;
if (amount < 0)
return;
// await FlowersHandler.RemoveFlowers(usrId, $"Taken by bot owner.({imsg.Author.Username}/{imsg.Author.Id})", (int)amount).ConfigureAwait(false);
var mentionedUser = e.Message.MentionedUsers.FirstOrDefault(u =>
u.Id != NadekoBot.Client.CurrentUser.Id);
if (mentionedUser == null)
return;
// await channel.SendMessageAsync($"{imsg.Author.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from <@{usrId}>!").ConfigureAwait(false);
//}
await FlowersHandler.RemoveFlowers(ownedPerson.Id, $"Taken by bot owner.({e.User.Name}/{e.User.Id})", (int)amount).ConfigureAwait(false);
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
//[RequireContext(ContextType.Guild)]
//public async Task BetRoll(IMessage imsg, int amount)
//{
// var channel = imsg.Channel as ITextChannel;
await channel.SendMessageAsync($"{e.User.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from {mentionedUser.Mention}!").ConfigureAwait(false);
// if (amount < 1)
// return;
// var userFlowers = GetUserFlowers(imsg.Author.Id);
// if (userFlowers < amount)
// {
// await channel.SendMessageAsync($"{imsg.Author.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
// return;
// }
// await FlowersHandler.RemoveFlowers(imsg.Author, "Betroll Gamble", (int)amount, true).ConfigureAwait(false);
// var rng = new Random().Next(0, 101);
// var str = $"{imsg.Author.Mention} `You rolled {rng}.` ";
// if (rng < 67)
// {
// str += "Better luck next time.";
// }
// else if (rng < 90)
// {
// str += $"Congratulations! You won {amount * 2}{NadekoBot.Config.CurrencySign} for rolling above 66";
// await FlowersHandler.AddFlowersAsync(imsg.Author, "Betroll Gamble", amount * 2, true).ConfigureAwait(false);
// }
// else if (rng < 100)
// {
// str += $"Congratulations! You won {amount * 3}{NadekoBot.Config.CurrencySign} for rolling above 90.";
// await FlowersHandler.AddFlowersAsync(imsg.Author, "Betroll Gamble", amount * 3, true).ConfigureAwait(false);
// }
// else
// {
// str += $"👑 Congratulations! You won {amount * 10}{NadekoBot.Config.CurrencySign} for rolling **100**. 👑";
// await FlowersHandler.AddFlowersAsync(imsg.Author, "Betroll Gamble", amount * 10, true).ConfigureAwait(false);
// }
// await channel.SendMessageAsync(str).ConfigureAwait(false);
//}
////todo DB
// [LocalizedCommand, LocalizedDescription, LocalizedSummary]
// [RequireContext(ContextType.Guild)]
// public async Task Leaderboard(IMessage imsg)
// {
// var channel = imsg.Channel as ITextChannel;
// var richestTemp = DbHandler.Instance.GetTopRichest();
// var richest = richestTemp as CurrencyState[] ?? richestTemp.ToArray();
// if (richest.Length == 0)
// return;
// await channel.SendMessageAsync(
// richest.Aggregate(new StringBuilder(
//$@"```xl
//┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
//┃ Id ┃ $$$ ┃
//"),
// (cur, cs) => cur.AppendLine(
//$@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━┫
//┃{(e.Server.Users.Where(u => u.Id == (ulong)cs.UserId).FirstOrDefault()?.Name.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs.Value,5} ┃")
// ).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━┛```").ConfigureAwait(false);
}
public override void Install(ModuleManager manager)
{
cgb.CreateCommand(Prefix + "award")
.Description($"Gives someone a certain amount of flowers. **Bot Owner Only!** | `{Prefix}award 100 @person`")
.AddCheck(SimpleCheckers.OwnerOnly())
.Parameter("amount", ParameterType.Required)
.Parameter("receiver", ParameterType.Unparsed)
.Do(async e =>
{
});
cgb.CreateCommand(Prefix + "take")
.Description($"Takes a certain amount of flowers from someone. **Bot Owner Only!** | `{Prefix}take 1 \"@someguy\"`")
.AddCheck(SimpleCheckers.OwnerOnly())
.Parameter("amount", ParameterType.Required)
.Parameter("rektperson", ParameterType.Unparsed)
.Do(async e =>
{
});
cgb.CreateCommand(Prefix + "betroll")
.Alias(Prefix + "br")
.Description($"Bets a certain amount of {NadekoBot.Config.CurrencyName}s and rolls a dice. Rolling over 66 yields x2 flowers, over 90 - x3 and 100 x10. | `{Prefix}br 5`")
.Parameter("amount", ParameterType.Required)
.Do(async e =>
{
var amountstr = e.GetArg("amount").Trim();
int amount;
if (!int.TryParse(amountstr, out amount) || amount < 1)
return;
var userFlowers = GetUserFlowers(e.User.Id);
if (userFlowers < amount)
{
await channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
return;
}
await FlowersHandler.RemoveFlowers(e.User, "Betroll Gamble", (int)amount, true).ConfigureAwait(false);
var rng = new Random().Next(0, 101);
var str = $"{e.User.Mention} `You rolled {rng}.` ";
if (rng < 67)
{
str += "Better luck next time.";
}
else if (rng < 90)
{
str += $"Congratulations! You won {amount * 2}{NadekoBot.Config.CurrencySign} for rolling above 66";
await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 2, true).ConfigureAwait(false);
}
else if (rng < 100)
{
str += $"Congratulations! You won {amount * 3}{NadekoBot.Config.CurrencySign} for rolling above 90.";
await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 3, true).ConfigureAwait(false);
}
else
{
str += $"👑 Congratulations! You won {amount * 10}{NadekoBot.Config.CurrencySign} for rolling **100**. 👑";
await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 10, true).ConfigureAwait(false);
}
await channel.SendMessageAsync(str).ConfigureAwait(false);
});
cgb.CreateCommand(Prefix + "leaderboard")
.Alias(Prefix + "lb")
.Description($"Displays bot currency leaderboard | `{Prefix}lb`")
.Do(async e =>
{
var richestTemp = DbHandler.Instance.GetTopRichest();
var richest = richestTemp as CurrencyState[] ?? richestTemp.ToArray();
if (richest.Length == 0)
return;
await channel.SendMessageAsync(
richest.Aggregate(new StringBuilder(
$@"```xl
Id $$$
"),
(cur, cs) => cur.AppendLine(
$@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━┫
{(e.Server.Users.Where(u => u.Id == (ulong)cs.UserId).FirstOrDefault()?.Name.TrimTo(18, true) ?? cs.UserId.ToString()),-20} {cs.Value,5} ")
).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━┛```").ConfigureAwait(false);
});
});
}
public static long GetUserFlowers(ulong userId) =>
Classes.DbHandler.Instance.GetStateByUserId((long)userId)?.Value ?? 0;
}
}
}

View File

@ -79,8 +79,8 @@
// foreach(var msgToDelete in msgs)
// await msgToDelete.Delete().ConfigureAwait(false);
// await FlowersHandler.AddFlowersAsync(e.User, "Picked a flower.", 1, true).ConfigureAwait(false);
// var msg = await channel.SendMessageAsync($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!").ConfigureAwait(false);
// await FlowersHandler.AddFlowersAsync(imsg.Author, "Picked a flower.", 1, true).ConfigureAwait(false);
// var msg = await channel.SendMessageAsync($"**{imsg.Author.Username}** picked a {NadekoBot.Config.CurrencyName}!").ConfigureAwait(false);
// ThreadPool.QueueUserWorkItem(async (state) =>
// {
// try
@ -104,7 +104,7 @@
// await channel.SendMessageAsync($"There is already a {NadekoBot.Config.CurrencyName} in this channel.").ConfigureAwait(false);
// return;
// }
// var removed = await FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1, true).ConfigureAwait(false);
// var removed = await FlowersHandler.RemoveFlowers(imsg.Author, "Planted a flower.", 1, true).ConfigureAwait(false);
// if (!removed)
// {
// await channel.SendMessageAsync($"You don't have any {NadekoBot.Config.CurrencyName}s.").ConfigureAwait(false);
@ -118,7 +118,7 @@
// else
// msg = await e.Channel.SendFile(file).ConfigureAwait(false);
// var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]);
// var msg2 = await channel.SendMessageAsync($"Oh how Nice! **{e.User.Name}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick").ConfigureAwait(false);
// var msg2 = await channel.SendMessageAsync($"Oh how Nice! **{imsg.Author.Username}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick").ConfigureAwait(false);
// plantedFlowerChannels.TryAdd(e.Channel.Id, new[] { msg, msg2 });
// }
// finally { locker.Release(); }

View File

@ -103,16 +103,16 @@
// {
// try
// {
// if (e.Channel == null || e.Channel.Id != channel.Id || e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
// if (e.Channel == null || e.Channel.Id != channel.Id || imsg.Author.Id == NadekoBot.Client.CurrentUser.Id) return;
// var guess = e.Message.RawText;
// var distance = CurrentSentence.LevenshteinDistance(guess);
// var decision = Judge(distance, guess.Length);
// if (decision && !finishedUserIds.Contains(e.User.Id))
// if (decision && !finishedUserIds.Contains(imsg.Author.Id))
// {
// finishedUserIds.Add(e.User.Id);
// await channel.Send($"{e.User.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false);
// finishedUserIds.Add(imsg.Author.Id);
// await channel.Send($"{imsg.Author.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false);
// if (finishedUserIds.Count % 2 == 0)
// {
// await channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false);
@ -139,7 +139,7 @@
// public Func<CommandEventArgs, Task> DoFunc() =>
// async e =>
// {
// var game = RunningContests.GetOrAdd(e.User.Server.Id, id => new TypingGame(e.Channel));
// var game = RunningContests.GetOrAdd(imsg.Author.Server.Id, id => new TypingGame(e.Channel));
// if (game.IsActive)
// {
@ -158,7 +158,7 @@
// async e =>
// {
// TypingGame game;
// if (RunningContests.TryRemove(e.User.Server.Id, out game))
// if (RunningContests.TryRemove(imsg.Author.Server.Id, out game))
// {
// await game.Stop().ConfigureAwait(false);
// return;
@ -181,7 +181,7 @@
// .Parameter("text", ParameterType.Unparsed)
// .Do(async e =>
// {
// if (!NadekoBot.IsOwner(e.User.Id) || string.IsNullOrWhiteSpace(e.GetArg("text"))) return;
// if (!NadekoBot.IsOwner(imsg.Author.Id) || string.IsNullOrWhiteSpace(e.GetArg("text"))) return;
// DbHandler.Instance.Connection.Insert(new TypingArticle
// {

View File

@ -258,7 +258,7 @@
// config.ObservingStreams.Remove(toRemove);
// await ConfigHandler.SaveConfig().ConfigureAwait(false);
// await channel.SendMessageAsync($":ok: Removed `{toRemove.Username}`'s stream from notifications.").ConfigureAwait(false);
// await channel.SendMessageAsync($":ok: Removed `{toRemovimsg.Authorname}`'s stream from notifications.").ConfigureAwait(false);
// });
// cgb.CreateCommand(Module.Prefix + "liststreams")

View File

@ -75,7 +75,7 @@
// .Parameter("board_id", Discord.Commands.ParameterType.Required)
// .Do(async e =>
// {
// if (!NadekoBot.IsOwner(e.User.Id)) return;
// if (!NadekoBot.IsOwner(imsg.Author.Id)) return;
// if (bound != null) return;
// try
// {
@ -95,7 +95,7 @@
// .Description($"Unbinds a bot from the channel and board. **Bot Owner Only!**| `{Prefix}unbind`")
// .Do(async e =>
// {
// if (!NadekoBot.IsOwner(e.User.Id)) return;
// if (!NadekoBot.IsOwner(imsg.Author.Id)) return;
// if (bound == null || bound != e.Channel) return;
// t.Stop();
// bound = null;
@ -109,7 +109,7 @@
// .Description($"Lists all lists, yo ;) **Bot Owner Only!**| `{Prefix}list`")
// .Do(async e =>
// {
// if (!NadekoBot.IsOwner(e.User.Id)) return;
// if (!NadekoBot.IsOwner(imsg.Author.Id)) return;
// if (bound == null || board == null || bound != e.Channel) return;
// await channel.SendMessageAsync("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")))
// .ConfigureAwait(false);
@ -120,7 +120,7 @@
// .Parameter("list_name", Discord.Commands.ParameterType.Unparsed)
// .Do(async e =>
// {
// if (!NadekoBot.IsOwner(e.User.Id)) return;
// if (!NadekoBot.IsOwner(imsg.Author.Id)) return;
// if (bound == null || board == null || bound != e.Channel || e.GetArg("list_name") == null) return;
// int num;

View File

@ -100,7 +100,7 @@
// if (meorchStr == "ME")
// {
// isPrivate = true;
// ch = await e.User.CreatePMChannel().ConfigureAwait(false);
// ch = await imsg.Author.CreatePMChannel().ConfigureAwait(false);
// }
// else if (meorchStr == "HERE")
// {
@ -113,7 +113,7 @@
// if (ch == null)
// {
// await channel.SendMessageAsync($"{e.User.Mention} Something went wrong (channel cannot be found) ;(").ConfigureAwait(false);
// await channel.SendMessageAsync($"{imsg.Author.Mention} Something went wrong (channel cannot be found) ;(").ConfigureAwait(false);
// return;
// }
@ -168,7 +168,7 @@
// IsPrivate = isPrivate,
// When = time,
// Message = e.GetArg("message"),
// UserId = (long)e.User.Id,
// UserId = (long)imsg.Author.Id,
// ServerId = (long)e.Server.Id
// };
// DbHandler.Instance.Connection.Insert(rem);

View File

@ -31,7 +31,7 @@ namespace NadekoBot.Modules.CustomReactions
}else return rng.Next().ToString();
} },
{new Regex("%mention%"), (e,m) => NadekoBot.BotMention },
{new Regex("%user%"), (e,m) => e.User.Mention },
{new Regex("%user%"), (e,m) => imsg.Author.Mention },
{new Regex("%target%"), (e,m) => e.GetArg("args")?.Trim() ?? "" },
};

View File

@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Music
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
if (musicPlayer.PlaybackVoiceChannel == e.User.VoiceChannel)
if (musicPlayer.PlaybackVoiceChannel == imsg.Author.VoiceChannel)
musicPlayer.Next();
});
@ -62,7 +62,7 @@ namespace NadekoBot.Modules.Music
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
if (e.User.VoiceChannel == musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel == musicPlayer.PlaybackVoiceChannel)
{
musicPlayer.Autoplay = false;
musicPlayer.Stop();
@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Music
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryRemove(e.Server, out musicPlayer)) return;
if (e.User.VoiceChannel == musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel == musicPlayer.PlaybackVoiceChannel)
musicPlayer.Destroy();
});
@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Music
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.TogglePause();
if (musicPlayer.Paused)
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Music
.Parameter("query", ParameterType.Unparsed)
.Do(async e =>
{
await QueueSong(e.User, e.Channel, e.User.VoiceChannel, e.GetArg("query")).ConfigureAwait(false);
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("query")).ConfigureAwait(false);
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
{
await Task.Delay(10000).ConfigureAwait(false);
@ -120,7 +120,7 @@ namespace NadekoBot.Modules.Music
.Parameter("query", ParameterType.Unparsed)
.Do(async e =>
{
await QueueSong(e.User, e.Channel, e.User.VoiceChannel, e.GetArg("query"), musicType: MusicType.Soundcloud).ConfigureAwait(false);
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("query"), musicType: MusicType.Soundcloud).ConfigureAwait(false);
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
{
await Task.Delay(10000).ConfigureAwait(false);
@ -190,7 +190,7 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
var arg = e.GetArg("val");
int volume;
@ -230,7 +230,7 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.SetVolume(0);
});
@ -242,7 +242,7 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.SetVolume(100);
});
@ -254,7 +254,7 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.SetVolume(50);
});
@ -267,7 +267,7 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
if (musicPlayer.Playlist.Count < 2)
{
@ -288,7 +288,7 @@ namespace NadekoBot.Modules.Music
var arg = e.GetArg("playlist");
if (string.IsNullOrWhiteSpace(arg))
return;
if (e.User.VoiceChannel?.Server != e.Server)
if (imsg.Author.VoiceChannel?.Server != e.Server)
{
await channel.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false);
return;
@ -313,7 +313,7 @@ namespace NadekoBot.Modules.Music
{
try
{
await QueueSong(e.User, e.Channel, e.User.VoiceChannel, id, true).ConfigureAwait(false);
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, id, true).ConfigureAwait(false);
}
catch (PlaylistFullException)
{ break; }
@ -334,7 +334,7 @@ namespace NadekoBot.Modules.Music
return;
var scvids = JObject.Parse(await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={pl}&client_id={NadekoBot.Creds.SoundCloudClientID}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
await QueueSong(e.User, e.Channel, e.User.VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false);
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false);
MusicPlayer mp;
if (!MusicPlayers.TryGetValue(e.Server, out mp))
@ -351,7 +351,7 @@ namespace NadekoBot.Modules.Music
Uri = svideo.StreamLink,
ProviderType = MusicType.Normal,
Query = svideo.TrackLink,
}), e.User.Name);
}), imsg.Author.Username);
}
catch (PlaylistFullException) { break; }
}
@ -375,7 +375,7 @@ namespace NadekoBot.Modules.Music
{
try
{
await QueueSong(e.User, e.Channel, e.User.VoiceChannel, file.FullName, true, MusicType.Local).ConfigureAwait(false);
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, file.FullName, true, MusicType.Local).ConfigureAwait(false);
}
catch (PlaylistFullException)
{
@ -393,12 +393,12 @@ namespace NadekoBot.Modules.Music
.Parameter("radio_link", ParameterType.Required)
.Do(async e =>
{
if (e.User.VoiceChannel?.Server != e.Server)
if (imsg.Author.VoiceChannel?.Server != e.Server)
{
await channel.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false);
return;
}
await QueueSong(e.User, e.Channel, e.User.VoiceChannel, e.GetArg("radio_link"), musicType: MusicType.Radio).ConfigureAwait(false);
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("radio_link"), musicType: MusicType.Radio).ConfigureAwait(false);
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
{
await Task.Delay(10000).ConfigureAwait(false);
@ -416,7 +416,7 @@ namespace NadekoBot.Modules.Music
var arg = e.GetArg("path");
if (string.IsNullOrWhiteSpace(arg))
return;
await QueueSong(e.User, e.Channel, e.User.VoiceChannel, e.GetArg("path"), musicType: MusicType.Local).ConfigureAwait(false);
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("path"), musicType: MusicType.Local).ConfigureAwait(false);
});
cgb.CreateCommand(Prefix + "move")
@ -425,7 +425,7 @@ namespace NadekoBot.Modules.Music
.Do(e =>
{
MusicPlayer musicPlayer;
var voiceChannel = e.User.VoiceChannel;
var voiceChannel = imsg.Author.VoiceChannel;
if (voiceChannel == null || voiceChannel.Server != e.Server || !MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
musicPlayer.MoveToVoiceChannel(voiceChannel);
@ -443,7 +443,7 @@ namespace NadekoBot.Modules.Music
{
return;
}
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
if (arg?.ToLower() == "all")
{
@ -608,8 +608,8 @@ namespace NadekoBot.Modules.Music
var playlist = new MusicPlaylist
{
CreatorId = (long)e.User.Id,
CreatorName = e.User.Name,
CreatorId = (long)imsg.Author.Id,
CreatorName = imsg.Author.Username,
Name = name.ToLowerInvariant(),
};
DbHandler.Instance.SaveAll(songInfos);
@ -629,7 +629,7 @@ namespace NadekoBot.Modules.Music
.Parameter("name", ParameterType.Unparsed)
.Do(async e =>
{
var voiceCh = e.User.VoiceChannel;
var voiceCh = imsg.Author.VoiceChannel;
var textCh = e.Channel;
if (voiceCh == null || voiceCh.Server != textCh.Server)
{
@ -670,7 +670,7 @@ namespace NadekoBot.Modules.Music
{
try
{
await QueueSong(e.User, textCh, voiceCh, si.Query, true, (MusicType)si.ProviderType).ConfigureAwait(false);
await QueueSong(imsg.Author, textCh, voiceCh, si.Query, true, (MusicType)si.ProviderType).ConfigureAwait(false);
}
catch (PlaylistFullException)
{
@ -710,10 +710,10 @@ namespace NadekoBot.Modules.Music
if (string.IsNullOrWhiteSpace(pl))
return;
var plnum = int.Parse(pl);
if (NadekoBot.IsOwner(e.User.Id))
if (NadekoBot.IsOwner(imsg.Author.Id))
DbHandler.Instance.Delete<MusicPlaylist>(plnum);
else
DbHandler.Instance.DeleteWhere<MusicPlaylist>(mp => mp.Id == plnum && (long)e.User.Id == mp.CreatorId);
DbHandler.Instance.DeleteWhere<MusicPlaylist>(mp => mp.Id == plnum && (long)imsg.Author.Id == mp.CreatorId);
await channel.SendMessageAsync("`Ok.` :ok:").ConfigureAwait(false);
});
@ -726,7 +726,7 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
int skipTo;
if (!int.TryParse(skipToStr, out skipTo) || skipTo < 0)

View File

@ -119,10 +119,10 @@ namespace NadekoBot.Modules.Permissions.Classes
case PermissionsHandler.PermissionBanType.RoleBanModule:
msg = $"You do not have a **role** which permits you the usage of **{command.Category}** module.";
break;
case PermissionsHandler.PermissionBanType.UserBanCommand:
case PermissionsHandler.PermissionBanTypimsg.AuthorBanCommand:
msg = $"{user.Mention}, You have been banned from using **{command.Text}** command.";
break;
case PermissionsHandler.PermissionBanType.UserBanModule:
case PermissionsHandler.PermissionBanTypimsg.AuthorBanModule:
msg = $"{user.Mention}, You have been banned from using **{command.Category}** module.";
break;
default:

View File

@ -142,10 +142,10 @@ namespace NadekoBot.Modules.Permissions.Classes
//user
if (serverPerms.UserPermissions.TryGetValue(user.Id, out perm) &&
perm.Modules.TryGetValue(command.Category, out val) && val == false)
return PermissionBanType.UserBanModule;
return PermissionBanTypimsg.AuthorBanModule;
if (serverPerms.UserPermissions.TryGetValue(user.Id, out perm) &&
perm.Commands.TryGetValue(command.Text, out val) && val == false)
return PermissionBanType.UserBanCommand;
return PermissionBanTypimsg.AuthorBanCommand;
return PermissionBanType.None;
}

View File

@ -224,7 +224,7 @@ namespace NadekoBot.Modules.Permissions
.Parameter("user", ParameterType.Unparsed)
.Do(async e =>
{
var user = e.User;
var user = imsg.Author;
if (!string.IsNullOrWhiteSpace(e.GetArg("user")))
try
{