A lot more work on converting
This commit is contained in:
parent
d6477b9d90
commit
846e7120b4
@ -1,4 +0,0 @@
|
|||||||
#:C:\Users\Kwoth\Source\Repos\NadekoBot1.0\src\NadekoBot\NadekoBot.xproj
|
|
||||||
C:\Users\Kwoth\Source\Repos\NadekoBot1.0\src\NadekoBot\NadekoBot.xproj|C:\Users\Kwoth\Source\Repos\NadekoBot1.0\discord.net\src\Discord.Net\Discord.Net.xproj
|
|
||||||
C:\Users\Kwoth\Source\Repos\NadekoBot1.0\src\NadekoBot\NadekoBot.xproj|C:\Users\Kwoth\Source\Repos\NadekoBot1.0\discord.net\src\Discord.Net.Commands\Discord.Net.Commands.xproj
|
|
||||||
C:\Users\Kwoth\Source\Repos\NadekoBot1.0\discord.net\src\Discord.Net.Commands\Discord.Net.Commands.xproj|C:\Users\Kwoth\Source\Repos\NadekoBot1.0\discord.net\src\Discord.Net\Discord.Net.xproj
|
|
@ -1 +1 @@
|
|||||||
Subproject commit cf911456a751f4778fe4789973e028560624cfe8
|
Subproject commit a76956c8ef516b3d5399fedc30b321043c86f112
|
@ -1,11 +1,6 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.Modules;
|
|
||||||
using NadekoBot.Classes;
|
|
||||||
using NadekoBot.DataModels;
|
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Administration.Commands;
|
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -14,6 +9,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Attributes;
|
using NadekoBot.Attributes;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
//todo fix delmsgoncmd
|
//todo fix delmsgoncmd
|
||||||
//todo DB
|
//todo DB
|
||||||
@ -26,12 +22,12 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo owner only
|
////todo owner only
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Restart(IMessage imsg)
|
//public async Task Restart(IMessage imsg)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// await imsg.Channel.SendMessageAsync("`Restarting in 2 seconds...`");
|
// await imsg.Channel.SendMessageAsync("`Restarting in 2 seconds...`");
|
||||||
// await Task.Delay(2000);
|
// await Task.Delay(2000);
|
||||||
@ -39,12 +35,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
// Environment.Exit(0);
|
// Environment.Exit(0);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
////todo DB
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//[RequirePermission(GuildPermission.ManageGuild)]
|
//[RequirePermission(GuildPermission.ManageGuild)]
|
||||||
//public async Task Delmsgoncmd(IMessage imsg)
|
//public async Task Delmsgoncmd(IMessage imsg)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// var conf = SpecificConfigurations.Default.Of(channel.Guild.Id);
|
// var conf = SpecificConfigurations.Default.Of(channel.Guild.Id);
|
||||||
// conf.AutoDeleteMessagesOnCommand = !conf.AutoDeleteMessagesOnCommand;
|
// conf.AutoDeleteMessagesOnCommand = !conf.AutoDeleteMessagesOnCommand;
|
||||||
@ -58,30 +55,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageRoles)]
|
[RequirePermission(GuildPermission.ManageRoles)]
|
||||||
public async Task Setrole(IMessage imsg, IUser userName, [Remainder] string roleName)
|
public async Task Setrole(IMessage imsg, IGuildUser usr, [Remainder] IRole role)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(roleName)) return;
|
|
||||||
|
|
||||||
var usr = channel.Guild.FindUsers(userName).FirstOrDefault();
|
|
||||||
if (usr == null)
|
|
||||||
{
|
|
||||||
await imsg.Channel.SendMessageAsync("You failed to supply a valid username").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var role = channel.Guild.FindRoles(roleName).FirstOrDefault();
|
|
||||||
if (role == null)
|
|
||||||
{
|
|
||||||
await imsg.Channel.SendMessageAsync("You failed to supply a valid role").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.AddRoles(role).ConfigureAwait(false);
|
await usr.AddRolesAsync(role).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Successfully added role **{role.Name}** to user **{usr.Name}**").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"Successfully added role **{role.Name}** to user **{usr.Username}**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -93,30 +73,12 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageRoles)]
|
[RequirePermission(GuildPermission.ManageRoles)]
|
||||||
public async Task Removerole(IMessage imsg, IUser userName, [Remainder] string roleName)
|
public async Task Removerole(IMessage imsg, IGuildUser usr, [Remainder] IRole role)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(roleName)) return;
|
|
||||||
|
|
||||||
var usr = channel.Guild.FindUsers(userName).FirstOrDefault();
|
|
||||||
if (usr == null)
|
|
||||||
{
|
|
||||||
await imsg.Channel.SendMessageAsync("You failed to supply a valid username").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var role = channel.Guild.FindRoles(roleName).FirstOrDefault();
|
|
||||||
if (role == null)
|
|
||||||
{
|
|
||||||
await imsg.Channel.SendMessageAsync("You failed to supply a valid role").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.RemoveRoles(role).ConfigureAwait(false);
|
await usr.RemoveRolesAsync(role).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Successfully removed role **{role.Name}** from user **{usr.Name}**").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"Successfully removed role **{role.Name}** from user **{usr.Username}**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -127,25 +89,17 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageRoles)]
|
[RequirePermission(GuildPermission.ManageRoles)]
|
||||||
public async Task RenameRole(IMessage imsg, string r1, string r2)
|
public async Task RenameRole(IMessage imsg, IRole roleToEdit, string newname)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var roleToEdit = channel.Guild.FindRoles(r1).FirstOrDefault();
|
|
||||||
if (roleToEdit == null)
|
|
||||||
{
|
|
||||||
await imsg.Channel.SendMessageAsync("Can't find that role.").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (roleToEdit.Position > channel.Guild.CurrentUser.Roles.Max(r => r.Position))
|
if (roleToEdit.Position > (await channel.Guild.GetCurrentUserAsync().ConfigureAwait(false)).Roles.Max(r => r.Position))
|
||||||
{
|
{
|
||||||
await imsg.Channel.SendMessageAsync("I can't edit roles higher than my highest role.").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("You can't edit roles higher than your highest role.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await roleToEdit.Edit(r2);
|
await roleToEdit.ModifyAsync(g => g.Name = newname).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync("Role renamed.").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Role renamed.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -157,21 +111,14 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageRoles)]
|
[RequirePermission(GuildPermission.ManageRoles)]
|
||||||
public async Task RemoveAllRoles(IMessage imsg, [Remainder] string userName)
|
public async Task RemoveAllRoles(IMessage imsg, [Remainder] IGuildUser user)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var usr = channel.Guild.FindUsers(userName).FirstOrDefault();
|
|
||||||
if (usr == null)
|
|
||||||
{
|
|
||||||
await imsg.Channel.SendMessageAsync("You failed to supply a valid username").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.RemoveRoles(usr.Roles.ToArray()).ConfigureAwait(false);
|
await user.RemoveRolesAsync(user.Roles).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Successfully removed **all** roles from user **{usr.Name}**").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"Successfully removed **all** roles from user **{user.Username}**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -182,16 +129,16 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageRoles)]
|
[RequirePermission(GuildPermission.ManageRoles)]
|
||||||
public async Task CreateRole(IMessage imsg, [Remainder] string roleName)
|
public async Task CreateRole(IMessage imsg, [Remainder] string roleName = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("role_name")))
|
if (string.IsNullOrWhiteSpace(roleName))
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var r = await channel.Guild.CreateRole(e.GetArg("role_name")).ConfigureAwait(false);
|
var r = await channel.Guild.CreateRoleAsync(roleName).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Successfully created role **{r.Name}**.").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"Successfully created role **{r.Name}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -203,19 +150,17 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageRoles)]
|
[RequirePermission(GuildPermission.ManageRoles)]
|
||||||
public async Task RoleColor(IMessage imsg, string roleName, string r="", string g="", string b="")
|
public async Task RoleColor(IMessage imsg, params string[] args)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var args = e.Args.Where(s => s != string.Empty);
|
|
||||||
|
|
||||||
if (args.Count() != 2 && args.Count() != 4)
|
if (args.Count() != 2 && args.Count() != 4)
|
||||||
{
|
{
|
||||||
await imsg.Channel.SendMessageAsync("The parameters are invalid.").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("The parameters are invalid.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var roleName = args[0].ToUpperInvariant();
|
||||||
var role = channel.Guild.FindRoles(e.Args[0]).FirstOrDefault();
|
var role = channel.Guild.Roles.Where(r=>r.Name.ToUpperInvariant() == roleName).FirstOrDefault();
|
||||||
|
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
@ -225,13 +170,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rgb = args.Count() == 4;
|
var rgb = args.Count() == 4;
|
||||||
var arg1 = e.Args[1].Replace("#", "");
|
var arg1 = args[1].Replace("#", "");
|
||||||
|
|
||||||
var red = Convert.ToByte(rgb ? int.Parse(arg1) : Convert.ToInt32(arg1.Substring(0, 2), 16));
|
var red = Convert.ToByte(rgb ? int.Parse(arg1) : Convert.ToInt32(arg1.Substring(0, 2), 16));
|
||||||
var green = Convert.ToByte(rgb ? int.Parse(e.Args[2]) : Convert.ToInt32(arg1.Substring(2, 2), 16));
|
var green = Convert.ToByte(rgb ? int.Parse(args[2]) : Convert.ToInt32(arg1.Substring(2, 2), 16));
|
||||||
var blue = Convert.ToByte(rgb ? int.Parse(e.Args[3]) : Convert.ToInt32(arg1.Substring(4, 2), 16));
|
var blue = Convert.ToByte(rgb ? int.Parse(args[3]) : Convert.ToInt32(arg1.Substring(4, 2), 16));
|
||||||
|
|
||||||
await role.Edit(color: new Color(red, green, blue)).ConfigureAwait(false);
|
await role.ModifyAsync(r => r.Color = new Color(red, green, blue).RawValue).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Role {role.Name}'s color has been changed.").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"Role {role.Name}'s color has been changed.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -243,25 +188,21 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.BanMembers)]
|
[RequirePermission(GuildPermission.BanMembers)]
|
||||||
public async Task Ban(IMessage imsg, IUser user, [Remainder] string msg)
|
public async Task Ban(IMessage imsg, IGuildUser user, [Remainder] string msg = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
if (user == null)
|
|
||||||
{
|
|
||||||
await imsg.Channel.SendMessageAsync("User not found.").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
if (!string.IsNullOrWhiteSpace(msg))
|
||||||
{
|
{
|
||||||
await user.SendMessage($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||||
$"Reason: {msg}").ConfigureAwait(false);
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await channel.Guild.Ban(user, 7).ConfigureAwait(false);
|
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync("Banned user " + user.Name + " Id: " + user.Id).ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -272,9 +213,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.BanMembers)]
|
[RequirePermission(GuildPermission.BanMembers)]
|
||||||
public async Task Softban(IMessage imsg, IUser user, [Remainder] string msg)
|
public async Task Softban(IMessage imsg, IGuildUser user, [Remainder] string msg = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
@ -283,14 +224,14 @@ namespace NadekoBot.Modules.Administration
|
|||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
if (!string.IsNullOrWhiteSpace(msg))
|
||||||
{
|
{
|
||||||
await user.SendMessage($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
|
await user.SendMessageAsync($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||||
$"Reason: {msg}").ConfigureAwait(false);
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await channel.Guild.Ban(user, 7).ConfigureAwait(false);
|
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
|
||||||
await channel.Guild.Unban(user).ConfigureAwait(false);
|
await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false);
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync("Soft-Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Soft-Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -302,26 +243,25 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Kick(IMessage imsg, IUser user, [Remainder] string msg)
|
public async Task Kick(IMessage imsg, IGuildUser user, [Remainder] string msg = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var usr = channel.Guild.FindUsers(user).FirstOrDefault();
|
if (user == null)
|
||||||
if (usr == null)
|
|
||||||
{
|
{
|
||||||
await imsg.Channel.SendMessageAsync("User not found.").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("User not found.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
if (!string.IsNullOrWhiteSpace(msg))
|
||||||
{
|
{
|
||||||
await usr.SendMessage($"**You have been KICKED from `{channel.Guild.Name}` server.**\n" +
|
await user.SendMessageAsync($"**You have been KICKED from `{channel.Guild.Name}` server.**\n" +
|
||||||
$"Reason: {msg}").ConfigureAwait(false);
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.Kick().ConfigureAwait(false);
|
await user.KickAsync().ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync("Kicked user " + usr.Name + " Id: " + usr.Id).ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Kicked user " + user.Username + " Id: " + user.Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -332,17 +272,17 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.MuteMembers)]
|
[RequirePermission(GuildPermission.MuteMembers)]
|
||||||
public async Task Mute(IMessage imsg, [Remainder] string throwaway)
|
public async Task Mute(IMessage imsg, params IGuildUser[] users)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!users.Any())
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in users)
|
||||||
{
|
{
|
||||||
await u.Edit(isMuted: true).ConfigureAwait(false);
|
await u.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await imsg.Channel.SendMessageAsync("Mute successful").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Mute successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -354,17 +294,18 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Unmute(IMessage imsg, [Remainder] string throwaway)
|
[RequirePermission(GuildPermission.MuteMembers)]
|
||||||
|
public async Task Unmute(IMessage imsg, params IGuildUser[] users)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!users.Any())
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in users)
|
||||||
{
|
{
|
||||||
await u.Edit(isMuted: false).ConfigureAwait(false);
|
await u.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await imsg.Channel.SendMessageAsync("Unmute successful").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Unmute successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -377,17 +318,17 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.DeafenMembers)]
|
[RequirePermission(GuildPermission.DeafenMembers)]
|
||||||
public async Task Deafen(IMessage imsg, [Remainder] string throwaway)
|
public async Task Deafen(IMessage imsg, params IGuildUser[] users)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!users.Any())
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in users)
|
||||||
{
|
{
|
||||||
await u.Edit(isDeafened: true).ConfigureAwait(false);
|
await u.ModifyAsync(usr=>usr.Deaf = true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await imsg.Channel.SendMessageAsync("Deafen successful").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Deafen successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -400,17 +341,17 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.DeafenMembers)]
|
[RequirePermission(GuildPermission.DeafenMembers)]
|
||||||
public async Task UnDeafen(IMessage imsg, [Remainder] string throwaway)
|
public async Task UnDeafen(IMessage imsg, params IGuildUser[] users)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!users.Any())
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in users)
|
||||||
{
|
{
|
||||||
await u.Edit(isDeafened: false).ConfigureAwait(false);
|
await u.ModifyAsync(usr=> usr.Deaf = false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await imsg.Channel.SendMessageAsync("Undeafen successful").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("Undeafen successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -422,69 +363,64 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task DelVoiChanl(IMessage imsg, [Remainder] channelName)
|
[RequirePermission(GuildPermission.ManageChannels)]
|
||||||
|
public async Task DelVoiChanl(IMessage imsg, [Remainder] IVoiceChannel channel)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
await channel.DeleteAsync().ConfigureAwait(false);
|
||||||
var ch = channel.Guild.FindChannels(channelName, ChannelType.Voice).FirstOrDefault();
|
await imsg.Channel.SendMessageAsync($"Removed channel **{channel.Name}**.").ConfigureAwait(false);
|
||||||
if (ch == null)
|
|
||||||
return;
|
|
||||||
await ch.Delete().ConfigureAwait(false);
|
|
||||||
await imsg.Channel.SendMessageAsync($"Removed channel **{channelName}**.").ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[RequirePermission(GuildPermission.ManageChannels)]
|
||||||
public async Task CreatVoiChanl(IMessage imsg, [Remainder] string channelName)
|
public async Task CreatVoiChanl(IMessage imsg, [Remainder] string channelName)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
//todo actually print info about created channel
|
||||||
await channel.Guild.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice).ConfigureAwait(false);
|
await channel.Guild.CreateVoiceChannelAsync(channelName).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Created voice channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"Created voice channel **{channelName}**.").ConfigureAwait(false);
|
||||||
}
|
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
public async Task DelTxtChanl(IMessage imsg, [Remainder] string channelName)
|
|
||||||
{
|
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
|
||||||
|
|
||||||
var channel = channel.Guild.FindChannels(e.GetArg("channel_name"), ChannelType.Text).FirstOrDefault();
|
|
||||||
if (channel == null) return;
|
|
||||||
await channel.Delete().ConfigureAwait(false);
|
|
||||||
await imsg.Channel.SendMessageAsync($"Removed text channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageChannels)]
|
[RequirePermission(GuildPermission.ManageChannels)]
|
||||||
public async Task CreaTxtChanl(IMessage imsg, [Remainder] string arg)
|
public async Task DelTxtChanl(IMessage imsg, [Remainder] ITextChannel channel)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
await channel.DeleteAsync().ConfigureAwait(false);
|
||||||
await channel.Guild.CreateChannel(e.GetArg("channel_name"), ChannelType.Text).ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"Removed text channel **{channel.Name}**.").ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Added text channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageChannels)]
|
[RequirePermission(GuildPermission.ManageChannels)]
|
||||||
public async Task SetTopic(IMessage imsg, [Remainder] string arg)
|
public async Task CreaTxtChanl(IMessage imsg, [Remainder] string channelName)
|
||||||
{
|
{
|
||||||
var topic = e.GetArg("topic")?.Trim() ?? "";
|
var channel = imsg.Channel as ITextChannel;
|
||||||
await e.Channel.Edit(topic: topic).ConfigureAwait(false);
|
//todo actually print info about created channel
|
||||||
|
var txtCh = await channel.Guild.CreateTextChannelAsync(channelName).ConfigureAwait(false);
|
||||||
|
await imsg.Channel.SendMessageAsync($"Added text channel **{channelName}**.").ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[RequirePermission(GuildPermission.ManageChannels)]
|
||||||
|
public async Task SetTopic(IMessage imsg, [Remainder] string topic = null)
|
||||||
|
{
|
||||||
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
topic = topic ?? "";
|
||||||
|
await (channel as ITextChannel).ModifyAsync(c => c.Topic = topic);
|
||||||
|
//await (channel).ModifyAsync(c => c).ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync(":ok: **New channel topic set.**").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync(":ok: **New channel topic set.**").ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.ManageChannels)]
|
[RequirePermission(GuildPermission.ManageChannels)]
|
||||||
public async Task SetChanlName(IMessage imsg, [Remainder] string arg)
|
public async Task SetChanlName(IMessage imsg, [Remainder] string name)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var name = e.GetArg("name");
|
await channel.ModifyAsync(c => c.Name = name).ConfigureAwait(false);
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
|
||||||
return;
|
|
||||||
await e.Channel.Edit(name: name).ConfigureAwait(false);
|
|
||||||
await imsg.Channel.SendMessageAsync(":ok: **New channel name set.**").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync(":ok: **New channel name set.**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +430,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Prune(IMessage msg, [Remainder] string target = null)
|
public async Task Prune(IMessage msg, [Remainder] string target = null)
|
||||||
{
|
{
|
||||||
var channel = msg.Channel as IGuildChannel;
|
var channel = msg.Channel as ITextChannel;
|
||||||
|
|
||||||
var user = await channel.Guild.GetCurrentUserAsync();
|
var user = await channel.Guild.GetCurrentUserAsync();
|
||||||
if (string.IsNullOrWhiteSpace(target))
|
if (string.IsNullOrWhiteSpace(target))
|
||||||
@ -561,7 +497,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Die(IMessage imsg)
|
//public async Task Die(IMessage imsg)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// await imsg.Channel.SendMessageAsync("`Shutting down.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Shutting down.`").ConfigureAwait(false);
|
||||||
// await Task.Delay(2000).ConfigureAwait(false);
|
// await Task.Delay(2000).ConfigureAwait(false);
|
||||||
@ -571,18 +507,18 @@ namespace NadekoBot.Modules.Administration
|
|||||||
////todo owner only
|
////todo owner only
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Setname(IMessage imsg, [Remainder] string newName)
|
//public async Task Setname(IMessage imsg, [Remainder] string newName = null)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
////todo owner only
|
////todo owner only
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task NewAvatar(IMessage imsg, [Remainder] string img)
|
//public async Task NewAvatar(IMessage imsg, [Remainder] string img = null)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// if (string.IsNullOrWhiteSpace(e.GetArg("img")))
|
// if (string.IsNullOrWhiteSpace(e.GetArg("img")))
|
||||||
// return;
|
// return;
|
||||||
@ -599,9 +535,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
////todo owner only
|
////todo owner only
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task SetGame(IMessage imsg, [Remainder] string game)
|
//public async Task SetGame(IMessage imsg, [Remainder] string game = null)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// game = game ?? "";
|
// game = game ?? "";
|
||||||
|
|
||||||
@ -611,9 +547,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
////todo owner only
|
////todo owner only
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Send(IMessage imsg, string where, [Remainder] string msg)
|
//public async Task Send(IMessage imsg, string where, [Remainder] string msg = null)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// if (string.IsNullOrWhiteSpace(msg))
|
// if (string.IsNullOrWhiteSpace(msg))
|
||||||
// return;
|
// return;
|
||||||
@ -659,7 +595,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Donadd(IMessage imsg, IUser donator, int amount)
|
//public async Task Donadd(IMessage imsg, IUser donator, int amount)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
// var donator = channel.Guild.FindUsers(e.GetArg("donator")).FirstOrDefault();
|
// var donator = channel.Guild.FindUsers(e.GetArg("donator")).FirstOrDefault();
|
||||||
// var amount = int.Parse(e.GetArg("amount"));
|
// var amount = int.Parse(e.GetArg("amount"));
|
||||||
// if (donator == null) return;
|
// if (donator == null) return;
|
||||||
@ -677,75 +613,77 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//todo owner only
|
////todo owner only
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
public async Task Announce(IMessage imsg, [Remainder] string message)
|
//public async Task Announce(IMessage imsg, [Remainder] string message)
|
||||||
{
|
//{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
|
// foreach (var ch in (await _client.GetGuildsAsync().ConfigureAwait(false)).Select(async g => await g.GetDefaultChannelAsync().ConfigureAwait(false)))
|
||||||
|
// {
|
||||||
|
// await imsg.Channel.SendMessageAsync(message).ConfigureAwait(false);
|
||||||
|
// }
|
||||||
|
|
||||||
foreach (var ch in NadekoBot.Client.Servers.Select(s => s.DefaultChannel))
|
// await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
||||||
{
|
//}
|
||||||
await ch.SendMessage(e.GetArg("msg")).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
////todo owner only
|
||||||
}
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
|
//[RequireContext(ContextType.Guild)]
|
||||||
|
//public async Task SaveChat(IMessage imsg, int cnt)
|
||||||
|
//{
|
||||||
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
//todo owner only
|
// ulong? lastmsgId = null;
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
// var sb = new StringBuilder();
|
||||||
[RequireContext(ContextType.Guild)]
|
// var msgs = new List<IMessage>(cnt);
|
||||||
public async Task SaveChat(IMessage imsg, int cnt)
|
// while (cnt > 0)
|
||||||
{
|
// {
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
// var dlcnt = cnt < 100 ? cnt : 100;
|
||||||
|
// IReadOnlyCollection<IMessage> dledMsgs;
|
||||||
|
// if (lastmsgId == null)
|
||||||
|
// dledMsgs = await imsg.Channel.GetMessagesAsync(cnt).ConfigureAwait(false);
|
||||||
|
// else
|
||||||
|
// dledMsgs = await imsg.Channel.GetMessagesAsync(lastmsgId.Value, Direction.Before, dlcnt);
|
||||||
|
|
||||||
ulong? lastmsgId = null;
|
// if (!dledMsgs.Any())
|
||||||
var sb = new StringBuilder();
|
// break;
|
||||||
var msgs = new List<IMessage>(cnt);
|
|
||||||
while (cnt > 0)
|
|
||||||
{
|
|
||||||
var dlcnt = cnt < 100 ? cnt : 100;
|
|
||||||
|
|
||||||
var dledMsgs = await e.Channel.DownloadMessages(dlcnt, lastmsgId);
|
// msgs.AddRange(dledMsgs);
|
||||||
if (!dledMsgs.Any())
|
// lastmsgId = msgs[msgs.Count - 1].Id;
|
||||||
break;
|
// cnt -= 100;
|
||||||
msgs.AddRange(dledMsgs);
|
// }
|
||||||
lastmsgId = msgs[msgs.Count - 1].Id;
|
// var title = $"Chatlog-{channel.Guild.Name}/#{channel.Name}-{DateTime.Now}.txt";
|
||||||
cnt -= 100;
|
// await (imsg.Author as IGuildUser).SendFileAsync(
|
||||||
}
|
// await JsonConvert.SerializeObject(new { Messages = msgs.Select(s => s.ToString()) }, Formatting.Indented).ToStream().ConfigureAwait(false),
|
||||||
await e.User.SendFile($"Chatlog-{channel.Guild.Name}/#{e.Channel.Name}-{DateTime.Now}.txt",
|
// title, title).ConfigureAwait(false);
|
||||||
JsonConvert.SerializeObject(new { Messages = msgs.Select(s => s.ToString()) }, Formatting.Indented).ToStream()).ConfigureAwait(false);
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.MentionEveryone)]
|
[RequirePermission(GuildPermission.MentionEveryone)]
|
||||||
public async Task MentionRole(IMessage imsg, [Remainder] string roles)
|
public async Task MentionRole(IMessage imsg, params IRole[] roles)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var arg = e.GetArg("roles").Split(',').Select(r => r.Trim());
|
string send = $"--{imsg.Author.Mention} has invoked a mention on the following roles--";
|
||||||
string send = $"--{e.User.Mention} has invoked a mention on the following roles--";
|
foreach (var role in roles)
|
||||||
foreach (var roleStr in arg.Where(str => !string.IsNullOrWhiteSpace(str)))
|
|
||||||
{
|
{
|
||||||
var role = channel.Guild.FindRoles(roleStr).FirstOrDefault();
|
|
||||||
if (role == null) continue;
|
|
||||||
send += $"\n`{role.Name}`\n";
|
send += $"\n`{role.Name}`\n";
|
||||||
send += string.Join(", ", role.Members.Select(r => r.Mention));
|
send += string.Join(", ", (await channel.Guild.GetUsersAsync()).Where(u => u.Roles.Contains(role)).Distinct());
|
||||||
}
|
}
|
||||||
|
|
||||||
while (send.Length > 2000)
|
while (send.Length > 2000)
|
||||||
{
|
{
|
||||||
var curstr = send.Substring(0, 2000);
|
var curstr = send.Substring(0, 2000);
|
||||||
await
|
await channel.SendMessageAsync(curstr.Substring(0,
|
||||||
e.Channel.Send(curstr.Substring(0,
|
|
||||||
curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1)).ConfigureAwait(false);
|
curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1)).ConfigureAwait(false);
|
||||||
send = curstr.Substring(curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1) +
|
send = curstr.Substring(curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1) +
|
||||||
send.Substring(2000);
|
send.Substring(2000);
|
||||||
}
|
}
|
||||||
await e.Channel.Send(send).ConfigureAwait(false);
|
await channel.SendMessageAsync(send).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo DB
|
//todo DB
|
||||||
@ -753,7 +691,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Donators(IMessage imsg)
|
//public async Task Donators(IMessage imsg)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// var rows = DbHandler.Instance.GetAllRows<Donator>();
|
// var rows = DbHandler.Instance.GetAllRows<Donator>();
|
||||||
// var donatorsOrdered = rows.OrderByDescending(d => d.Amount);
|
// var donatorsOrdered = rows.OrderByDescending(d => d.Amount);
|
||||||
|
@ -1,72 +1,72 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
class AutoAssignRole : DiscordCommand
|
// class AutoAssignRole : DiscordCommand
|
||||||
{
|
// {
|
||||||
public AutoAssignRole(DiscordModule module) : base(module)
|
// public AutoAssignRole(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
NadekoBot.Client.UserJoined += (s, e) =>
|
// NadekoBot.Client.UserJoined += (s, e) =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
|
|
||||||
var role = e.Server.Roles.Where(r => r.Id == config.AutoAssignedRole).FirstOrDefault();
|
// var role = e.Server.Roles.Where(r => r.Id == config.AutoAssignedRole).FirstOrDefault();
|
||||||
|
|
||||||
if (role == null)
|
// if (role == null)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
e.User.AddRoles(role);
|
// e.User.AddRoles(role);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
Console.WriteLine($"aar exception. {ex}");
|
// Console.WriteLine($"aar exception. {ex}");
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "autoassignrole")
|
// cgb.CreateCommand(Module.Prefix + "autoassignrole")
|
||||||
.Alias(Module.Prefix + "aar")
|
// .Alias(Module.Prefix + "aar")
|
||||||
.Description($"Automaticaly assigns a specified role to every user who joins the server. **Needs Manage Roles Permissions.** |`{Prefix}aar` to disable, `{Prefix}aar Role Name` to enable")
|
// .Description($"Automaticaly assigns a specified role to every user who joins the server. **Needs Manage Roles Permissions.** |`{Prefix}aar` to disable, `{Prefix}aar Role Name` to enable")
|
||||||
.Parameter("role", ParameterType.Unparsed)
|
// .Parameter("role", ParameterType.Unparsed)
|
||||||
.AddCheck(new SimpleCheckers.ManageRoles())
|
// .AddCheck(new SimpleCheckers.ManageRoles())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.Server.CurrentUser.ServerPermissions.ManageRoles)
|
// if (!e.Server.CurrentUser.ServerPermissions.ManageRoles)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("I do not have the permission to manage roles.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("I do not have the permission to manage roles.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var r = e.GetArg("role")?.Trim();
|
// var r = e.GetArg("role")?.Trim();
|
||||||
|
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(r)) //if role is not specified, disable
|
// if (string.IsNullOrWhiteSpace(r)) //if role is not specified, disable
|
||||||
{
|
// {
|
||||||
config.AutoAssignedRole = 0;
|
// config.AutoAssignedRole = 0;
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync("`Auto assign role on user join is now disabled.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Auto assign role on user join is now disabled.`").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var role = e.Server.FindRoles(r).FirstOrDefault();
|
// var role = e.Server.FindRoles(r).FirstOrDefault();
|
||||||
|
|
||||||
if (role == null)
|
// if (role == null)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("💢 `Role not found.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("💢 `Role not found.`").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
config.AutoAssignedRole = role.Id;
|
// config.AutoAssignedRole = role.Id;
|
||||||
await imsg.Channel.SendMessageAsync("`Auto assigned role is set.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Auto assigned role is set.`").ConfigureAwait(false);
|
||||||
|
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,110 +1,110 @@
|
|||||||
using Discord;
|
//using Discord;
|
||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
class CrossServerTextChannel : DiscordCommand
|
// class CrossServerTextChannel : DiscordCommand
|
||||||
{
|
// {
|
||||||
public CrossServerTextChannel(DiscordModule module) : base(module)
|
// public CrossServerTextChannel(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
NadekoBot.Client.MessageReceived += async (s, e) =>
|
// NadekoBot.Client.MessageReceived += async (s, e) =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
// if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||||
foreach (var subscriber in Subscribers)
|
// foreach (var subscriber in Subscribers)
|
||||||
{
|
// {
|
||||||
var set = subscriber.Value;
|
// var set = subscriber.Value;
|
||||||
if (!set.Contains(e.Channel))
|
// if (!set.Contains(e.Channel))
|
||||||
continue;
|
// continue;
|
||||||
foreach (var chan in set.Except(new[] { e.Channel }))
|
// 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, e.User, e.Message)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
};
|
// };
|
||||||
NadekoBot.Client.MessageUpdated += async (s, e) =>
|
// NadekoBot.Client.MessageUpdated += async (s, e) =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (e.After?.User?.Id == null || e.After.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
// if (e.After?.User?.Id == null || e.After.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||||
foreach (var subscriber in Subscribers)
|
// foreach (var subscriber in Subscribers)
|
||||||
{
|
// {
|
||||||
var set = subscriber.Value;
|
// var set = subscriber.Value;
|
||||||
if (!set.Contains(e.Channel))
|
// if (!set.Contains(e.Channel))
|
||||||
continue;
|
// continue;
|
||||||
foreach (var chan in set.Except(new[] { e.Channel }))
|
// foreach (var chan in set.Except(new[] { e.Channel }))
|
||||||
{
|
// {
|
||||||
var msg = chan.Messages
|
// var msg = chan.Messages
|
||||||
.FirstOrDefault(m =>
|
// .FirstOrDefault(m =>
|
||||||
m.RawText == GetText(e.Server, e.Channel, e.User, e.Before));
|
// m.RawText == GetText(e.Server, e.Channel, e.User, e.Before));
|
||||||
if (msg != default(Message))
|
// 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, e.User, e.After)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
private string GetText(Server server, Channel channel, User user, Message message) =>
|
// private string GetText(Server server, Channel channel, User user, Message message) =>
|
||||||
$"**{server.Name} | {channel.Name}** `{user.Name}`: " + message.RawText;
|
// $"**{server.Name} | {channel.Name}** `{user.Name}`: " + message.RawText;
|
||||||
|
|
||||||
public static readonly ConcurrentDictionary<int, HashSet<Channel>> Subscribers = new ConcurrentDictionary<int, HashSet<Channel>>();
|
// public static readonly ConcurrentDictionary<int, HashSet<Channel>> Subscribers = new ConcurrentDictionary<int, HashSet<Channel>>();
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "scsc")
|
// cgb.CreateCommand(Module.Prefix + "scsc")
|
||||||
.Description("Starts an instance of cross server channel. You will get a token as a DM " +
|
// .Description("Starts an instance of cross server channel. You will get a token as a DM " +
|
||||||
$"that other people will use to tune in to the same instance. **Bot Owner Only.** | `{Prefix}scsc`")
|
// $"that other people will use to tune in to the same instance. **Bot Owner Only.** | `{Prefix}scsc`")
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var token = new Random().Next();
|
// var token = new Random().Next();
|
||||||
var set = new HashSet<Channel>();
|
// var set = new HashSet<Channel>();
|
||||||
if (Subscribers.TryAdd(token, set))
|
// if (Subscribers.TryAdd(token, set))
|
||||||
{
|
// {
|
||||||
set.Add(e.Channel);
|
// set.Add(e.Channel);
|
||||||
await e.User.SendMessage("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
|
// await e.User.SendMessage("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "jcsc")
|
// cgb.CreateCommand(Module.Prefix + "jcsc")
|
||||||
.Description($"Joins current channel to an instance of cross server channel using the token. **Needs Manage Server Permissions.**| `{Prefix}jcsc`")
|
// .Description($"Joins current channel to an instance of cross server channel using the token. **Needs Manage Server Permissions.**| `{Prefix}jcsc`")
|
||||||
.Parameter("token")
|
// .Parameter("token")
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
int token;
|
// int token;
|
||||||
if (!int.TryParse(e.GetArg("token"), out token))
|
// if (!int.TryParse(e.GetArg("token"), out token))
|
||||||
return;
|
// return;
|
||||||
HashSet<Channel> set;
|
// HashSet<Channel> set;
|
||||||
if (!Subscribers.TryGetValue(token, out set))
|
// if (!Subscribers.TryGetValue(token, out set))
|
||||||
return;
|
// return;
|
||||||
set.Add(e.Channel);
|
// set.Add(e.Channel);
|
||||||
await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "lcsc")
|
// cgb.CreateCommand(Module.Prefix + "lcsc")
|
||||||
.Description($"Leaves Cross server channel instance from this channel. **Needs Manage Server Permissions.**| `{Prefix}lcsc`")
|
// .Description($"Leaves Cross server channel instance from this channel. **Needs Manage Server Permissions.**| `{Prefix}lcsc`")
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
foreach (var subscriber in Subscribers)
|
// foreach (var subscriber in Subscribers)
|
||||||
{
|
// {
|
||||||
subscriber.Value.Remove(e.Channel);
|
// subscriber.Value.Remove(e.Channel);
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,225 +1,225 @@
|
|||||||
using Discord;
|
//using Discord;
|
||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Text;
|
//using System.Text;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
class CustomReactionsCommands : DiscordCommand
|
// class CustomReactionsCommands : DiscordCommand
|
||||||
{
|
// {
|
||||||
public CustomReactionsCommands(DiscordModule module) : base(module)
|
// public CustomReactionsCommands(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
var Prefix = Module.Prefix;
|
// var Prefix = Module.Prefix;
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "addcustreact")
|
// cgb.CreateCommand(Prefix + "addcustreact")
|
||||||
.Alias(Prefix + "acr")
|
// .Alias(Prefix + "acr")
|
||||||
.Description($"Add a custom reaction. Guide here: <https://github.com/Kwoth/NadekoBot/wiki/Custom-Reactions> **Bot Owner Only!** | `{Prefix}acr \"hello\" I love saying hello to %user%`")
|
// .Description($"Add a custom reaction. Guide here: <https://github.com/Kwoth/NadekoBot/wiki/Custom-Reactions> **Bot Owner Only!** | `{Prefix}acr \"hello\" I love saying hello to %user%`")
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Parameter("name", ParameterType.Required)
|
// .Parameter("name", ParameterType.Required)
|
||||||
.Parameter("message", ParameterType.Unparsed)
|
// .Parameter("message", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var name = e.GetArg("name");
|
// var name = e.GetArg("name");
|
||||||
var message = e.GetArg("message")?.Trim();
|
// var message = e.GetArg("message")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(message))
|
// if (string.IsNullOrWhiteSpace(message))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync($"Incorrect command usage. See -h {Prefix}acr for correct formatting").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"Incorrect command usage. See -h {Prefix}acr for correct formatting").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (NadekoBot.Config.CustomReactions.ContainsKey(name))
|
// if (NadekoBot.Config.CustomReactions.ContainsKey(name))
|
||||||
NadekoBot.Config.CustomReactions[name].Add(message);
|
// NadekoBot.Config.CustomReactions[name].Add(message);
|
||||||
else
|
// else
|
||||||
NadekoBot.Config.CustomReactions.Add(name, new System.Collections.Generic.List<string>() { message });
|
// NadekoBot.Config.CustomReactions.Add(name, new System.Collections.Generic.List<string>() { message });
|
||||||
await Classes.JSONModels.ConfigHandler.SaveConfig().ConfigureAwait(false);
|
// await Classes.JSONModels.ConfigHandler.SaveConfig().ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Added {name} : {message}").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"Added {name} : {message}").ConfigureAwait(false);
|
||||||
|
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "listcustreact")
|
// cgb.CreateCommand(Prefix + "listcustreact")
|
||||||
.Alias(Prefix + "lcr")
|
// .Alias(Prefix + "lcr")
|
||||||
.Description($"Lists custom reactions (paginated with 30 commands per page). Use 'all' instead of page number to get all custom reactions DM-ed to you. |`{Prefix}lcr 1`")
|
// .Description($"Lists custom reactions (paginated with 30 commands per page). Use 'all' instead of page number to get all custom reactions DM-ed to you. |`{Prefix}lcr 1`")
|
||||||
.Parameter("num", ParameterType.Required)
|
// .Parameter("num", ParameterType.Required)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var numStr = e.GetArg("num");
|
// var numStr = e.GetArg("num");
|
||||||
|
|
||||||
if (numStr.ToUpperInvariant() == "ALL")
|
// if (numStr.ToUpperInvariant() == "ALL")
|
||||||
{
|
// {
|
||||||
var fullstr = String.Join("\n", NadekoBot.Config.CustomReactions.Select(kvp => kvp.Key));
|
// var fullstr = String.Join("\n", NadekoBot.Config.CustomReactions.Select(kvp => kvp.Key));
|
||||||
do
|
// do
|
||||||
{
|
// {
|
||||||
var str = string.Concat(fullstr.Take(1900));
|
// var str = string.Concat(fullstr.Take(1900));
|
||||||
fullstr = new string(fullstr.Skip(1900).ToArray());
|
// fullstr = new string(fullstr.Skip(1900).ToArray());
|
||||||
await e.User.SendMessage("```xl\n" + str + "```");
|
// await e.User.SendMessage("```xl\n" + str + "```");
|
||||||
} while (fullstr.Length != 0);
|
// } while (fullstr.Length != 0);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
int num;
|
// int num;
|
||||||
if (!int.TryParse(numStr, out num) || num <= 0) num = 1;
|
// if (!int.TryParse(numStr, out num) || num <= 0) num = 1;
|
||||||
var cmds = GetCustomsOnPage(num - 1);
|
// var cmds = GetCustomsOnPage(num - 1);
|
||||||
if (!cmds.Any())
|
// if (!cmds.Any())
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`There are no custom reactions.`");
|
// await imsg.Channel.SendMessageAsync("`There are no custom reactions.`");
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
string result = SearchHelper.ShowInPrettyCode<string>(cmds, s => $"{s,-25}"); //People prefer starting with 1
|
// string result = SearchHelper.ShowInPrettyCode<string>(cmds, s => $"{s,-25}"); //People prefer starting with 1
|
||||||
await imsg.Channel.SendMessageAsync($"`Showing page {num}:`\n" + result).ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"`Showing page {num}:`\n" + result).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "showcustreact")
|
// cgb.CreateCommand(Prefix + "showcustreact")
|
||||||
.Alias(Prefix + "scr")
|
// .Alias(Prefix + "scr")
|
||||||
.Description($"Shows all possible responses from a single custom reaction. |`{Prefix}scr %mention% bb`")
|
// .Description($"Shows all possible responses from a single custom reaction. |`{Prefix}scr %mention% bb`")
|
||||||
.Parameter("name", ParameterType.Unparsed)
|
// .Parameter("name", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var name = e.GetArg("name")?.Trim();
|
// var name = e.GetArg("name")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
// if (string.IsNullOrWhiteSpace(name))
|
||||||
return;
|
// return;
|
||||||
if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
// if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`Can't find that custom reaction.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Can't find that custom reaction.`").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var items = NadekoBot.Config.CustomReactions[name];
|
// var items = NadekoBot.Config.CustomReactions[name];
|
||||||
var message = new StringBuilder($"Responses for {Format.Bold(name)}:\n");
|
// var message = new StringBuilder($"Responses for {Format.Bold(name)}:\n");
|
||||||
var last = items.Last();
|
// var last = items.Last();
|
||||||
|
|
||||||
int i = 1;
|
// int i = 1;
|
||||||
foreach (var reaction in items)
|
// foreach (var reaction in items)
|
||||||
{
|
// {
|
||||||
message.AppendLine($"[{i++}] " + Format.Code(Format.Escape(reaction)));
|
// message.AppendLine($"[{i++}] " + Format.Code(Format.Escape(reaction)));
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync(message.ToString());
|
// await imsg.Channel.SendMessageAsync(message.ToString());
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "editcustreact")
|
// cgb.CreateCommand(Prefix + "editcustreact")
|
||||||
.Alias(Prefix + "ecr")
|
// .Alias(Prefix + "ecr")
|
||||||
.Description($"Edits a custom reaction, arguments are custom reactions name, index to change, and a (multiword) message **Bot Owner Only** | `{Prefix}ecr \"%mention% disguise\" 2 Test 123`")
|
// .Description($"Edits a custom reaction, arguments are custom reactions name, index to change, and a (multiword) message **Bot Owner Only** | `{Prefix}ecr \"%mention% disguise\" 2 Test 123`")
|
||||||
.Parameter("name", ParameterType.Required)
|
// .Parameter("name", ParameterType.Required)
|
||||||
.Parameter("index", ParameterType.Required)
|
// .Parameter("index", ParameterType.Required)
|
||||||
.Parameter("message", ParameterType.Unparsed)
|
// .Parameter("message", ParameterType.Unparsed)
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var name = e.GetArg("name")?.Trim();
|
// var name = e.GetArg("name")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
// if (string.IsNullOrWhiteSpace(name))
|
||||||
return;
|
// return;
|
||||||
var indexstr = e.GetArg("index")?.Trim();
|
// var indexstr = e.GetArg("index")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(indexstr))
|
// if (string.IsNullOrWhiteSpace(indexstr))
|
||||||
return;
|
// return;
|
||||||
var msg = e.GetArg("message")?.Trim();
|
// var msg = e.GetArg("message")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(msg))
|
// if (string.IsNullOrWhiteSpace(msg))
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
// if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`Could not find given commandname`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Could not find given commandname`").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int index;
|
// int index;
|
||||||
if (!int.TryParse(indexstr, out index) || index < 1 || index > NadekoBot.Config.CustomReactions[name].Count)
|
// if (!int.TryParse(indexstr, out index) || index < 1 || index > NadekoBot.Config.CustomReactions[name].Count)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`Invalid index.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Invalid index.`").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
index = index - 1;
|
// index = index - 1;
|
||||||
NadekoBot.Config.CustomReactions[name][index] = msg;
|
// NadekoBot.Config.CustomReactions[name][index] = msg;
|
||||||
|
|
||||||
await Classes.JSONModels.ConfigHandler.SaveConfig().ConfigureAwait(false);
|
// await Classes.JSONModels.ConfigHandler.SaveConfig().ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync($"Edited response #{index + 1} from `{name}`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"Edited response #{index + 1} from `{name}`").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "delcustreact")
|
// cgb.CreateCommand(Prefix + "delcustreact")
|
||||||
.Alias(Prefix + "dcr")
|
// .Alias(Prefix + "dcr")
|
||||||
.Description($"Deletes a custom reaction with given name (and index). **Bot Owner Only.**| `{Prefix}dcr index`")
|
// .Description($"Deletes a custom reaction with given name (and index). **Bot Owner Only.**| `{Prefix}dcr index`")
|
||||||
.Parameter("name", ParameterType.Required)
|
// .Parameter("name", ParameterType.Required)
|
||||||
.Parameter("index", ParameterType.Optional)
|
// .Parameter("index", ParameterType.Optional)
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var name = e.GetArg("name")?.Trim();
|
// var name = e.GetArg("name")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
// if (string.IsNullOrWhiteSpace(name))
|
||||||
return;
|
// return;
|
||||||
if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
// if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("Could not find given commandname").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Could not find given commandname").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
string message = "";
|
// string message = "";
|
||||||
int index;
|
// int index;
|
||||||
if (int.TryParse(e.GetArg("index")?.Trim() ?? "", out index))
|
// if (int.TryParse(e.GetArg("index")?.Trim() ?? "", out index))
|
||||||
{
|
// {
|
||||||
index = index - 1;
|
// index = index - 1;
|
||||||
if (index < 0 || index > NadekoBot.Config.CustomReactions[name].Count)
|
// if (index < 0 || index > NadekoBot.Config.CustomReactions[name].Count)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("Given index was out of range").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Given index was out of range").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
}
|
// }
|
||||||
NadekoBot.Config.CustomReactions[name].RemoveAt(index);
|
// NadekoBot.Config.CustomReactions[name].RemoveAt(index);
|
||||||
if (!NadekoBot.Config.CustomReactions[name].Any())
|
// if (!NadekoBot.Config.CustomReactions[name].Any())
|
||||||
{
|
// {
|
||||||
NadekoBot.Config.CustomReactions.Remove(name);
|
// NadekoBot.Config.CustomReactions.Remove(name);
|
||||||
}
|
// }
|
||||||
message = $"Deleted response #{index + 1} from `{name}`";
|
// message = $"Deleted response #{index + 1} from `{name}`";
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
NadekoBot.Config.CustomReactions.Remove(name);
|
// NadekoBot.Config.CustomReactions.Remove(name);
|
||||||
message = $"Deleted custom reaction: `{name}`";
|
// message = $"Deleted custom reaction: `{name}`";
|
||||||
}
|
// }
|
||||||
await Classes.JSONModels.ConfigHandler.SaveConfig().ConfigureAwait(false);
|
// await Classes.JSONModels.ConfigHandler.SaveConfig().ConfigureAwait(false);
|
||||||
await imsg.Channel.SendMessageAsync(message).ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(message).ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
private readonly int ItemsPerPage = 30;
|
// private readonly int ItemsPerPage = 30;
|
||||||
|
|
||||||
private IEnumerable<string> GetCustomsOnPage(int page)
|
// private IEnumerable<string> GetCustomsOnPage(int page)
|
||||||
{
|
// {
|
||||||
var items = NadekoBot.Config.CustomReactions.Skip(page * ItemsPerPage).Take(ItemsPerPage);
|
// var items = NadekoBot.Config.CustomReactions.Skip(page * ItemsPerPage).Take(ItemsPerPage);
|
||||||
if (!items.Any())
|
// if (!items.Any())
|
||||||
{
|
// {
|
||||||
return Enumerable.Empty<string>();
|
// return Enumerable.Empty<string>();
|
||||||
}
|
// }
|
||||||
return items.Select(kvp => kvp.Key);
|
// return items.Select(kvp => kvp.Key);
|
||||||
/*
|
// /*
|
||||||
var message = new StringBuilder($"--- Custom reactions - page {page + 1} ---\n");
|
// var message = new StringBuilder($"--- Custom reactions - page {page + 1} ---\n");
|
||||||
foreach (var cr in items)
|
// foreach (var cr in items)
|
||||||
{
|
// {
|
||||||
message.Append($"{Format.Code(cr.Key)}\n");
|
// message.Append($"{Format.Code(cr.Key)}\n");
|
||||||
int i = 1;
|
// int i = 1;
|
||||||
var last = cr.Value.Last();
|
// var last = cr.Value.Last();
|
||||||
foreach (var reaction in cr.Value)
|
// foreach (var reaction in cr.Value)
|
||||||
{
|
// {
|
||||||
if (last != reaction)
|
// if (last != reaction)
|
||||||
message.AppendLine(" `├" + i++ + "─`" + Format.Bold(reaction));
|
// message.AppendLine(" `├" + i++ + "─`" + Format.Bold(reaction));
|
||||||
else
|
// else
|
||||||
message.AppendLine(" `└" + i++ + "─`" + Format.Bold(reaction));
|
// message.AppendLine(" `└" + i++ + "─`" + Format.Bold(reaction));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return message.ToString() + "\n";
|
// return message.ToString() + "\n";
|
||||||
*/
|
// */
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
// zeta is a god
|
//// zeta is a god
|
||||||
//├
|
////├
|
||||||
//─
|
////─
|
||||||
//│
|
////│
|
||||||
//└
|
////└
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.DataModels;
|
//using NadekoBot.DataModels;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System.IO;
|
//using System.IO;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
internal class IncidentsCommands : DiscordCommand
|
// internal class IncidentsCommands : DiscordCommand
|
||||||
{
|
// {
|
||||||
public IncidentsCommands(DiscordModule module) : base(module) { }
|
// public IncidentsCommands(DiscordModule module) : base(module) { }
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "listincidents")
|
// cgb.CreateCommand(Module.Prefix + "listincidents")
|
||||||
.Alias(Prefix + "lin")
|
// .Alias(Prefix + "lin")
|
||||||
.Description($"List all UNREAD incidents and flags them as read. **Needs Manage Server Permissions.**| `{Prefix}lin`")
|
// .Description($"List all UNREAD incidents and flags them as read. **Needs Manage Server Permissions.**| `{Prefix}lin`")
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var sid = (long)e.Server.Id;
|
// var sid = (long)e.Server.Id;
|
||||||
var incs = DbHandler.Instance.FindAll<Incident>(i => i.ServerId == sid && i.Read == false);
|
// 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; }));
|
// 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 e.User.SendMessage(string.Join("\n----------------------", incs.Select(i => i.Text)));
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "listallincidents")
|
// cgb.CreateCommand(Module.Prefix + "listallincidents")
|
||||||
.Alias(Prefix + "lain")
|
// .Alias(Prefix + "lain")
|
||||||
.Description($"Sends you a file containing all incidents and flags them as read. **Needs Manage Server Permissions.**| `{Prefix}lain`")
|
// .Description($"Sends you a file containing all incidents and flags them as read. **Needs Manage Server Permissions.**| `{Prefix}lain`")
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var sid = (long)e.Server.Id;
|
// var sid = (long)e.Server.Id;
|
||||||
var incs = DbHandler.Instance.FindAll<Incident>(i => i.ServerId == sid);
|
// var incs = DbHandler.Instance.FindAll<Incident>(i => i.ServerId == sid);
|
||||||
DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return i; }));
|
// DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return i; }));
|
||||||
var data = string.Join("\n----------------------\n", incs.Select(i => i.Text));
|
// var data = string.Join("\n----------------------\n", incs.Select(i => i.Text));
|
||||||
MemoryStream ms = new MemoryStream();
|
// MemoryStream ms = new MemoryStream();
|
||||||
var sw = new StreamWriter(ms);
|
// var sw = new StreamWriter(ms);
|
||||||
sw.WriteLine(data);
|
// sw.WriteLine(data);
|
||||||
sw.Flush();
|
// sw.Flush();
|
||||||
sw.BaseStream.Position = 0;
|
// sw.BaseStream.Position = 0;
|
||||||
await e.User.SendFile("incidents.txt", sw.BaseStream);
|
// await e.User.SendFile("incidents.txt", sw.BaseStream);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,483 +1,483 @@
|
|||||||
using Discord;
|
//using Discord;
|
||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Extensions;
|
//using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
internal class LogCommand : DiscordCommand
|
// internal class LogCommand : DiscordCommand
|
||||||
{
|
// {
|
||||||
private string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】";
|
// private string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】";
|
||||||
|
|
||||||
private ConcurrentBag<KeyValuePair<Channel, string>> voicePresenceUpdates = new ConcurrentBag<KeyValuePair<Channel, string>>();
|
// private ConcurrentBag<KeyValuePair<Channel, string>> voicePresenceUpdates = new ConcurrentBag<KeyValuePair<Channel, string>>();
|
||||||
|
|
||||||
public LogCommand(DiscordModule module) : base(module)
|
// public LogCommand(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
NadekoBot.Client.MessageReceived += MsgRecivd;
|
// NadekoBot.Client.MessageReceived += MsgRecivd;
|
||||||
NadekoBot.Client.MessageDeleted += MsgDltd;
|
// NadekoBot.Client.MessageDeleted += MsgDltd;
|
||||||
NadekoBot.Client.MessageUpdated += MsgUpdtd;
|
// NadekoBot.Client.MessageUpdated += MsgUpdtd;
|
||||||
NadekoBot.Client.UserUpdated += UsrUpdtd;
|
// NadekoBot.Client.UserUpdated += UsrUpdtd;
|
||||||
NadekoBot.Client.UserBanned += UsrBanned;
|
// NadekoBot.Client.UserBanned += UsrBanned;
|
||||||
NadekoBot.Client.UserLeft += UsrLeft;
|
// NadekoBot.Client.UserLeft += UsrLeft;
|
||||||
NadekoBot.Client.UserJoined += UsrJoined;
|
// NadekoBot.Client.UserJoined += UsrJoined;
|
||||||
NadekoBot.Client.UserUnbanned += UsrUnbanned;
|
// NadekoBot.Client.UserUnbanned += UsrUnbanned;
|
||||||
NadekoBot.Client.ChannelCreated += ChannelCreated;
|
// NadekoBot.Client.ChannelCreated += ChannelCreated;
|
||||||
NadekoBot.Client.ChannelDestroyed += ChannelDestroyed;
|
// NadekoBot.Client.ChannelDestroyed += ChannelDestroyed;
|
||||||
NadekoBot.Client.ChannelUpdated += ChannelUpdated;
|
// NadekoBot.Client.ChannelUpdated += ChannelUpdated;
|
||||||
|
|
||||||
|
|
||||||
NadekoBot.Client.MessageReceived += async (s, e) =>
|
// NadekoBot.Client.MessageReceived += async (s, e) =>
|
||||||
{
|
// {
|
||||||
if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
// if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
||||||
return;
|
// return;
|
||||||
if (!SpecificConfigurations.Default.Of(e.Server.Id).SendPrivateMessageOnMention) return;
|
// if (!SpecificConfigurations.Default.Of(e.Server.Id).SendPrivateMessageOnMention) return;
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != e.User);
|
// var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != e.User);
|
||||||
if (usr?.Status != UserStatus.Offline)
|
// if (usr?.Status != UserStatus.Offline)
|
||||||
return;
|
// return;
|
||||||
await imsg.Channel.SendMessageAsync($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false);
|
||||||
await usr.SendMessage(
|
// await usr.SendMessage(
|
||||||
$"User `{e.User.Name}` mentioned you on " +
|
// $"User `{e.User.Name}` mentioned you on " +
|
||||||
$"`{e.Server.Name}` server while you were offline.\n" +
|
// $"`{e.Server.Name}` server while you were offline.\n" +
|
||||||
$"`Message:` {e.Message.Text}").ConfigureAwait(false);
|
// $"`Message:` {e.Message.Text}").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
};
|
// };
|
||||||
|
|
||||||
// start the userpresence queue
|
// // start the userpresence queue
|
||||||
|
|
||||||
NadekoBot.OnReady += () => Task.Run(async () =>
|
// NadekoBot.OnReady += () => Task.Run(async () =>
|
||||||
{
|
// {
|
||||||
while (true)
|
// while (true)
|
||||||
{
|
// {
|
||||||
var toSend = new Dictionary<Channel, string>();
|
// var toSend = new Dictionary<Channel, string>();
|
||||||
//take everything from the queue and merge the messages which are going to the same channel
|
// //take everything from the queue and merge the messages which are going to the same channel
|
||||||
KeyValuePair<Channel, string> item;
|
// KeyValuePair<Channel, string> item;
|
||||||
while (voicePresenceUpdates.TryTake(out item))
|
// while (voicePresenceUpdates.TryTake(out item))
|
||||||
{
|
// {
|
||||||
if (toSend.ContainsKey(item.Key))
|
// if (toSend.ContainsKey(item.Key))
|
||||||
{
|
// {
|
||||||
toSend[item.Key] = toSend[item.Key] + Environment.NewLine + item.Value;
|
// toSend[item.Key] = toSend[item.Key] + Environment.NewLine + item.Value;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
toSend.Add(item.Key, item.Value);
|
// toSend.Add(item.Key, item.Value);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//send merged messages to each channel
|
// //send merged messages to each channel
|
||||||
foreach (var k in toSend)
|
// foreach (var k in toSend)
|
||||||
{
|
// {
|
||||||
try { await k.Key.SendMessage(Environment.NewLine + k.Value).ConfigureAwait(false); } catch { }
|
// try { await k.Key.SendMessage(Environment.NewLine + k.Value).ConfigureAwait(false); } catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
await Task.Delay(5000);
|
// await Task.Delay(5000);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void ChannelUpdated(object sender, ChannelUpdatedEventArgs e)
|
// private async void ChannelUpdated(object sender, ChannelUpdatedEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var chId = config.LogServerChannel;
|
// var chId = config.LogServerChannel;
|
||||||
if (chId == null || config.LogserverIgnoreChannels.Contains(e.After.Id))
|
// if (chId == null || config.LogserverIgnoreChannels.Contains(e.After.Id))
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
if (e.Before.Name != e.After.Name)
|
// if (e.Before.Name != e.After.Name)
|
||||||
await ch.SendMessage($@"`{prettyCurrentTime}` **Channel Name Changed** `#{e.Before.Name}` (*{e.After.Id}*)
|
// await ch.SendMessage($@"`{prettyCurrentTime}` **Channel Name Changed** `#{e.Before.Name}` (*{e.After.Id}*)
|
||||||
`New:` {e.After.Name}").ConfigureAwait(false);
|
// `New:` {e.After.Name}").ConfigureAwait(false);
|
||||||
else if (e.Before.Topic != e.After.Topic)
|
// else if (e.Before.Topic != e.After.Topic)
|
||||||
await ch.SendMessage($@"`{prettyCurrentTime}` **Channel Topic Changed** `#{e.After.Name}` (*{e.After.Id}*)
|
// await ch.SendMessage($@"`{prettyCurrentTime}` **Channel Topic Changed** `#{e.After.Name}` (*{e.After.Id}*)
|
||||||
`Old:` {e.Before.Topic}
|
// `Old:` {e.Before.Topic}
|
||||||
`New:` {e.After.Topic}").ConfigureAwait(false);
|
// `New:` {e.After.Topic}").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void ChannelDestroyed(object sender, ChannelEventArgs e)
|
// private async void ChannelDestroyed(object sender, ChannelEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var chId = config.LogServerChannel;
|
// var chId = config.LogServerChannel;
|
||||||
if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
// if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage($"❗`{prettyCurrentTime}`❗`Channel Deleted:` #{e.Channel.Name} (*{e.Channel.Id}*)").ConfigureAwait(false);
|
// await ch.SendMessage($"❗`{prettyCurrentTime}`❗`Channel Deleted:` #{e.Channel.Name} (*{e.Channel.Id}*)").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void ChannelCreated(object sender, ChannelEventArgs e)
|
// private async void ChannelCreated(object sender, ChannelEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var chId = config.LogServerChannel;
|
// var chId = config.LogServerChannel;
|
||||||
if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
// if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage($"`{prettyCurrentTime}`🆕`Channel Created:` #{e.Channel.Mention} (*{e.Channel.Id}*)").ConfigureAwait(false);
|
// await ch.SendMessage($"`{prettyCurrentTime}`🆕`Channel Created:` #{e.Channel.Mention} (*{e.Channel.Id}*)").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void UsrUnbanned(object sender, UserEventArgs e)
|
// private async void UsrUnbanned(object sender, UserEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||||
if (chId == null)
|
// if (chId == null)
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage($"`{prettyCurrentTime}`♻`User was unbanned:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
// await ch.SendMessage($"`{prettyCurrentTime}`♻`User was unbanned:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void UsrJoined(object sender, UserEventArgs e)
|
// private async void UsrJoined(object sender, UserEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||||
if (chId == null)
|
// if (chId == null)
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage($"`{prettyCurrentTime}`✅`User joined:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
// await ch.SendMessage($"`{prettyCurrentTime}`✅`User joined:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void UsrLeft(object sender, UserEventArgs e)
|
// private async void UsrLeft(object sender, UserEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||||
if (chId == null)
|
// if (chId == null)
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage($"`{prettyCurrentTime}`❗`User left:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
// await ch.SendMessage($"`{prettyCurrentTime}`❗`User left:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void UsrBanned(object sender, UserEventArgs e)
|
// private async void UsrBanned(object sender, UserEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||||
if (chId == null)
|
// if (chId == null)
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage($"❗`{prettyCurrentTime}`❌`User banned:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
// await ch.SendMessage($"❗`{prettyCurrentTime}`❌`User banned:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void MsgRecivd(object sender, MessageEventArgs e)
|
// private async void MsgRecivd(object sender, MessageEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
// if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
||||||
return;
|
// return;
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var chId = config.LogServerChannel;
|
// var chId = config.LogServerChannel;
|
||||||
if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
// if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
if (!string.IsNullOrWhiteSpace(e.Message.Text))
|
// if (!string.IsNullOrWhiteSpace(e.Message.Text))
|
||||||
{
|
// {
|
||||||
await ch.SendMessage(
|
// await ch.SendMessage(
|
||||||
$@"🕔`{prettyCurrentTime}` **New Message** `#{e.Channel.Name}`
|
// $@"🕔`{prettyCurrentTime}` **New Message** `#{e.Channel.Name}`
|
||||||
👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
|
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
await ch.SendMessage(
|
// await ch.SendMessage(
|
||||||
$@"🕔`{prettyCurrentTime}` **File Uploaded** `#{e.Channel.Name}`
|
// $@"🕔`{prettyCurrentTime}` **File Uploaded** `#{e.Channel.Name}`
|
||||||
👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
|
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
private async void MsgDltd(object sender, MessageEventArgs e)
|
// private async void MsgDltd(object sender, MessageEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id)
|
// if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id)
|
||||||
return;
|
// return;
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var chId = config.LogServerChannel;
|
// var chId = config.LogServerChannel;
|
||||||
if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
// if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
if (!string.IsNullOrWhiteSpace(e.Message.Text))
|
// if (!string.IsNullOrWhiteSpace(e.Message.Text))
|
||||||
{
|
// {
|
||||||
await ch.SendMessage(
|
// await ch.SendMessage(
|
||||||
$@"🕔`{prettyCurrentTime}` **Message** 🚮 `#{e.Channel.Name}`
|
// $@"🕔`{prettyCurrentTime}` **Message** 🚮 `#{e.Channel.Name}`
|
||||||
👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
|
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
await ch.SendMessage(
|
// await ch.SendMessage(
|
||||||
$@"🕔`{prettyCurrentTime}` **File Deleted** `#{e.Channel.Name}`
|
// $@"🕔`{prettyCurrentTime}` **File Deleted** `#{e.Channel.Name}`
|
||||||
👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
|
//👤`{e.User?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
private async void MsgUpdtd(object sender, MessageUpdatedEventArgs e)
|
// private async void MsgUpdtd(object sender, MessageUpdatedEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id)
|
// if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id)
|
||||||
return;
|
// return;
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var chId = config.LogServerChannel;
|
// var chId = config.LogServerChannel;
|
||||||
if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
// if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id))
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage(
|
// await ch.SendMessage(
|
||||||
$@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}`
|
// $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}`
|
||||||
👤`{e.User?.ToString() ?? ("NULL")}`
|
//👤`{e.User?.ToString() ?? ("NULL")}`
|
||||||
`Old:` {e.Before.Text.Unmention()}
|
// `Old:` {e.Before.Text.Unmention()}
|
||||||
`New:` {e.After.Text.Unmention()}").ConfigureAwait(false);
|
// `New:` {e.After.Text.Unmention()}").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
private async void UsrUpdtd(object sender, UserUpdatedEventArgs e)
|
// private async void UsrUpdtd(object sender, UserUpdatedEventArgs e)
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var chId = config.LogPresenceChannel;
|
// var chId = config.LogPresenceChannel;
|
||||||
if (chId != null)
|
// if (chId != null)
|
||||||
{
|
// {
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) != null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) != null)
|
||||||
{
|
// {
|
||||||
if (e.Before.Status != e.After.Status)
|
// if (e.Before.Status != e.After.Status)
|
||||||
{
|
// {
|
||||||
voicePresenceUpdates.Add(new KeyValuePair<Channel, string>(ch, $"`{prettyCurrentTime}`**{e.Before.Name}** is now **{e.After.Status}**."));
|
// voicePresenceUpdates.Add(new KeyValuePair<Channel, string>(ch, $"`{prettyCurrentTime}`**{e.Before.Name}** is now **{e.After.Status}**."));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
ulong notifyChBeforeId;
|
// ulong notifyChBeforeId;
|
||||||
ulong notifyChAfterId;
|
// ulong notifyChAfterId;
|
||||||
Channel notifyChBefore = null;
|
// Channel notifyChBefore = null;
|
||||||
Channel notifyChAfter = null;
|
// Channel notifyChAfter = null;
|
||||||
var beforeVch = e.Before.VoiceChannel;
|
// var beforeVch = e.Before.VoiceChannel;
|
||||||
var afterVch = e.After.VoiceChannel;
|
// var afterVch = e.After.VoiceChannel;
|
||||||
var notifyLeave = false;
|
// var notifyLeave = false;
|
||||||
var notifyJoin = false;
|
// var notifyJoin = false;
|
||||||
if ((beforeVch != null || afterVch != null) && (beforeVch != afterVch)) // this means we need to notify for sure.
|
// if ((beforeVch != null || afterVch != null) && (beforeVch != afterVch)) // this means we need to notify for sure.
|
||||||
{
|
// {
|
||||||
if (beforeVch != null && config.VoiceChannelLog.TryGetValue(beforeVch.Id, out notifyChBeforeId) && (notifyChBefore = e.Before.Server.TextChannels.FirstOrDefault(tc => tc.Id == notifyChBeforeId)) != null)
|
// if (beforeVch != null && config.VoiceChannelLog.TryGetValue(beforeVch.Id, out notifyChBeforeId) && (notifyChBefore = e.Before.Server.TextChannels.FirstOrDefault(tc => tc.Id == notifyChBeforeId)) != null)
|
||||||
{
|
// {
|
||||||
notifyLeave = true;
|
// notifyLeave = true;
|
||||||
}
|
// }
|
||||||
if (afterVch != null && config.VoiceChannelLog.TryGetValue(afterVch.Id, out notifyChAfterId) && (notifyChAfter = e.After.Server.TextChannels.FirstOrDefault(tc => tc.Id == notifyChAfterId)) != null)
|
// if (afterVch != null && config.VoiceChannelLog.TryGetValue(afterVch.Id, out notifyChAfterId) && (notifyChAfter = e.After.Server.TextChannels.FirstOrDefault(tc => tc.Id == notifyChAfterId)) != null)
|
||||||
{
|
// {
|
||||||
notifyJoin = true;
|
// notifyJoin = true;
|
||||||
}
|
// }
|
||||||
if ((notifyLeave && notifyJoin) && (notifyChAfter == notifyChBefore))
|
// if ((notifyLeave && notifyJoin) && (notifyChAfter == notifyChBefore))
|
||||||
{
|
// {
|
||||||
await notifyChAfter.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} moved from **{beforeVch.Mention}** to **{afterVch.Mention}** voice channel.").ConfigureAwait(false);
|
// await notifyChAfter.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} moved from **{beforeVch.Mention}** to **{afterVch.Mention}** voice channel.").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else if (notifyJoin)
|
// else if (notifyJoin)
|
||||||
{
|
// {
|
||||||
await notifyChAfter.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} has joined **{afterVch.Mention}** voice channel.").ConfigureAwait(false);
|
// await notifyChAfter.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} has joined **{afterVch.Mention}** voice channel.").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else if (notifyLeave)
|
// else if (notifyLeave)
|
||||||
{
|
// {
|
||||||
await notifyChBefore.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} has left **{beforeVch.Mention}** voice channel.").ConfigureAwait(false);
|
// await notifyChBefore.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} has left **{beforeVch.Mention}** voice channel.").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||||
if (chId == null)
|
// if (chId == null)
|
||||||
return;
|
// return;
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
string str = $"🕔`{prettyCurrentTime}`";
|
// string str = $"🕔`{prettyCurrentTime}`";
|
||||||
if (e.Before.Name != e.After.Name)
|
// if (e.Before.Name != e.After.Name)
|
||||||
str += $"**Name Changed**👤`{e.Before?.ToString()}`\n\t\t`New:`{e.After.ToString()}`";
|
// str += $"**Name Changed**👤`{e.Before?.ToString()}`\n\t\t`New:`{e.After.ToString()}`";
|
||||||
else if (e.Before.Nickname != e.After.Nickname)
|
// 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}";
|
// 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)
|
// 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()}";
|
// 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))
|
// else if (!e.Before.Roles.SequenceEqual(e.After.Roles))
|
||||||
{
|
// {
|
||||||
if (e.Before.Roles.Count() < e.After.Roles.Count())
|
// 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 + "`");
|
// 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.";
|
// 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())
|
// 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 + "`");
|
// 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.";
|
// str += $"**User's Roles changed ⚔➖**👤`{e.Before?.ToString()}`\n\tNo longer has {string.Join(", ", diffRoles)} role.";
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
Console.WriteLine("SEQUENCE NOT EQUAL BUT NO DIFF ROLES - REPORT TO KWOTH on #NADEKOLOG server");
|
// Console.WriteLine("SEQUENCE NOT EQUAL BUT NO DIFF ROLES - REPORT TO KWOTH on #NADEKOLOG server");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
return;
|
// return;
|
||||||
await ch.SendMessage(str).ConfigureAwait(false);
|
// await ch.SendMessage(str).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "spmom")
|
// 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`")
|
// .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())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var specificConfig = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var specificConfig = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
specificConfig.SendPrivateMessageOnMention =
|
// specificConfig.SendPrivateMessageOnMention =
|
||||||
!specificConfig.SendPrivateMessageOnMention;
|
// !specificConfig.SendPrivateMessageOnMention;
|
||||||
if (specificConfig.SendPrivateMessageOnMention)
|
// if (specificConfig.SendPrivateMessageOnMention)
|
||||||
await imsg.Channel.SendMessageAsync(":ok: I will send private messages " +
|
// await imsg.Channel.SendMessageAsync(":ok: I will send private messages " +
|
||||||
"to mentioned offline users.").ConfigureAwait(false);
|
// "to mentioned offline users.").ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await imsg.Channel.SendMessageAsync(":ok: I won't send private messages " +
|
// await imsg.Channel.SendMessageAsync(":ok: I won't send private messages " +
|
||||||
"to mentioned offline users anymore.").ConfigureAwait(false);
|
// "to mentioned offline users anymore.").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "logserver")
|
// 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`")
|
// .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.OwnerOnly())
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel;
|
||||||
if (chId == null)
|
// if (chId == null)
|
||||||
{
|
// {
|
||||||
SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = e.Channel.Id;
|
// SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = e.Channel.Id;
|
||||||
await imsg.Channel.SendMessageAsync($"❗**I WILL BEGIN LOGGING SERVER ACTIVITY IN THIS CHANNEL**❗").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"❗**I WILL BEGIN LOGGING SERVER ACTIVITY IN THIS CHANNEL**❗").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
Channel ch;
|
// Channel ch;
|
||||||
if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = null;
|
// SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = null;
|
||||||
await imsg.Channel.SendMessageAsync($"❗**NO LONGER LOGGING IN {ch.Mention} CHANNEL**❗").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"❗**NO LONGER LOGGING IN {ch.Mention} CHANNEL**❗").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "logignore")
|
// 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`")
|
// .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.OwnerOnly())
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (config.LogserverIgnoreChannels.Remove(e.Channel.Id))
|
// if (config.LogserverIgnoreChannels.Remove(e.Channel.Id))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync($"`{Prefix}logserver will stop ignoring this channel.`");
|
// await imsg.Channel.SendMessageAsync($"`{Prefix}logserver will stop ignoring this channel.`");
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
config.LogserverIgnoreChannels.Add(e.Channel.Id);
|
// config.LogserverIgnoreChannels.Add(e.Channel.Id);
|
||||||
await imsg.Channel.SendMessageAsync($"`{Prefix}logserver will ignore this channel.`");
|
// await imsg.Channel.SendMessageAsync($"`{Prefix}logserver will ignore this channel.`");
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "userpresence")
|
// 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`")
|
// .Description($"Starts logging to this channel when someone from the server goes online/offline/idle. **Needs Manage Server Permissions.**| `{Prefix}userpresence`")
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel;
|
// var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel;
|
||||||
if (chId == null)
|
// if (chId == null)
|
||||||
{
|
// {
|
||||||
SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = e.Channel.Id;
|
// SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = e.Channel.Id;
|
||||||
await imsg.Channel.SendMessageAsync($"**User presence notifications enabled.**").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"**User presence notifications enabled.**").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = null;
|
// SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = null;
|
||||||
await imsg.Channel.SendMessageAsync($"**User presence notifications disabled.**").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"**User presence notifications disabled.**").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "voicepresence")
|
// 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`")
|
// .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)
|
// .Parameter("all", ParameterType.Optional)
|
||||||
.AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
|
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (e.GetArg("all")?.ToLower() == "all")
|
// if (e.GetArg("all")?.ToLower() == "all")
|
||||||
{
|
// {
|
||||||
foreach (var voiceChannel in e.Server.VoiceChannels)
|
// foreach (var voiceChannel in e.Server.VoiceChannels)
|
||||||
{
|
// {
|
||||||
config.VoiceChannelLog.TryAdd(voiceChannel.Id, e.Channel.Id);
|
// config.VoiceChannelLog.TryAdd(voiceChannel.Id, e.Channel.Id);
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync("Started logging user presence for **ALL** voice channels!").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Started logging user presence for **ALL** voice channels!").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (e.User.VoiceChannel == null)
|
// if (e.User.VoiceChannel == null)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("💢 You are not in a voice channel right now. If you are, please rejoin it.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("💢 You are not in a voice channel right now. If you are, please rejoin it.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
ulong throwaway;
|
// ulong throwaway;
|
||||||
if (!config.VoiceChannelLog.TryRemove(e.User.VoiceChannel.Id, out throwaway))
|
// if (!config.VoiceChannelLog.TryRemove(e.User.VoiceChannel.Id, out throwaway))
|
||||||
{
|
// {
|
||||||
config.VoiceChannelLog.TryAdd(e.User.VoiceChannel.Id, e.Channel.Id);
|
// config.VoiceChannelLog.TryAdd(e.User.VoiceChannel.Id, e.Channel.Id);
|
||||||
await imsg.Channel.SendMessageAsync($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
await imsg.Channel.SendMessageAsync($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,129 +1,129 @@
|
|||||||
using Discord;
|
//using Discord;
|
||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using System.Timers;
|
//using System.Timers;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
class MessageRepeater : DiscordCommand
|
// class MessageRepeater : DiscordCommand
|
||||||
{
|
// {
|
||||||
private readonly ConcurrentDictionary<Server, Repeater> repeaters = new ConcurrentDictionary<Server, Repeater>();
|
// private readonly ConcurrentDictionary<Server, Repeater> repeaters = new ConcurrentDictionary<Server, Repeater>();
|
||||||
private class Repeater
|
// private class Repeater
|
||||||
{
|
// {
|
||||||
[Newtonsoft.Json.JsonIgnore]
|
// [Newtonsoft.Json.JsonIgnore]
|
||||||
public Timer MessageTimer { get; set; }
|
// public Timer MessageTimer { get; set; }
|
||||||
[Newtonsoft.Json.JsonIgnore]
|
// [Newtonsoft.Json.JsonIgnore]
|
||||||
public Channel RepeatingChannel { get; set; }
|
// public Channel RepeatingChannel { get; set; }
|
||||||
|
|
||||||
public ulong RepeatingServerId { get; set; }
|
// public ulong RepeatingServerId { get; set; }
|
||||||
public ulong RepeatingChannelId { get; set; }
|
// public ulong RepeatingChannelId { get; set; }
|
||||||
public Message lastMessage { get; set; } = null;
|
// public Message lastMessage { get; set; } = null;
|
||||||
public string RepeatingMessage { get; set; }
|
// public string RepeatingMessage { get; set; }
|
||||||
public int Interval { get; set; }
|
// public int Interval { get; set; }
|
||||||
|
|
||||||
public Repeater Start()
|
// public Repeater Start()
|
||||||
{
|
// {
|
||||||
MessageTimer = new Timer { Interval = Interval };
|
// MessageTimer = new Timer { Interval = Interval };
|
||||||
MessageTimer.Elapsed += async (s, e) => await Invoke();
|
// MessageTimer.Elapsed += async (s, e) => await Invoke();
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task Invoke()
|
// public async Task Invoke()
|
||||||
{
|
// {
|
||||||
var ch = RepeatingChannel;
|
// var ch = RepeatingChannel;
|
||||||
var msg = RepeatingMessage;
|
// var msg = RepeatingMessage;
|
||||||
if (ch != null && !string.IsNullOrWhiteSpace(msg))
|
// if (ch != null && !string.IsNullOrWhiteSpace(msg))
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (lastMessage != null)
|
// if (lastMessage != null)
|
||||||
await lastMessage.Delete().ConfigureAwait(false);
|
// await lastMessage.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
lastMessage = await ch.SendMessage(msg).ConfigureAwait(false);
|
// lastMessage = await ch.SendMessage(msg).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "repeatinvoke")
|
// cgb.CreateCommand(Module.Prefix + "repeatinvoke")
|
||||||
.Alias(Module.Prefix + "repinv")
|
// .Alias(Module.Prefix + "repinv")
|
||||||
.Description($"Immediately shows the repeat message and restarts the timer. **Needs Manage Messages Permissions.**| `{Prefix}repinv`")
|
// .Description($"Immediately shows the repeat message and restarts the timer. **Needs Manage Messages Permissions.**| `{Prefix}repinv`")
|
||||||
.AddCheck(SimpleCheckers.ManageMessages())
|
// .AddCheck(SimpleCheckers.ManageMessages())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
Repeater rep;
|
// Repeater rep;
|
||||||
if (!repeaters.TryGetValue(e.Server, out rep))
|
// if (!repeaters.TryGetValue(e.Server, out rep))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`No repeating message found on this server.`");
|
// await imsg.Channel.SendMessageAsync("`No repeating message found on this server.`");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
await rep.Invoke();
|
// await rep.Invoke();
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "repeat")
|
// cgb.CreateCommand(Module.Prefix + "repeat")
|
||||||
.Description("Repeat a message every X minutes. If no parameters are specified, " +
|
// .Description("Repeat a message every X minutes. If no parameters are specified, " +
|
||||||
$"repeat is disabled. **Needs Manage Messages Permissions.** |`{Prefix}repeat 5 Hello there`")
|
// $"repeat is disabled. **Needs Manage Messages Permissions.** |`{Prefix}repeat 5 Hello there`")
|
||||||
.Parameter("minutes", ParameterType.Optional)
|
// .Parameter("minutes", ParameterType.Optional)
|
||||||
.Parameter("msg", ParameterType.Unparsed)
|
// .Parameter("msg", ParameterType.Unparsed)
|
||||||
.AddCheck(SimpleCheckers.ManageMessages())
|
// .AddCheck(SimpleCheckers.ManageMessages())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var minutesStr = e.GetArg("minutes");
|
// var minutesStr = e.GetArg("minutes");
|
||||||
var msg = e.GetArg("msg");
|
// var msg = e.GetArg("msg");
|
||||||
|
|
||||||
// if both null, disable
|
// // if both null, disable
|
||||||
if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
// if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
||||||
{
|
// {
|
||||||
|
|
||||||
Repeater rep;
|
// Repeater rep;
|
||||||
if (!repeaters.TryRemove(e.Server, out rep))
|
// if (!repeaters.TryRemove(e.Server, out rep))
|
||||||
return;
|
// return;
|
||||||
rep.MessageTimer.Stop();
|
// rep.MessageTimer.Stop();
|
||||||
await imsg.Channel.SendMessageAsync("Repeating disabled").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Repeating disabled").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
int minutes;
|
// int minutes;
|
||||||
if (!int.TryParse(minutesStr, out minutes) || minutes < 1 || minutes > 1440)
|
// if (!int.TryParse(minutesStr, out minutes) || minutes < 1 || minutes > 1440)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("Invalid value").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Invalid value").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var repeater = repeaters.GetOrAdd(
|
// var repeater = repeaters.GetOrAdd(
|
||||||
e.Server,
|
// e.Server,
|
||||||
s => new Repeater
|
// s => new Repeater
|
||||||
{
|
// {
|
||||||
Interval = minutes * 60 * 1000,
|
// Interval = minutes * 60 * 1000,
|
||||||
RepeatingChannel = e.Channel,
|
// RepeatingChannel = e.Channel,
|
||||||
RepeatingChannelId = e.Channel.Id,
|
// RepeatingChannelId = e.Channel.Id,
|
||||||
RepeatingServerId = e.Server.Id,
|
// RepeatingServerId = e.Server.Id,
|
||||||
}.Start()
|
// }.Start()
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
// if (!string.IsNullOrWhiteSpace(msg))
|
||||||
repeater.RepeatingMessage = msg;
|
// repeater.RepeatingMessage = msg;
|
||||||
|
|
||||||
repeater.MessageTimer.Stop();
|
// repeater.MessageTimer.Stop();
|
||||||
repeater.MessageTimer.Start();
|
// repeater.MessageTimer.Start();
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync(String.Format("👌 Repeating `{0}` every " +
|
// await imsg.Channel.SendMessageAsync(String.Format("👌 Repeating `{0}` every " +
|
||||||
"**{1}** minutes on {2} channel.",
|
// "**{1}** minutes on {2} channel.",
|
||||||
repeater.RepeatingMessage, minutes, repeater.RepeatingChannel))
|
// repeater.RepeatingMessage, minutes, repeater.RepeatingChannel))
|
||||||
.ConfigureAwait(false);
|
// .ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
public MessageRepeater(DiscordModule module) : base(module) { }
|
// public MessageRepeater(DiscordModule module) : base(module) { }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,167 +1,167 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes.JSONModels;
|
//using NadekoBot.Classes.JSONModels;
|
||||||
using NadekoBot.Modules.Music;
|
//using NadekoBot.Modules.Music;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Text;
|
//using System.Text;
|
||||||
using System.Threading;
|
//using System.Threading;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using System.Timers;
|
//using System.Timers;
|
||||||
using Timer = System.Timers.Timer;
|
//using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
internal class PlayingRotate : DiscordCommand
|
// internal class PlayingRotate : DiscordCommand
|
||||||
{
|
// {
|
||||||
private static readonly Timer timer = new Timer(20000);
|
// private static readonly Timer timer = new Timer(20000);
|
||||||
|
|
||||||
public static Dictionary<string, Func<string>> PlayingPlaceholders { get; } =
|
// public static Dictionary<string, Func<string>> PlayingPlaceholders { get; } =
|
||||||
new Dictionary<string, Func<string>> {
|
// new Dictionary<string, Func<string>> {
|
||||||
{"%servers%", () => NadekoBot.Client.Servers.Count().ToString()},
|
// {"%servers%", () => NadekoBot.Client.Servers.Count().ToString()},
|
||||||
{"%users%", () => NadekoBot.Client.Servers.SelectMany(s => s.Users).Count().ToString()},
|
// {"%users%", () => NadekoBot.Client.Servers.SelectMany(s => s.Users).Count().ToString()},
|
||||||
{"%playing%", () => {
|
// {"%playing%", () => {
|
||||||
var cnt = MusicModule.MusicPlayers.Count(kvp => kvp.Value.CurrentSong != null);
|
// var cnt = MusicModule.MusicPlayers.Count(kvp => kvp.Value.CurrentSong != null);
|
||||||
if (cnt != 1) return cnt.ToString();
|
// if (cnt != 1) return cnt.ToString();
|
||||||
try {
|
// try {
|
||||||
var mp = MusicModule.MusicPlayers.FirstOrDefault();
|
// var mp = MusicModule.MusicPlayers.FirstOrDefault();
|
||||||
return mp.Value.CurrentSong.SongInfo.Title;
|
// return mp.Value.CurrentSong.SongInfo.Title;
|
||||||
}
|
// }
|
||||||
catch {
|
// catch {
|
||||||
return "No songs";
|
// return "No songs";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{"%queued%", () => MusicModule.MusicPlayers.Sum(kvp => kvp.Value.Playlist.Count).ToString()},
|
// {"%queued%", () => MusicModule.MusicPlayers.Sum(kvp => kvp.Value.Playlist.Count).ToString()},
|
||||||
{"%trivia%", () => Games.Commands.TriviaCommands.RunningTrivias.Count.ToString()}
|
// {"%trivia%", () => Games.Commands.TriviaCommands.RunningTrivias.Count.ToString()}
|
||||||
};
|
// };
|
||||||
|
|
||||||
private readonly SemaphoreSlim playingPlaceholderLock = new SemaphoreSlim(1,1);
|
// private readonly SemaphoreSlim playingPlaceholderLock = new SemaphoreSlim(1,1);
|
||||||
|
|
||||||
public PlayingRotate(DiscordModule module) : base(module)
|
// public PlayingRotate(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
var i = -1;
|
// var i = -1;
|
||||||
timer.Elapsed += async (s, e) =>
|
// timer.Elapsed += async (s, e) =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
i++;
|
// i++;
|
||||||
var status = "";
|
// var status = "";
|
||||||
//wtf am i doing, just use a queue ffs
|
// //wtf am i doing, just use a queue ffs
|
||||||
await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (PlayingPlaceholders.Count == 0
|
// if (PlayingPlaceholders.Count == 0
|
||||||
|| NadekoBot.Config.RotatingStatuses.Count == 0
|
// || NadekoBot.Config.RotatingStatuses.Count == 0
|
||||||
|| i >= NadekoBot.Config.RotatingStatuses.Count)
|
// || i >= NadekoBot.Config.RotatingStatuses.Count)
|
||||||
{
|
// {
|
||||||
i = 0;
|
// i = 0;
|
||||||
}
|
// }
|
||||||
status = NadekoBot.Config.RotatingStatuses[i];
|
// status = NadekoBot.Config.RotatingStatuses[i];
|
||||||
status = PlayingPlaceholders.Aggregate(status,
|
// status = PlayingPlaceholders.Aggregate(status,
|
||||||
(current, kvp) => current.Replace(kvp.Key, kvp.Value()));
|
// (current, kvp) => current.Replace(kvp.Key, kvp.Value()));
|
||||||
}
|
// }
|
||||||
finally { playingPlaceholderLock.Release(); }
|
// finally { playingPlaceholderLock.Release(); }
|
||||||
if (string.IsNullOrWhiteSpace(status))
|
// if (string.IsNullOrWhiteSpace(status))
|
||||||
return;
|
// return;
|
||||||
await Task.Run(() => { NadekoBot.Client.SetGame(status); });
|
// await Task.Run(() => { NadekoBot.Client.SetGame(status); });
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
};
|
// };
|
||||||
|
|
||||||
timer.Enabled = NadekoBot.Config.IsRotatingStatus;
|
// timer.Enabled = NadekoBot.Config.IsRotatingStatus;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public Func<CommandEventArgs, Task> DoFunc() => async e =>
|
// public Func<CommandEventArgs, Task> DoFunc() => async e =>
|
||||||
{
|
// {
|
||||||
await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (timer.Enabled)
|
// if (timer.Enabled)
|
||||||
timer.Stop();
|
// timer.Stop();
|
||||||
else
|
// else
|
||||||
timer.Start();
|
// timer.Start();
|
||||||
NadekoBot.Config.IsRotatingStatus = timer.Enabled;
|
// NadekoBot.Config.IsRotatingStatus = timer.Enabled;
|
||||||
await ConfigHandler.SaveConfig().ConfigureAwait(false);
|
// await ConfigHandler.SaveConfig().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
finally {
|
// finally {
|
||||||
playingPlaceholderLock.Release();
|
// playingPlaceholderLock.Release();
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`").ConfigureAwait(false);
|
||||||
};
|
// };
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "rotateplaying")
|
// cgb.CreateCommand(Module.Prefix + "rotateplaying")
|
||||||
.Alias(Module.Prefix + "ropl")
|
// .Alias(Module.Prefix + "ropl")
|
||||||
.Description($"Toggles rotation of playing status of the dynamic strings you specified earlier. **Bot Owner Only!** | `{Prefix}ropl`")
|
// .Description($"Toggles rotation of playing status of the dynamic strings you specified earlier. **Bot Owner Only!** | `{Prefix}ropl`")
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(DoFunc());
|
// .Do(DoFunc());
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "addplaying")
|
// cgb.CreateCommand(Module.Prefix + "addplaying")
|
||||||
.Alias(Module.Prefix + "adpl")
|
// .Alias(Module.Prefix + "adpl")
|
||||||
.Description("Adds a specified string to the list of playing strings to rotate. " +
|
// .Description("Adds a specified string to the list of playing strings to rotate. " +
|
||||||
"Supported placeholders: " + string.Join(", ", PlayingPlaceholders.Keys)+ $" **Bot Owner Only!**| `{Prefix}adpl`")
|
// "Supported placeholders: " + string.Join(", ", PlayingPlaceholders.Keys)+ $" **Bot Owner Only!**| `{Prefix}adpl`")
|
||||||
.Parameter("text", ParameterType.Unparsed)
|
// .Parameter("text", ParameterType.Unparsed)
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var arg = e.GetArg("text");
|
// var arg = e.GetArg("text");
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
// if (string.IsNullOrWhiteSpace(arg))
|
||||||
return;
|
// return;
|
||||||
await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
NadekoBot.Config.RotatingStatuses.Add(arg);
|
// NadekoBot.Config.RotatingStatuses.Add(arg);
|
||||||
await ConfigHandler.SaveConfig();
|
// await ConfigHandler.SaveConfig();
|
||||||
}
|
// }
|
||||||
finally
|
// finally
|
||||||
{
|
// {
|
||||||
playingPlaceholderLock.Release();
|
// playingPlaceholderLock.Release();
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync("🆗 `Added a new playing string.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("🆗 `Added a new playing string.`").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "listplaying")
|
// cgb.CreateCommand(Module.Prefix + "listplaying")
|
||||||
.Alias(Module.Prefix + "lipl")
|
// .Alias(Module.Prefix + "lipl")
|
||||||
.Description($"Lists all playing statuses with their corresponding number. **Bot Owner Only!**| `{Prefix}lipl`")
|
// .Description($"Lists all playing statuses with their corresponding number. **Bot Owner Only!**| `{Prefix}lipl`")
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (NadekoBot.Config.RotatingStatuses.Count == 0)
|
// if (NadekoBot.Config.RotatingStatuses.Count == 0)
|
||||||
await imsg.Channel.SendMessageAsync("`There are no playing strings. " +
|
// await imsg.Channel.SendMessageAsync("`There are no playing strings. " +
|
||||||
"Add some with .addplaying [text] command.`").ConfigureAwait(false);
|
// "Add some with .addplaying [text] command.`").ConfigureAwait(false);
|
||||||
var sb = new StringBuilder();
|
// var sb = new StringBuilder();
|
||||||
for (var i = 0; i < NadekoBot.Config.RotatingStatuses.Count; i++)
|
// for (var i = 0; i < NadekoBot.Config.RotatingStatuses.Count; i++)
|
||||||
{
|
// {
|
||||||
sb.AppendLine($"`{i + 1}.` {NadekoBot.Config.RotatingStatuses[i]}");
|
// sb.AppendLine($"`{i + 1}.` {NadekoBot.Config.RotatingStatuses[i]}");
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "removeplaying")
|
// cgb.CreateCommand(Module.Prefix + "removeplaying")
|
||||||
.Alias(Module.Prefix + "repl", Module.Prefix + "rmpl")
|
// .Alias(Module.Prefix + "repl", Module.Prefix + "rmpl")
|
||||||
.Description($"Removes a playing string on a given number. **Bot Owner Only!**| `{Prefix}rmpl`")
|
// .Description($"Removes a playing string on a given number. **Bot Owner Only!**| `{Prefix}rmpl`")
|
||||||
.Parameter("number", ParameterType.Required)
|
// .Parameter("number", ParameterType.Required)
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var arg = e.GetArg("number");
|
// var arg = e.GetArg("number");
|
||||||
int num;
|
// int num;
|
||||||
string str;
|
// string str;
|
||||||
await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||||
try {
|
// try {
|
||||||
if (!int.TryParse(arg.Trim(), out num) || num <= 0 || num > NadekoBot.Config.RotatingStatuses.Count)
|
// if (!int.TryParse(arg.Trim(), out num) || num <= 0 || num > NadekoBot.Config.RotatingStatuses.Count)
|
||||||
return;
|
// return;
|
||||||
str = NadekoBot.Config.RotatingStatuses[num - 1];
|
// str = NadekoBot.Config.RotatingStatuses[num - 1];
|
||||||
NadekoBot.Config.RotatingStatuses.RemoveAt(num - 1);
|
// NadekoBot.Config.RotatingStatuses.RemoveAt(num - 1);
|
||||||
await ConfigHandler.SaveConfig().ConfigureAwait(false);
|
// await ConfigHandler.SaveConfig().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
finally { playingPlaceholderLock.Release(); }
|
// finally { playingPlaceholderLock.Release(); }
|
||||||
await imsg.Channel.SendMessageAsync($"🆗 `Removed playing string #{num}`({str})").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($"🆗 `Removed playing string #{num}`({str})").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,63 +1,63 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
internal class RatelimitCommand : DiscordCommand
|
// internal class RatelimitCommand : DiscordCommand
|
||||||
{
|
// {
|
||||||
|
|
||||||
public static ConcurrentDictionary<ulong, ConcurrentDictionary<ulong, DateTime>> RatelimitingChannels = new ConcurrentDictionary<ulong, ConcurrentDictionary<ulong, DateTime>>();
|
// public static ConcurrentDictionary<ulong, ConcurrentDictionary<ulong, DateTime>> RatelimitingChannels = new ConcurrentDictionary<ulong, ConcurrentDictionary<ulong, DateTime>>();
|
||||||
|
|
||||||
private static readonly TimeSpan ratelimitTime = new TimeSpan(0, 0, 0, 5);
|
// private static readonly TimeSpan ratelimitTime = new TimeSpan(0, 0, 0, 5);
|
||||||
|
|
||||||
public RatelimitCommand(DiscordModule module) : base(module)
|
// public RatelimitCommand(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
NadekoBot.Client.MessageReceived += async (s, e) =>
|
// NadekoBot.Client.MessageReceived += async (s, e) =>
|
||||||
{
|
// {
|
||||||
if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
// if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
||||||
return;
|
// return;
|
||||||
ConcurrentDictionary<ulong, DateTime> userTimePair;
|
// ConcurrentDictionary<ulong, DateTime> userTimePair;
|
||||||
if (!RatelimitingChannels.TryGetValue(e.Channel.Id, out userTimePair)) return;
|
// if (!RatelimitingChannels.TryGetValue(e.Channel.Id, out userTimePair)) return;
|
||||||
DateTime lastMessageTime;
|
// DateTime lastMessageTime;
|
||||||
if (userTimePair.TryGetValue(e.User.Id, out lastMessageTime))
|
// if (userTimePair.TryGetValue(e.User.Id, out lastMessageTime))
|
||||||
{
|
// {
|
||||||
if (DateTime.Now - lastMessageTime < ratelimitTime)
|
// if (DateTime.Now - lastMessageTime < ratelimitTime)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await e.Message.Delete().ConfigureAwait(false);
|
// await e.Message.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
userTimePair.AddOrUpdate(e.User.Id, id => DateTime.Now, (id, dt) => DateTime.Now);
|
// userTimePair.AddOrUpdate(e.User.Id, id => DateTime.Now, (id, dt) => DateTime.Now);
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "slowmode")
|
// cgb.CreateCommand(Module.Prefix + "slowmode")
|
||||||
.Description($"Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds. **Needs Manage Messages Permissions.**| `{Prefix}slowmode`")
|
// .Description($"Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds. **Needs Manage Messages Permissions.**| `{Prefix}slowmode`")
|
||||||
.AddCheck(SimpleCheckers.ManageMessages())
|
// .AddCheck(SimpleCheckers.ManageMessages())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
ConcurrentDictionary<ulong, DateTime> throwaway;
|
// ConcurrentDictionary<ulong, DateTime> throwaway;
|
||||||
if (RatelimitingChannels.TryRemove(e.Channel.Id, out throwaway))
|
// if (RatelimitingChannels.TryRemove(e.Channel.Id, out throwaway))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("Slow mode disabled.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Slow mode disabled.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (RatelimitingChannels.TryAdd(e.Channel.Id, new ConcurrentDictionary<ulong, DateTime>()))
|
// if (RatelimitingChannels.TryAdd(e.Channel.Id, new ConcurrentDictionary<ulong, DateTime>()))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("Slow mode initiated. " +
|
// await imsg.Channel.SendMessageAsync("Slow mode initiated. " +
|
||||||
"Users can't send more than 1 message every 5 seconds.")
|
// "Users can't send more than 1 message every 5 seconds.")
|
||||||
.ConfigureAwait(false);
|
// .ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
@ -1,207 +1,207 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using Discord.Net;
|
//using Discord.Net;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Text;
|
//using System.Text;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
internal class SelfAssignedRolesCommand : DiscordCommand
|
// internal class SelfAssignedRolesCommand : DiscordCommand
|
||||||
{
|
// {
|
||||||
public SelfAssignedRolesCommand(DiscordModule module) : base(module) { }
|
// public SelfAssignedRolesCommand(DiscordModule module) : base(module) { }
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "asar")
|
// cgb.CreateCommand(Module.Prefix + "asar")
|
||||||
.Description("Adds a role, or list of roles separated by whitespace" +
|
// .Description("Adds a role, or list of roles separated by whitespace" +
|
||||||
$"(use quotations for multiword roles) to the list of self-assignable roles. **Needs Manage Roles Permissions.**| `{Prefix}asar Gamer`")
|
// $"(use quotations for multiword roles) to the list of self-assignable roles. **Needs Manage Roles Permissions.**| `{Prefix}asar Gamer`")
|
||||||
.Parameter("roles", ParameterType.Multiple)
|
// .Parameter("roles", ParameterType.Multiple)
|
||||||
.AddCheck(SimpleCheckers.CanManageRoles)
|
// .AddCheck(SimpleCheckers.CanManageRoles)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var msg = new StringBuilder();
|
// var msg = new StringBuilder();
|
||||||
foreach (var arg in e.Args)
|
// foreach (var arg in e.Args)
|
||||||
{
|
// {
|
||||||
var role = e.Server.FindRoles(arg.Trim()).FirstOrDefault();
|
// var role = e.Server.FindRoles(arg.Trim()).FirstOrDefault();
|
||||||
if (role == null)
|
// if (role == null)
|
||||||
msg.AppendLine($":anger:Role **{arg}** not found.");
|
// msg.AppendLine($":anger:Role **{arg}** not found.");
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
if (config.ListOfSelfAssignableRoles.Contains(role.Id))
|
// if (config.ListOfSelfAssignableRoles.Contains(role.Id))
|
||||||
{
|
// {
|
||||||
msg.AppendLine($":anger:Role **{role.Name}** is already in the list.");
|
// msg.AppendLine($":anger:Role **{role.Name}** is already in the list.");
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
config.ListOfSelfAssignableRoles.Add(role.Id);
|
// config.ListOfSelfAssignableRoles.Add(role.Id);
|
||||||
msg.AppendLine($":ok:Role **{role.Name}** added to the list.");
|
// msg.AppendLine($":ok:Role **{role.Name}** added to the list.");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "rsar")
|
// cgb.CreateCommand(Module.Prefix + "rsar")
|
||||||
.Description($"Removes a specified role from the list of self-assignable roles. | `{Prefix}rsar`")
|
// .Description($"Removes a specified role from the list of self-assignable roles. | `{Prefix}rsar`")
|
||||||
.Parameter("role", ParameterType.Unparsed)
|
// .Parameter("role", ParameterType.Unparsed)
|
||||||
.AddCheck(SimpleCheckers.CanManageRoles)
|
// .AddCheck(SimpleCheckers.CanManageRoles)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var roleName = e.GetArg("role")?.Trim();
|
// var roleName = e.GetArg("role")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(roleName))
|
// if (string.IsNullOrWhiteSpace(roleName))
|
||||||
return;
|
// return;
|
||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
// if (role == null)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
// if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
config.ListOfSelfAssignableRoles.Remove(role.Id);
|
// config.ListOfSelfAssignableRoles.Remove(role.Id);
|
||||||
await imsg.Channel.SendMessageAsync($":ok:**{role.Name}** has been removed from the list of self-assignable roles").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($":ok:**{role.Name}** has been removed from the list of self-assignable roles").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "lsar")
|
// cgb.CreateCommand(Module.Prefix + "lsar")
|
||||||
.Description($"Lists all self-assignable roles. | `{Prefix}lsar`")
|
// .Description($"Lists all self-assignable roles. | `{Prefix}lsar`")
|
||||||
.Parameter("roles", ParameterType.Multiple)
|
// .Parameter("roles", ParameterType.Multiple)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
var msg = new StringBuilder($"There are `{config.ListOfSelfAssignableRoles.Count}` self assignable roles:\n");
|
// var msg = new StringBuilder($"There are `{config.ListOfSelfAssignableRoles.Count}` self assignable roles:\n");
|
||||||
var toRemove = new HashSet<ulong>();
|
// var toRemove = new HashSet<ulong>();
|
||||||
foreach (var roleId in config.ListOfSelfAssignableRoles.OrderBy(r => r.ToString()))
|
// foreach (var roleId in config.ListOfSelfAssignableRoles.OrderBy(r => r.ToString()))
|
||||||
{
|
// {
|
||||||
var role = e.Server.GetRole(roleId);
|
// var role = e.Server.GetRole(roleId);
|
||||||
if (role == null)
|
// if (role == null)
|
||||||
{
|
// {
|
||||||
msg.Append($"`{roleId} not found. Cleaned up.`, ");
|
// msg.Append($"`{roleId} not found. Cleaned up.`, ");
|
||||||
toRemove.Add(roleId);
|
// toRemove.Add(roleId);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
msg.Append($"**{role.Name}**, ");
|
// msg.Append($"**{role.Name}**, ");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
foreach (var id in toRemove)
|
// foreach (var id in toRemove)
|
||||||
{
|
// {
|
||||||
config.ListOfSelfAssignableRoles.Remove(id);
|
// config.ListOfSelfAssignableRoles.Remove(id);
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "togglexclsar").Alias(Module.Prefix + "tesar")
|
// cgb.CreateCommand(Module.Prefix + "togglexclsar").Alias(Module.Prefix + "tesar")
|
||||||
.Description($"toggle whether the self-assigned roles should be exclusive | `{Prefix}tesar`")
|
// .Description($"toggle whether the self-assigned roles should be exclusive | `{Prefix}tesar`")
|
||||||
.AddCheck(SimpleCheckers.CanManageRoles)
|
// .AddCheck(SimpleCheckers.CanManageRoles)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles;
|
// config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles;
|
||||||
string exl = config.ExclusiveSelfAssignedRoles ? "exclusive" : "not exclusive";
|
// string exl = config.ExclusiveSelfAssignedRoles ? "exclusive" : "not exclusive";
|
||||||
await imsg.Channel.SendMessageAsync("Self assigned roles are now " + exl);
|
// await imsg.Channel.SendMessageAsync("Self assigned roles are now " + exl);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "iam")
|
// cgb.CreateCommand(Module.Prefix + "iam")
|
||||||
.Description("Adds a role to you that you choose. " +
|
// .Description("Adds a role to you that you choose. " +
|
||||||
"Role must be on a list of self-assignable roles." +
|
// "Role must be on a list of self-assignable roles." +
|
||||||
$" | `{Prefix}iam Gamer`")
|
// $" | `{Prefix}iam Gamer`")
|
||||||
.Parameter("role", ParameterType.Unparsed)
|
// .Parameter("role", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var roleName = e.GetArg("role")?.Trim();
|
// var roleName = e.GetArg("role")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(roleName))
|
// if (string.IsNullOrWhiteSpace(roleName))
|
||||||
return;
|
// return;
|
||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
// if (role == null)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
// if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (e.User.HasRole(role))
|
// if (e.User.HasRole(role))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync($":anger:You already have {role.Name} role.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($":anger:You already have {role.Name} role.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var sameRoles = e.User.Roles.Where(r => config.ListOfSelfAssignableRoles.Contains(r.Id));
|
// var sameRoles = e.User.Roles.Where(r => config.ListOfSelfAssignableRoles.Contains(r.Id));
|
||||||
if (config.ExclusiveSelfAssignedRoles && sameRoles.Any())
|
// if (config.ExclusiveSelfAssignedRoles && sameRoles.Any())
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync($":anger:You already have {sameRoles.FirstOrDefault().Name} role.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($":anger:You already have {sameRoles.FirstOrDefault().Name} role.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await e.User.AddRoles(role).ConfigureAwait(false);
|
// await e.User.AddRoles(role).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.InternalServerError)
|
// catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.InternalServerError)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync($":anger:`I am unable to add that role to you. I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($":anger:`I am unable to add that role to you. I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var msg = await imsg.Channel.SendMessageAsync($":ok:You now have {role.Name} role.").ConfigureAwait(false);
|
// var msg = await imsg.Channel.SendMessageAsync($":ok:You now have {role.Name} role.").ConfigureAwait(false);
|
||||||
await Task.Delay(3000).ConfigureAwait(false);
|
// await Task.Delay(3000).ConfigureAwait(false);
|
||||||
await msg.Delete().ConfigureAwait(false);
|
// await msg.Delete().ConfigureAwait(false);
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await e.Message.Delete().ConfigureAwait(false);
|
// await e.Message.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "iamnot")
|
// cgb.CreateCommand(Module.Prefix + "iamnot")
|
||||||
.Alias(Module.Prefix + "iamn")
|
// .Alias(Module.Prefix + "iamn")
|
||||||
.Description("Removes a role to you that you choose. " +
|
// .Description("Removes a role to you that you choose. " +
|
||||||
"Role must be on a list of self-assignable roles." +
|
// "Role must be on a list of self-assignable roles." +
|
||||||
$" | `{Prefix}iamn Gamer`")
|
// $" | `{Prefix}iamn Gamer`")
|
||||||
.Parameter("role", ParameterType.Unparsed)
|
// .Parameter("role", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var roleName = e.GetArg("role")?.Trim();
|
// var roleName = e.GetArg("role")?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(roleName))
|
// if (string.IsNullOrWhiteSpace(roleName))
|
||||||
return;
|
// return;
|
||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
// if (role == null)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
// if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (!e.User.HasRole(role))
|
// if (!e.User.HasRole(role))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync($":anger:You don't have {role.Name} role.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync($":anger:You don't have {role.Name} role.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
await e.User.RemoveRoles(role).ConfigureAwait(false);
|
// await e.User.RemoveRoles(role).ConfigureAwait(false);
|
||||||
var msg = await imsg.Channel.SendMessageAsync($":ok:Successfuly removed {role.Name} role from you.").ConfigureAwait(false);
|
// var msg = await imsg.Channel.SendMessageAsync($":ok:Successfuly removed {role.Name} role from you.").ConfigureAwait(false);
|
||||||
await Task.Delay(3000).ConfigureAwait(false);
|
// await Task.Delay(3000).ConfigureAwait(false);
|
||||||
await msg.Delete().ConfigureAwait(false);
|
// await msg.Delete().ConfigureAwait(false);
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await e.Message.Delete().ConfigureAwait(false);
|
// await e.Message.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,42 +1,42 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
class SelfCommands : DiscordCommand
|
// class SelfCommands : DiscordCommand
|
||||||
{
|
// {
|
||||||
public SelfCommands(DiscordModule module) : base(module)
|
// public SelfCommands(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "leave")
|
// cgb.CreateCommand(Module.Prefix + "leave")
|
||||||
.Description($"Makes Nadeko leave the server. Either name or id required. **Bot Owner Only!**| `{Prefix}leave 123123123331`")
|
// .Description($"Makes Nadeko leave the server. Either name or id required. **Bot Owner Only!**| `{Prefix}leave 123123123331`")
|
||||||
.Parameter("arg", ParameterType.Required)
|
// .Parameter("arg", ParameterType.Required)
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
var arg = e.GetArg("arg").Trim();
|
// var arg = e.GetArg("arg").Trim();
|
||||||
var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
|
// var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
|
||||||
NadekoBot.Client.FindServers(arg).FirstOrDefault();
|
// NadekoBot.Client.FindServers(arg).FirstOrDefault();
|
||||||
if (server == null)
|
// if (server == null)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("Cannot find that server").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Cannot find that server").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (!server.IsOwner)
|
// if (!server.IsOwner)
|
||||||
{
|
// {
|
||||||
await server.Leave().ConfigureAwait(false);
|
// await server.Leave().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
await server.Delete().ConfigureAwait(false);
|
// await server.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
await NadekoBot.SendMessageToOwner("Left server " + server.Name).ConfigureAwait(false);
|
// await NadekoBot.SendMessageToOwner("Left server " + server.Name).ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,332 +1,332 @@
|
|||||||
using Discord;
|
//using Discord;
|
||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
/* Voltana's legacy
|
///* Voltana's legacy
|
||||||
public class AsyncLazy<T> : Lazy<Task<T>>
|
//public class AsyncLazy<T> : Lazy<Task<T>>
|
||||||
{
|
//{
|
||||||
public AsyncLazy(Func<T> valueFactory) :
|
// public AsyncLazy(Func<T> valueFactory) :
|
||||||
base(() => Task.Factory.StartNew(valueFactory)) { }
|
// base(() => Task.Factory.StartNew(valueFactory)) { }
|
||||||
|
|
||||||
public AsyncLazy(Func<Task<T>> taskFactory) :
|
// public AsyncLazy(Func<Task<T>> taskFactory) :
|
||||||
base(() => Task.Factory.StartNew(() => taskFactory()).Unwrap()) { }
|
// base(() => Task.Factory.StartNew(() => taskFactory()).Unwrap()) { }
|
||||||
|
|
||||||
public TaskAwaiter<T> GetAwaiter() { return Value.GetAwaiter(); }
|
// public TaskAwaiter<T> GetAwaiter() { return Value.GetAwaiter(); }
|
||||||
}
|
//}
|
||||||
*/
|
//*/
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
internal class ServerGreetCommand : DiscordCommand
|
// internal class ServerGreetCommand : DiscordCommand
|
||||||
{
|
// {
|
||||||
|
|
||||||
public static ConcurrentDictionary<ulong, AnnounceControls> AnnouncementsDictionary;
|
// public static ConcurrentDictionary<ulong, AnnounceControls> AnnouncementsDictionary;
|
||||||
|
|
||||||
public static long Greeted = 0;
|
// public static long Greeted = 0;
|
||||||
|
|
||||||
public ServerGreetCommand(DiscordModule module) : base(module)
|
// public ServerGreetCommand(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
AnnouncementsDictionary = new ConcurrentDictionary<ulong, AnnounceControls>();
|
// AnnouncementsDictionary = new ConcurrentDictionary<ulong, AnnounceControls>();
|
||||||
|
|
||||||
NadekoBot.Client.UserJoined += UserJoined;
|
// NadekoBot.Client.UserJoined += UserJoined;
|
||||||
NadekoBot.Client.UserLeft += UserLeft;
|
// NadekoBot.Client.UserLeft += UserLeft;
|
||||||
|
|
||||||
var data = Classes.DbHandler.Instance.GetAllRows<DataModels.Announcement>();
|
// var data = Classes.DbHandler.Instance.GetAllRows<DataModels.Announcement>();
|
||||||
|
|
||||||
if (!data.Any()) return;
|
// if (!data.Any()) return;
|
||||||
foreach (var obj in data)
|
// foreach (var obj in data)
|
||||||
AnnouncementsDictionary.TryAdd((ulong)obj.ServerId, new AnnounceControls(obj));
|
// AnnouncementsDictionary.TryAdd((ulong)obj.ServerId, new AnnounceControls(obj));
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void UserLeft(object sender, UserEventArgs e)
|
// private async void UserLeft(object sender, UserEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (!AnnouncementsDictionary.ContainsKey(e.Server.Id) ||
|
// if (!AnnouncementsDictionary.ContainsKey(e.Server.Id) ||
|
||||||
!AnnouncementsDictionary[e.Server.Id].Bye) return;
|
// !AnnouncementsDictionary[e.Server.Id].Bye) return;
|
||||||
|
|
||||||
var controls = AnnouncementsDictionary[e.Server.Id];
|
// var controls = AnnouncementsDictionary[e.Server.Id];
|
||||||
var channel = NadekoBot.Client.GetChannel(controls.ByeChannel);
|
// var channel = NadekoBot.Client.GetChannel(controls.ByeChannel);
|
||||||
var msg = controls.ByeText.Replace("%user%", "**" + e.User.Name + "**").Trim();
|
// var msg = controls.ByeText.Replace("%user%", "**" + e.User.Name + "**").Trim();
|
||||||
if (string.IsNullOrEmpty(msg))
|
// if (string.IsNullOrEmpty(msg))
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
if (controls.ByePM)
|
// if (controls.ByePM)
|
||||||
{
|
// {
|
||||||
Greeted++;
|
// Greeted++;
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await e.User.SendMessage($"`Farewell Message From {e.Server?.Name}`\n" + msg).ConfigureAwait(false);
|
// await e.User.SendMessage($"`Farewell Message From {e.Server?.Name}`\n" + msg).ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
if (channel == null) return;
|
// if (channel == null) return;
|
||||||
Greeted++;
|
// Greeted++;
|
||||||
var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
// var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages)
|
// if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages)
|
||||||
{
|
// {
|
||||||
await Task.Delay(30000).ConfigureAwait(false); // 5 minutes
|
// await Task.Delay(30000).ConfigureAwait(false); // 5 minutes
|
||||||
await toDelete.Delete().ConfigureAwait(false);
|
// await toDelete.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private async void UserJoined(object sender, Discord.UserEventArgs e)
|
// private async void UserJoined(object sender, Discord.UserEventArgs e)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (!AnnouncementsDictionary.ContainsKey(e.Server.Id) ||
|
// if (!AnnouncementsDictionary.ContainsKey(e.Server.Id) ||
|
||||||
!AnnouncementsDictionary[e.Server.Id].Greet) return;
|
// !AnnouncementsDictionary[e.Server.Id].Greet) return;
|
||||||
|
|
||||||
var controls = AnnouncementsDictionary[e.Server.Id];
|
// var controls = AnnouncementsDictionary[e.Server.Id];
|
||||||
var channel = NadekoBot.Client.GetChannel(controls.GreetChannel);
|
// var channel = NadekoBot.Client.GetChannel(controls.GreetChannel);
|
||||||
|
|
||||||
var msg = controls.GreetText.Replace("%user%", e.User.Mention).Trim();
|
// var msg = controls.GreetText.Replace("%user%", e.User.Mention).Trim();
|
||||||
if (string.IsNullOrEmpty(msg))
|
// if (string.IsNullOrEmpty(msg))
|
||||||
return;
|
// return;
|
||||||
if (controls.GreetPM)
|
// if (controls.GreetPM)
|
||||||
{
|
// {
|
||||||
Greeted++;
|
// Greeted++;
|
||||||
await e.User.SendMessage($"`Welcome Message From {e.Server.Name}`\n" + msg).ConfigureAwait(false);
|
// await e.User.SendMessage($"`Welcome Message From {e.Server.Name}`\n" + msg).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
if (channel == null) return;
|
// if (channel == null) return;
|
||||||
Greeted++;
|
// Greeted++;
|
||||||
var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
// var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages)
|
// if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages)
|
||||||
{
|
// {
|
||||||
await Task.Delay(30000).ConfigureAwait(false); // 5 minutes
|
// await Task.Delay(30000).ConfigureAwait(false); // 5 minutes
|
||||||
await toDelete.Delete().ConfigureAwait(false);
|
// await toDelete.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public class AnnounceControls
|
// public class AnnounceControls
|
||||||
{
|
// {
|
||||||
private DataModels.Announcement _model { get; }
|
// private DataModels.Announcement _model { get; }
|
||||||
|
|
||||||
public bool Greet {
|
// public bool Greet {
|
||||||
get { return _model.Greet; }
|
// get { return _model.Greet; }
|
||||||
set { _model.Greet = value; Save(); }
|
// set { _model.Greet = value; Save(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public ulong GreetChannel {
|
// public ulong GreetChannel {
|
||||||
get { return (ulong)_model.GreetChannelId; }
|
// get { return (ulong)_model.GreetChannelId; }
|
||||||
set { _model.GreetChannelId = (long)value; Save(); }
|
// set { _model.GreetChannelId = (long)value; Save(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool GreetPM {
|
// public bool GreetPM {
|
||||||
get { return _model.GreetPM; }
|
// get { return _model.GreetPM; }
|
||||||
set { _model.GreetPM = value; Save(); }
|
// set { _model.GreetPM = value; Save(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool ByePM {
|
// public bool ByePM {
|
||||||
get { return _model.ByePM; }
|
// get { return _model.ByePM; }
|
||||||
set { _model.ByePM = value; Save(); }
|
// set { _model.ByePM = value; Save(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public string GreetText {
|
// public string GreetText {
|
||||||
get { return _model.GreetText; }
|
// get { return _model.GreetText; }
|
||||||
set { _model.GreetText = value; Save(); }
|
// set { _model.GreetText = value; Save(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool Bye {
|
// public bool Bye {
|
||||||
get { return _model.Bye; }
|
// get { return _model.Bye; }
|
||||||
set { _model.Bye = value; Save(); }
|
// set { _model.Bye = value; Save(); }
|
||||||
}
|
// }
|
||||||
public ulong ByeChannel {
|
// public ulong ByeChannel {
|
||||||
get { return (ulong)_model.ByeChannelId; }
|
// get { return (ulong)_model.ByeChannelId; }
|
||||||
set { _model.ByeChannelId = (long)value; Save(); }
|
// set { _model.ByeChannelId = (long)value; Save(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public string ByeText {
|
// public string ByeText {
|
||||||
get { return _model.ByeText; }
|
// get { return _model.ByeText; }
|
||||||
set { _model.ByeText = value; Save(); }
|
// set { _model.ByeText = value; Save(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public ulong ServerId {
|
// public ulong ServerId {
|
||||||
get { return (ulong)_model.ServerId; }
|
// get { return (ulong)_model.ServerId; }
|
||||||
set { _model.ServerId = (long)value; }
|
// set { _model.ServerId = (long)value; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool DeleteGreetMessages {
|
// public bool DeleteGreetMessages {
|
||||||
get {
|
// get {
|
||||||
return _model.DeleteGreetMessages;
|
// return _model.DeleteGreetMessages;
|
||||||
}
|
// }
|
||||||
set {
|
// set {
|
||||||
_model.DeleteGreetMessages = value; Save();
|
// _model.DeleteGreetMessages = value; Save();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public AnnounceControls(DataModels.Announcement model)
|
// public AnnounceControls(DataModels.Announcement model)
|
||||||
{
|
// {
|
||||||
this._model = model;
|
// this._model = model;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public AnnounceControls(ulong serverId)
|
// public AnnounceControls(ulong serverId)
|
||||||
{
|
// {
|
||||||
this._model = new DataModels.Announcement();
|
// this._model = new DataModels.Announcement();
|
||||||
ServerId = serverId;
|
// ServerId = serverId;
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal bool ToggleBye(ulong id)
|
// internal bool ToggleBye(ulong id)
|
||||||
{
|
// {
|
||||||
if (Bye)
|
// if (Bye)
|
||||||
{
|
// {
|
||||||
return Bye = false;
|
// return Bye = false;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
ByeChannel = id;
|
// ByeChannel = id;
|
||||||
return Bye = true;
|
// return Bye = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal bool ToggleGreet(ulong id)
|
// internal bool ToggleGreet(ulong id)
|
||||||
{
|
// {
|
||||||
if (Greet)
|
// if (Greet)
|
||||||
{
|
// {
|
||||||
return Greet = false;
|
// return Greet = false;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
GreetChannel = id;
|
// GreetChannel = id;
|
||||||
return Greet = true;
|
// return Greet = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal bool ToggleDelete() => DeleteGreetMessages = !DeleteGreetMessages;
|
// internal bool ToggleDelete() => DeleteGreetMessages = !DeleteGreetMessages;
|
||||||
internal bool ToggleGreetPM() => GreetPM = !GreetPM;
|
// internal bool ToggleGreetPM() => GreetPM = !GreetPM;
|
||||||
internal bool ToggleByePM() => ByePM = !ByePM;
|
// internal bool ToggleByePM() => ByePM = !ByePM;
|
||||||
|
|
||||||
private void Save()
|
// private void Save()
|
||||||
{
|
// {
|
||||||
Classes.DbHandler.Instance.Save(_model);
|
// Classes.DbHandler.Instance.Save(_model);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "grdel")
|
// cgb.CreateCommand(Module.Prefix + "grdel")
|
||||||
.Description($"Toggles automatic deletion of greet and bye messages. **Needs Manage Server Permissions.**| `{Prefix}grdel`")
|
// .Description($"Toggles automatic deletion of greet and bye messages. **Needs Manage Server Permissions.**| `{Prefix}grdel`")
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.User.ServerPermissions.ManageServer) return;
|
// if (!e.User.ServerPermissions.ManageServer) return;
|
||||||
var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
|
|
||||||
if (ann.ToggleDelete())
|
// if (ann.ToggleDelete())
|
||||||
await imsg.Channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been enabled.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been enabled.`").ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await imsg.Channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been disabled.`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been disabled.`").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "greet")
|
// cgb.CreateCommand(Module.Prefix + "greet")
|
||||||
.Description($"Toggles anouncements on the current channel when someone joins the server. **Needs Manage Server Permissions.**| `{Prefix}greet`")
|
// .Description($"Toggles anouncements on the current channel when someone joins the server. **Needs Manage Server Permissions.**| `{Prefix}greet`")
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.User.ServerPermissions.ManageServer) return;
|
// if (!e.User.ServerPermissions.ManageServer) return;
|
||||||
var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
|
|
||||||
if (ann.ToggleGreet(e.Channel.Id))
|
// if (ann.ToggleGreet(e.Channel.Id))
|
||||||
await imsg.Channel.SendMessageAsync("Greet announcements enabled on this channel.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Greet announcements enabled on this channel.").ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await imsg.Channel.SendMessageAsync("Greet announcements disabled.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Greet announcements disabled.").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "greetmsg")
|
// cgb.CreateCommand(Module.Prefix + "greetmsg")
|
||||||
.Description($"Sets a new join announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. **Needs Manage Server Permissions.**| `{Prefix}greetmsg Welcome to the server, %user%.`")
|
// .Description($"Sets a new join announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. **Needs Manage Server Permissions.**| `{Prefix}greetmsg Welcome to the server, %user%.`")
|
||||||
.Parameter("msg", ParameterType.Unparsed)
|
// .Parameter("msg", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.User.ServerPermissions.ManageServer) return;
|
// if (!e.User.ServerPermissions.ManageServer) return;
|
||||||
var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`Current greet message:` " + ann.GreetText);
|
// await imsg.Channel.SendMessageAsync("`Current greet message:` " + ann.GreetText);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
ann.GreetText = e.GetArg("msg");
|
// ann.GreetText = e.GetArg("msg");
|
||||||
await imsg.Channel.SendMessageAsync("New greet message set.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("New greet message set.").ConfigureAwait(false);
|
||||||
if (!ann.Greet)
|
// if (!ann.Greet)
|
||||||
await imsg.Channel.SendMessageAsync("Enable greet messsages by typing `.greet`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Enable greet messsages by typing `.greet`").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "bye")
|
// cgb.CreateCommand(Module.Prefix + "bye")
|
||||||
.Description($"Toggles anouncements on the current channel when someone leaves the server. | `{Prefix}bye`")
|
// .Description($"Toggles anouncements on the current channel when someone leaves the server. | `{Prefix}bye`")
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.User.ServerPermissions.ManageServer) return;
|
// if (!e.User.ServerPermissions.ManageServer) return;
|
||||||
var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
|
|
||||||
if (ann.ToggleBye(e.Channel.Id))
|
// if (ann.ToggleBye(e.Channel.Id))
|
||||||
await imsg.Channel.SendMessageAsync("Bye announcements enabled on this channel.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Bye announcements enabled on this channel.").ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await imsg.Channel.SendMessageAsync("Bye announcements disabled.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Bye announcements disabled.").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "byemsg")
|
// cgb.CreateCommand(Module.Prefix + "byemsg")
|
||||||
.Description($"Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. **Needs Manage Server Permissions.**| `{Prefix}byemsg %user% has left the server.`")
|
// .Description($"Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. **Needs Manage Server Permissions.**| `{Prefix}byemsg %user% has left the server.`")
|
||||||
.Parameter("msg", ParameterType.Unparsed)
|
// .Parameter("msg", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.User.ServerPermissions.ManageServer) return;
|
// if (!e.User.ServerPermissions.ManageServer) return;
|
||||||
var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`Current bye message:` " + ann.ByeText);
|
// await imsg.Channel.SendMessageAsync("`Current bye message:` " + ann.ByeText);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
ann.ByeText = e.GetArg("msg");
|
// ann.ByeText = e.GetArg("msg");
|
||||||
await imsg.Channel.SendMessageAsync("New bye message set.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("New bye message set.").ConfigureAwait(false);
|
||||||
if (!ann.Bye)
|
// if (!ann.Bye)
|
||||||
await imsg.Channel.SendMessageAsync("Enable bye messsages by typing `.bye`.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Enable bye messsages by typing `.bye`.").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "byepm")
|
// cgb.CreateCommand(Module.Prefix + "byepm")
|
||||||
.Description($"Toggles whether the good bye messages will be sent in a PM or in the text channel. **Needs Manage Server Permissions.**| `{Prefix}byepm`")
|
// .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 =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.User.ServerPermissions.ManageServer) return;
|
// if (!e.User.ServerPermissions.ManageServer) return;
|
||||||
var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
|
|
||||||
|
|
||||||
if (ann.ToggleByePM())
|
// if (ann.ToggleByePM())
|
||||||
await imsg.Channel.SendMessageAsync("Bye messages will be sent in a PM from now on.\n ⚠ Keep in mind this might fail if the user and the bot have no common servers after the user leaves.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Bye messages will be sent in a PM from now on.\n ⚠ Keep in mind this might fail if the user and the bot have no common servers after the user leaves.").ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await imsg.Channel.SendMessageAsync("Bye messages will be sent in a bound channel from now on.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Bye messages will be sent in a bound channel from now on.").ConfigureAwait(false);
|
||||||
if (!ann.Bye)
|
// if (!ann.Bye)
|
||||||
await imsg.Channel.SendMessageAsync("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "greetpm")
|
// cgb.CreateCommand(Module.Prefix + "greetpm")
|
||||||
.Description($"Toggles whether the greet messages will be sent in a PM or in the text channel. **Needs Manage Server Permissions.**| `{Prefix}greetpm`")
|
// .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 =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.User.ServerPermissions.ManageServer) return;
|
// if (!e.User.ServerPermissions.ManageServer) return;
|
||||||
|
|
||||||
var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
|
|
||||||
if (ann.ToggleGreetPM())
|
// if (ann.ToggleGreetPM())
|
||||||
await imsg.Channel.SendMessageAsync("Greet messages will be sent in a PM from now on.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Greet messages will be sent in a PM from now on.").ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await imsg.Channel.SendMessageAsync("Greet messages will be sent in a bound channel from now on.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Greet messages will be sent in a bound channel from now on.").ConfigureAwait(false);
|
||||||
if (!ann.Greet)
|
// if (!ann.Greet)
|
||||||
await imsg.Channel.SendMessageAsync("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`").ConfigureAwait(false);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,164 +1,164 @@
|
|||||||
using Discord;
|
//using Discord;
|
||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Extensions;
|
//using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
//using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
//using System;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
//using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using ChPermOverride = Discord.ChannelPermissionOverrides;
|
//using ChPermOverride = Discord.ChannelPermissionOverrides;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
//namespace NadekoBot.Modules.Administration.Commands
|
||||||
{
|
//{
|
||||||
internal class VoicePlusTextCommand : DiscordCommand
|
// internal class VoicePlusTextCommand : DiscordCommand
|
||||||
{
|
// {
|
||||||
Regex channelNameRegex = new Regex(@"[^a-zA-Z0-9 -]", RegexOptions.Compiled);
|
// Regex channelNameRegex = new Regex(@"[^a-zA-Z0-9 -]", RegexOptions.Compiled);
|
||||||
public VoicePlusTextCommand(DiscordModule module) : base(module)
|
// public VoicePlusTextCommand(DiscordModule module) : base(module)
|
||||||
{
|
// {
|
||||||
// changing servers may cause bugs
|
// // changing servers may cause bugs
|
||||||
NadekoBot.Client.UserUpdated += async (sender, e) =>
|
// NadekoBot.Client.UserUpdated += async (sender, e) =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (e.Server == null)
|
// if (e.Server == null)
|
||||||
return;
|
// return;
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (e.Before.VoiceChannel == e.After.VoiceChannel) return;
|
// if (e.Before.VoiceChannel == e.After.VoiceChannel) return;
|
||||||
if (!config.VoicePlusTextEnabled)
|
// if (!config.VoicePlusTextEnabled)
|
||||||
return;
|
// return;
|
||||||
var serverPerms = e.Server.GetUser(NadekoBot.Client.CurrentUser.Id)?.ServerPermissions;
|
// var serverPerms = e.Server.GetUser(NadekoBot.Client.CurrentUser.Id)?.ServerPermissions;
|
||||||
if (serverPerms == null)
|
// if (serverPerms == null)
|
||||||
return;
|
// return;
|
||||||
if (!serverPerms.Value.ManageChannels || !serverPerms.Value.ManageRoles)
|
// if (!serverPerms.Value.ManageChannels || !serverPerms.Value.ManageRoles)
|
||||||
{
|
// {
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await e.Server.Owner.SendMessage(
|
// await e.Server.Owner.SendMessage(
|
||||||
"I don't have manage server and/or Manage Channels permission," +
|
// "I don't have manage server and/or Manage Channels permission," +
|
||||||
$" so I cannot run voice+text on **{e.Server.Name}** server.").ConfigureAwait(false);
|
// $" so I cannot run voice+text on **{e.Server.Name}** server.").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { } // meh
|
// catch { } // meh
|
||||||
config.VoicePlusTextEnabled = false;
|
// config.VoicePlusTextEnabled = false;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
var beforeVch = e.Before.VoiceChannel;
|
// var beforeVch = e.Before.VoiceChannel;
|
||||||
if (beforeVch != null)
|
// if (beforeVch != null)
|
||||||
{
|
// {
|
||||||
var textChannel =
|
// var textChannel =
|
||||||
e.Server.FindChannels(GetChannelName(beforeVch.Name), ChannelType.Text).FirstOrDefault();
|
// e.Server.FindChannels(GetChannelName(beforeVch.Name), ChannelType.Text).FirstOrDefault();
|
||||||
if (textChannel != null)
|
// if (textChannel != null)
|
||||||
await textChannel.AddPermissionsRule(e.Before,
|
// await textChannel.AddPermissionsRule(e.Before,
|
||||||
new ChPermOverride(readMessages: PermValue.Deny,
|
// new ChPermOverride(readMessages: PermValue.Deny,
|
||||||
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
// sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
var afterVch = e.After.VoiceChannel;
|
// var afterVch = e.After.VoiceChannel;
|
||||||
if (afterVch != null && e.Server.AFKChannel != afterVch)
|
// if (afterVch != null && e.Server.AFKChannel != afterVch)
|
||||||
{
|
// {
|
||||||
var textChannel = e.Server.FindChannels(
|
// var textChannel = e.Server.FindChannels(
|
||||||
GetChannelName(afterVch.Name),
|
// GetChannelName(afterVch.Name),
|
||||||
ChannelType.Text)
|
// ChannelType.Text)
|
||||||
.FirstOrDefault();
|
// .FirstOrDefault();
|
||||||
if (textChannel == null)
|
// if (textChannel == null)
|
||||||
{
|
// {
|
||||||
textChannel = (await e.Server.CreateChannel(GetChannelName(afterVch.Name), ChannelType.Text).ConfigureAwait(false));
|
// textChannel = (await e.Server.CreateChannel(GetChannelName(afterVch.Name), ChannelType.Text).ConfigureAwait(false));
|
||||||
await textChannel.AddPermissionsRule(e.Server.EveryoneRole,
|
// await textChannel.AddPermissionsRule(e.Server.EveryoneRole,
|
||||||
new ChPermOverride(readMessages: PermValue.Deny,
|
// new ChPermOverride(readMessages: PermValue.Deny,
|
||||||
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
// sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
await textChannel.AddPermissionsRule(e.After,
|
// await textChannel.AddPermissionsRule(e.After,
|
||||||
new ChPermOverride(readMessages: PermValue.Allow,
|
// new ChPermOverride(readMessages: PermValue.Allow,
|
||||||
sendMessages: PermValue.Allow)).ConfigureAwait(false);
|
// sendMessages: PermValue.Allow)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
Console.WriteLine(ex);
|
// Console.WriteLine(ex);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
private string GetChannelName(string voiceName) =>
|
// private string GetChannelName(string voiceName) =>
|
||||||
channelNameRegex.Replace(voiceName, "").Trim().Replace(" ", "-").TrimTo(90, true) + "-voice";
|
// channelNameRegex.Replace(voiceName, "").Trim().Replace(" ", "-").TrimTo(90, true) + "-voice";
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "cleanv+t")
|
// cgb.CreateCommand(Module.Prefix + "cleanv+t")
|
||||||
.Alias(Module.Prefix + "cv+t")
|
// .Alias(Module.Prefix + "cv+t")
|
||||||
.Description($"Deletes all text channels ending in `-voice` for which voicechannels are not found. **Use at your own risk.\nNeeds Manage Roles and Manage Channels Permissions.** | `{Prefix}cleanv+t`")
|
// .Description($"Deletes all text channels ending in `-voice` for which voicechannels are not found. **Use at your own risk.\nNeeds Manage Roles and Manage Channels Permissions.** | `{Prefix}cleanv+t`")
|
||||||
.AddCheck(SimpleCheckers.CanManageRoles)
|
// .AddCheck(SimpleCheckers.CanManageRoles)
|
||||||
.AddCheck(SimpleCheckers.ManageChannels())
|
// .AddCheck(SimpleCheckers.ManageChannels())
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
if (!e.Server.CurrentUser.ServerPermissions.ManageChannels)
|
// if (!e.Server.CurrentUser.ServerPermissions.ManageChannels)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync("`I have insufficient permission to do that.`");
|
// await imsg.Channel.SendMessageAsync("`I have insufficient permission to do that.`");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var allTxtChannels = e.Server.TextChannels.Where(c => c.Name.EndsWith("-voice"));
|
// var allTxtChannels = e.Server.TextChannels.Where(c => c.Name.EndsWith("-voice"));
|
||||||
var validTxtChannelNames = e.Server.VoiceChannels.Select(c => GetChannelName(c.Name));
|
// var validTxtChannelNames = e.Server.VoiceChannels.Select(c => GetChannelName(c.Name));
|
||||||
|
|
||||||
var invalidTxtChannels = allTxtChannels.Where(c => !validTxtChannelNames.Contains(c.Name));
|
// var invalidTxtChannels = allTxtChannels.Where(c => !validTxtChannelNames.Contains(c.Name));
|
||||||
|
|
||||||
foreach (var c in invalidTxtChannels)
|
// foreach (var c in invalidTxtChannels)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await c.Delete();
|
// await c.Delete();
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
await Task.Delay(500);
|
// await Task.Delay(500);
|
||||||
}
|
// }
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync("`Done.`");
|
// await imsg.Channel.SendMessageAsync("`Done.`");
|
||||||
});
|
// });
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "voice+text")
|
// cgb.CreateCommand(Module.Prefix + "voice+text")
|
||||||
.Alias(Module.Prefix + "v+t")
|
// .Alias(Module.Prefix + "v+t")
|
||||||
.Description("Creates a text channel for each voice channel only users in that voice channel can see." +
|
// .Description("Creates a text channel for each voice channel only users in that voice channel can see." +
|
||||||
$"If you are server owner, keep in mind you will see them all the time regardless. **Needs Manage Roles and Manage Channels Permissions.**| `{Prefix}voice+text`")
|
// $"If you are server owner, keep in mind you will see them all the time regardless. **Needs Manage Roles and Manage Channels Permissions.**| `{Prefix}voice+text`")
|
||||||
.AddCheck(SimpleCheckers.ManageChannels())
|
// .AddCheck(SimpleCheckers.ManageChannels())
|
||||||
.AddCheck(SimpleCheckers.CanManageRoles)
|
// .AddCheck(SimpleCheckers.CanManageRoles)
|
||||||
.Do(async e =>
|
// .Do(async e =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (config.VoicePlusTextEnabled == true)
|
// if (config.VoicePlusTextEnabled == true)
|
||||||
{
|
// {
|
||||||
config.VoicePlusTextEnabled = false;
|
// config.VoicePlusTextEnabled = false;
|
||||||
foreach (var textChannel in e.Server.TextChannels.Where(c => c.Name.EndsWith("-voice")))
|
// foreach (var textChannel in e.Server.TextChannels.Where(c => c.Name.EndsWith("-voice")))
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
await textChannel.Delete().ConfigureAwait(false);
|
// await textChannel.Delete().ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(
|
// await imsg.Channel.SendMessageAsync(
|
||||||
":anger: Error: Most likely i don't have permissions to do this.")
|
// ":anger: Error: Most likely i don't have permissions to do this.")
|
||||||
.ConfigureAwait(false);
|
// .ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync("Successfuly removed voice + text feature.").ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync("Successfuly removed voice + text feature.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
config.VoicePlusTextEnabled = true;
|
// config.VoicePlusTextEnabled = true;
|
||||||
await imsg.Channel.SendMessageAsync("Successfuly enabled voice + text feature. " +
|
// await imsg.Channel.SendMessageAsync("Successfuly enabled voice + text feature. " +
|
||||||
"**Make sure the bot has manage roles and manage channels permissions**")
|
// "**Make sure the bot has manage roles and manage channels permissions**")
|
||||||
.ConfigureAwait(false);
|
// .ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync(ex.ToString()).ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(ex.ToString()).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -37,9 +37,9 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task CreateWar(IMessage imsg, int size, [Remainder] string enemyClan)
|
public async Task CreateWar(IMessage imsg, int size, [Remainder] string enemyClan = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
||||||
return;
|
return;
|
||||||
@ -70,9 +70,9 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task StartWar(IMessage imsg, [Remainder] string number)
|
public async Task StartWar(IMessage imsg, [Remainder] string number = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
int num = 0;
|
int num = 0;
|
||||||
int.TryParse(number, out num);
|
int.TryParse(number, out num);
|
||||||
@ -97,9 +97,9 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ListWar(IMessage imsg, [Remainder] string number)
|
public async Task ListWar(IMessage imsg, [Remainder] string number = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// if number is null, print all wars in a short way
|
// if number is null, print all wars in a short way
|
||||||
if (string.IsNullOrWhiteSpace(number))
|
if (string.IsNullOrWhiteSpace(number))
|
||||||
@ -140,9 +140,9 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Claim(IMessage imsg, int number, int baseNumber, [Remainder] string other_name)
|
public async Task Claim(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
var warsInfo = GetWarInfo(imsg, number);
|
var warsInfo = GetWarInfo(imsg, number);
|
||||||
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||||
{
|
{
|
||||||
@ -167,25 +167,25 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ClaimFinish1(IMessage imsg, int number, int baseNumber, [Remainder] string other_name)
|
public async Task ClaimFinish1(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
await FinishClaim(imsg, number, baseNumber, other_name, 1);
|
await FinishClaim(imsg, number, baseNumber, other_name, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ClaimFinish2(IMessage imsg, int number, int baseNumber, [Remainder] string other_name)
|
public async Task ClaimFinish2(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
await FinishClaim(imsg, number, baseNumber, other_name, 2);
|
await FinishClaim(imsg, number, baseNumber, other_name, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ClaimFinish(IMessage imsg, int number, int baseNumber, [Remainder] string other_name)
|
public async Task ClaimFinish(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
await FinishClaim(imsg, number, baseNumber, other_name);
|
await FinishClaim(imsg, number, baseNumber, other_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task EndWar(IMessage imsg, int number)
|
public async Task EndWar(IMessage imsg, int number)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var warsInfo = GetWarInfo(imsg,number);
|
var warsInfo = GetWarInfo(imsg,number);
|
||||||
if (warsInfo == null)
|
if (warsInfo == null)
|
||||||
@ -210,9 +210,9 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Unclaim(IMessage imsg, int number, [Remainder] string otherName)
|
public async Task Unclaim(IMessage imsg, int number, [Remainder] string otherName = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var warsInfo = GetWarInfo(imsg, number);
|
var warsInfo = GetWarInfo(imsg, number);
|
||||||
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||||
@ -238,7 +238,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
private async Task FinishClaim(IMessage imsg, int number, int baseNumber, [Remainder] string other_name, int stars = 3)
|
private async Task FinishClaim(IMessage imsg, int number, int baseNumber, [Remainder] string other_name, int stars = 3)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
var warInfo = GetWarInfo(imsg, number);
|
var warInfo = GetWarInfo(imsg, number);
|
||||||
if (warInfo == null || warInfo.Item1.Count == 0)
|
if (warInfo == null || warInfo.Item1.Count == 0)
|
||||||
{
|
{
|
||||||
@ -264,7 +264,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
|
|
||||||
private static Tuple<List<ClashWar>, int> GetWarInfo(IMessage imsg, int num)
|
private static Tuple<List<ClashWar>, int> GetWarInfo(IMessage imsg, int num)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
//check if there are any wars
|
//check if there are any wars
|
||||||
List<ClashWar> wars = null;
|
List<ClashWar> wars = null;
|
||||||
ClashWars.TryGetValue(channel.Guild.Id, out wars);
|
ClashWars.TryGetValue(channel.Guild.Id, out wars);
|
||||||
|
@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
{
|
{
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Leet(IMessage imsg, int level, [Remainder] string text)
|
public async Task Leet(IMessage imsg, int level, [Remainder] string text = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
text = text.Trim();
|
text = text.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
@ -18,9 +18,9 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Poll(IMessage imsg, [Remainder] string arg)
|
public async Task Poll(IMessage imsg, [Remainder] string arg = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
||||||
return;
|
return;
|
||||||
@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Pollend(IMessage imsg)
|
public async Task Pollend(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
||||||
return;
|
return;
|
||||||
|
@ -107,7 +107,7 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!(imsg.Channel is IGuildChannel && imsg.Channel is ITextChannel)) return;
|
if (!(imsg.Channel is IGuildChannel && imsg.Channel is ITextChannel)) return;
|
||||||
if ((imsg.Channel as IGuildChannel).Guild != guild) return;
|
if ((imsg.Channel as ITextChannel).Guild != guild) return;
|
||||||
if (imsg.Author.Id == (await NadekoBot.Client.GetCurrentUserAsync()).Id) return;
|
if (imsg.Author.Id == (await NadekoBot.Client.GetCurrentUserAsync()).Id) return;
|
||||||
|
|
||||||
var guildUser = imsg.Author as IGuildUser;
|
var guildUser = imsg.Author as IGuildUser;
|
||||||
|
@ -21,7 +21,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Trivia(IMessage imsg, string[] args)
|
public async Task Trivia(IMessage imsg, string[] args)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
TriviaGame trivia;
|
TriviaGame trivia;
|
||||||
if (!RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
|
if (!RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
|
||||||
@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Tl(IMessage imsg)
|
public async Task Tl(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
TriviaGame trivia;
|
TriviaGame trivia;
|
||||||
if (RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
|
if (RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
|
||||||
@ -61,7 +61,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Tq(IMessage imsg)
|
public async Task Tq(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
TriviaGame trivia;
|
TriviaGame trivia;
|
||||||
if (RunningTrivias.TryRemove(channel.Guild.Id, out trivia))
|
if (RunningTrivias.TryRemove(channel.Guild.Id, out trivia))
|
||||||
|
@ -21,9 +21,9 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Choose(IMessage imsg, [Remainder] string list)
|
public async Task Choose(IMessage imsg, [Remainder] string list = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
if (string.IsNullOrWhiteSpace(list))
|
if (string.IsNullOrWhiteSpace(list))
|
||||||
return;
|
return;
|
||||||
var listArr = list.Split(';');
|
var listArr = list.Split(';');
|
||||||
@ -35,9 +35,9 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task _8Ball(IMessage imsg, [Remainder] string question)
|
public async Task _8Ball(IMessage imsg, [Remainder] string question = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(question))
|
if (string.IsNullOrWhiteSpace(question))
|
||||||
return;
|
return;
|
||||||
@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Rps(IMessage imsg, string input)
|
public async Task Rps(IMessage imsg, string input)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
Func<int,string> GetRPSPick = (p) =>
|
Func<int,string> GetRPSPick = (p) =>
|
||||||
{
|
{
|
||||||
@ -100,7 +100,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Linux(IMessage imsg, string guhnoo, string loonix)
|
public async Task Linux(IMessage imsg, string guhnoo, string loonix)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync(
|
await imsg.Channel.SendMessageAsync(
|
||||||
$@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
|
$@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
|
||||||
|
@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Help
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Modules(IMessage imsg)
|
public async Task Modules(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync("`List of modules:` \n• " + string.Join("\n• ", _commands.Modules.Select(m => m.Name)) + $"\n`Type \"-commands module_name\" to get a list of commands in that module.`")
|
await imsg.Channel.SendMessageAsync("`List of modules:` \n• " + string.Join("\n• ", _commands.Modules.Select(m => m.Name)) + $"\n`Type \"-commands module_name\" to get a list of commands in that module.`")
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@ -36,9 +36,9 @@ namespace NadekoBot.Modules.Help
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Commands(IMessage imsg, [Remainder] string module)
|
public async Task Commands(IMessage imsg, [Remainder] string module = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
module = module?.Trim().ToUpperInvariant();
|
module = module?.Trim().ToUpperInvariant();
|
||||||
if (string.IsNullOrWhiteSpace(module))
|
if (string.IsNullOrWhiteSpace(module))
|
||||||
@ -66,9 +66,9 @@ namespace NadekoBot.Modules.Help
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Help(IMessage imsg, [Remainder] string comToFind)
|
public async Task Help(IMessage imsg, [Remainder] string comToFind = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
comToFind = comToFind?.ToLowerInvariant();
|
comToFind = comToFind?.ToLowerInvariant();
|
||||||
if (string.IsNullOrWhiteSpace(comToFind))
|
if (string.IsNullOrWhiteSpace(comToFind))
|
||||||
@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Help
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Guide(IMessage imsg)
|
public async Task Guide(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync(
|
await imsg.Channel.SendMessageAsync(
|
||||||
@"**LIST OF COMMANDS**: <http://nadekobot.readthedocs.io/en/latest/Commands%20List/>
|
@"**LIST OF COMMANDS**: <http://nadekobot.readthedocs.io/en/latest/Commands%20List/>
|
||||||
@ -127,7 +127,7 @@ namespace NadekoBot.Modules.Help
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Donate(IMessage imsg)
|
public async Task Donate(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync(
|
await imsg.Channel.SendMessageAsync(
|
||||||
$@"You can support the project on patreon. <https://patreon.com/nadekobot> or
|
$@"You can support the project on patreon. <https://patreon.com/nadekobot> or
|
||||||
|
@ -21,9 +21,9 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Hentai(IMessage imsg, [Remainder] string tag)
|
public async Task Hentai(IMessage imsg, [Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
tag = tag?.Trim() ?? "";
|
tag = tag?.Trim() ?? "";
|
||||||
|
|
||||||
@ -40,9 +40,9 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Danbooru(IMessage imsg, [Remainder] string tag)
|
public async Task Danbooru(IMessage imsg, [Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
tag = tag?.Trim() ?? "";
|
tag = tag?.Trim() ?? "";
|
||||||
var link = await GetDanbooruImageLink(tag).ConfigureAwait(false);
|
var link = await GetDanbooruImageLink(tag).ConfigureAwait(false);
|
||||||
@ -54,9 +54,9 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Gelbooru(IMessage imsg, [Remainder] string tag)
|
public async Task Gelbooru(IMessage imsg, [Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
tag = tag?.Trim() ?? "";
|
tag = tag?.Trim() ?? "";
|
||||||
var link = await GetRule34ImageLink(tag).ConfigureAwait(false);
|
var link = await GetRule34ImageLink(tag).ConfigureAwait(false);
|
||||||
@ -68,9 +68,9 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Rule34(IMessage imsg, [Remainder] string tag)
|
public async Task Rule34(IMessage imsg, [Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
tag = tag?.Trim() ?? "";
|
tag = tag?.Trim() ?? "";
|
||||||
var link = await GetGelbooruImageLink(tag).ConfigureAwait(false);
|
var link = await GetGelbooruImageLink(tag).ConfigureAwait(false);
|
||||||
@ -82,9 +82,9 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task E621(IMessage imsg, [Remainder] string tag)
|
public async Task E621(IMessage imsg, [Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
tag = tag?.Trim() ?? "";
|
tag = tag?.Trim() ?? "";
|
||||||
var link = await GetE621ImageLink(tag).ConfigureAwait(false);
|
var link = await GetE621ImageLink(tag).ConfigureAwait(false);
|
||||||
@ -98,7 +98,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Cp(IMessage imsg)
|
public async Task Cp(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Boobs(IMessage imsg)
|
public async Task Boobs(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JToken obj;
|
JToken obj;
|
||||||
@ -127,7 +127,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Butts(IMessage imsg)
|
public async Task Butts(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Poke(IMessage imsg)
|
public async Task Poke(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
// {
|
// {
|
||||||
// [LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
// [LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
// [RequireContext(ContextType.Guild)]
|
// [RequireContext(ContextType.Guild)]
|
||||||
// public async Task Anime(IMessage imsg, [Remainder] string query)
|
// public async Task Anime(IMessage imsg, [Remainder] string query = null)
|
||||||
// {
|
// {
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
// if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||||
// string result;
|
// string result;
|
||||||
@ -34,9 +34,9 @@
|
|||||||
|
|
||||||
// [LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
// [LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
// [RequireContext(ContextType.Guild)]
|
// [RequireContext(ContextType.Guild)]
|
||||||
// public async Task Manga(IMessage imsg, [Remainder] string query)
|
// public async Task Manga(IMessage imsg, [Remainder] string query = null)
|
||||||
// {
|
// {
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
// if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||||
// string result;
|
// string result;
|
||||||
|
@ -71,7 +71,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB
|
|||||||
mov.Status = true;
|
mov.Status = true;
|
||||||
mov.Title = match(@"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
|
mov.Title = match(@"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
|
||||||
mov.OriginalTitle = match(@"title-extra"">(.*?)<", html);
|
mov.OriginalTitle = match(@"title-extra"">(.*?)<", html);
|
||||||
mov.Year = match(@"<title>.*?\(.*?(\d{4}).*?\).*?</title>", match(@"(<title>.*?</title>)", html));
|
mov.Year = match(@"<title>.*?\(.*?(\d{4}).*?).*?</title>", match(@"(<title>.*?</title>)", html));
|
||||||
mov.Rating = match(@"<b>(\d.\d)/10</b>", html);
|
mov.Rating = match(@"<b>(\d.\d)/10</b>", html);
|
||||||
mov.Genres = MatchAll(@"<a.*?>(.*?)</a>", match(@"Genre.?:(.*?)(</div>|See more)", html)).Cast<string>().ToList();
|
mov.Genres = MatchAll(@"<a.*?>(.*?)</a>", match(@"Genre.?:(.*?)(</div>|See more)", html)).Cast<string>().ToList();
|
||||||
mov.Plot = match(@"Plot:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
|
mov.Plot = match(@"Plot:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
|
||||||
|
@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Yomama(IMessage imsg)
|
public async Task Yomama(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
var response = await http.GetStringAsync("http://api.yomomma.info/").ConfigureAwait(false);
|
var response = await http.GetStringAsync("http://api.yomomma.info/").ConfigureAwait(false);
|
||||||
@ -44,7 +44,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Randjoke(IMessage imsg)
|
public async Task Randjoke(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
var response = await http.GetStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
|
var response = await http.GetStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
|
||||||
@ -56,7 +56,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ChuckNorris(IMessage imsg)
|
public async Task ChuckNorris(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
var response = await http.GetStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
|
var response = await http.GetStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
|
||||||
@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task WowJoke(IMessage imsg)
|
public async Task WowJoke(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!wowJokes.Any())
|
if (!wowJokes.Any())
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task MagicItem(IMessage imsg)
|
public async Task MagicItem(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
var rng = new Random();
|
var rng = new Random();
|
||||||
var item = magicItems[rng.Next(0, magicItems.Count)].ToString();
|
var item = magicItems[rng.Next(0, magicItems.Count)].ToString();
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Memelist(IMessage imsg)
|
public async Task Memelist(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
var data = JsonConvert.DeserializeObject<Dictionary<string, string>>(await http.GetStringAsync("http://memegen.link/templates/"))
|
var data = JsonConvert.DeserializeObject<Dictionary<string, string>>(await http.GetStringAsync("http://memegen.link/templates/"))
|
||||||
@ -37,7 +37,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Memegen(IMessage imsg, string meme, string topText, string botText)
|
public async Task Memegen(IMessage imsg, string meme, string topText, string botText)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var top = Uri.EscapeDataString(topText.Replace(' ', '-'));
|
var top = Uri.EscapeDataString(topText.Replace(' ', '-'));
|
||||||
var bot = Uri.EscapeDataString(botText.Replace(' ', '-'));
|
var bot = Uri.EscapeDataString(botText.Replace(' ', '-'));
|
||||||
|
@ -26,9 +26,9 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Pokemon(IMessage imsg, [Remainder] string pokemon)
|
public async Task Pokemon(IMessage imsg, [Remainder] string pokemon = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
pokemon = pokemon?.Trim().ToUpperInvariant();
|
pokemon = pokemon?.Trim().ToUpperInvariant();
|
||||||
if (string.IsNullOrWhiteSpace(pokemon))
|
if (string.IsNullOrWhiteSpace(pokemon))
|
||||||
@ -47,9 +47,9 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task PokemonAbility(IMessage imsg, [Remainder] string ability)
|
public async Task PokemonAbility(IMessage imsg, [Remainder] string ability = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
ability = ability?.Trim().ToUpperInvariant().Replace(" ", "");
|
ability = ability?.Trim().ToUpperInvariant().Replace(" ", "");
|
||||||
if (string.IsNullOrWhiteSpace(ability))
|
if (string.IsNullOrWhiteSpace(ability))
|
||||||
|
@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Weather(IMessage imsg, string city, string country)
|
public async Task Weather(IMessage imsg, string city, string country)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
city = city.Replace(" ", "");
|
city = city.Replace(" ", "");
|
||||||
country = city.Replace(" ", "");
|
country = city.Replace(" ", "");
|
||||||
string response;
|
string response;
|
||||||
@ -52,9 +52,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Youtube(IMessage imsg, [Remainder] string query)
|
public async Task Youtube(IMessage imsg, [Remainder] string query = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||||
var result = (await _yt.FindVideosByKeywordsAsync(query, 1)).FirstOrDefault();
|
var result = (await _yt.FindVideosByKeywordsAsync(query, 1)).FirstOrDefault();
|
||||||
if (string.IsNullOrWhiteSpace(result))
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
@ -68,9 +68,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Imdb(IMessage imsg, [Remainder] string query)
|
public async Task Imdb(IMessage imsg, [Remainder] string query = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||||
await imsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
await imsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||||
@ -94,7 +94,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task RandomCat(IMessage imsg)
|
public async Task RandomCat(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
await imsg.Channel.SendMessageAsync(JObject.Parse(
|
await imsg.Channel.SendMessageAsync(JObject.Parse(
|
||||||
@ -107,7 +107,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task RandomDog(IMessage imsg)
|
public async Task RandomDog(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
await imsg.Channel.SendMessageAsync("http://random.dog/" + await http.GetStringAsync("http://random.dog/woof").ConfigureAwait(false)).ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("http://random.dog/" + await http.GetStringAsync("http://random.dog/woof").ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
@ -116,9 +116,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task I(IMessage imsg, [Remainder] string query)
|
public async Task I(IMessage imsg, [Remainder] string query = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
return;
|
return;
|
||||||
@ -146,9 +146,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Ir(IMessage imsg, [Remainder] string query)
|
public async Task Ir(IMessage imsg, [Remainder] string query = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
return;
|
return;
|
||||||
@ -177,9 +177,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Lmgtfy(IMessage imsg, [Remainder] string ffs)
|
public async Task Lmgtfy(IMessage imsg, [Remainder] string ffs = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(ffs))
|
if (string.IsNullOrWhiteSpace(ffs))
|
||||||
@ -191,9 +191,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Google(IMessage imsg, [Remainder] string terms)
|
public async Task Google(IMessage imsg, [Remainder] string terms = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
|
|
||||||
terms = terms?.Trim();
|
terms = terms?.Trim();
|
||||||
@ -205,9 +205,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
////todo drawing
|
////todo drawing
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Hearthstone(IMessage imsg, [Remainder] string name)
|
//public async Task Hearthstone(IMessage imsg, [Remainder] string name = null)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
// var arg = e.GetArg("name");
|
// var arg = e.GetArg("name");
|
||||||
// if (string.IsNullOrWhiteSpace(arg))
|
// if (string.IsNullOrWhiteSpace(arg))
|
||||||
// {
|
// {
|
||||||
@ -250,9 +250,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task UrbanDictionary(IMessage imsg, [Remainder] string query)
|
public async Task UrbanDictionary(IMessage imsg, [Remainder] string query = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var arg = query;
|
var arg = query;
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
@ -284,9 +284,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Hashtag(IMessage imsg, [Remainder] string query)
|
public async Task Hashtag(IMessage imsg, [Remainder] string query = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var arg = query;
|
var arg = query;
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
@ -321,7 +321,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Quote(IMessage imsg)
|
//public async Task Quote(IMessage imsg)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// var quote = NadekoBot.Config.Quotes[rng.Next(0, NadekoBot.Config.Quotes.Count)].ToString();
|
// var quote = NadekoBot.Config.Quotes[rng.Next(0, NadekoBot.Config.Quotes.Count)].ToString();
|
||||||
// await imsg.Channel.SendMessageAsync(quote).ConfigureAwait(false);
|
// await imsg.Channel.SendMessageAsync(quote).ConfigureAwait(false);
|
||||||
@ -331,7 +331,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Catfact(IMessage imsg)
|
public async Task Catfact(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
var response = await http.GetStringAsync("http://catfacts-api.appspot.com/api/facts").ConfigureAwait(false);
|
var response = await http.GetStringAsync("http://catfacts-api.appspot.com/api/facts").ConfigureAwait(false);
|
||||||
@ -343,9 +343,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Revav(IMessage imsg, [Remainder] string arg)
|
public async Task Revav(IMessage imsg, [Remainder] string arg = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
var usrStr = arg?.Trim().ToUpperInvariant();
|
var usrStr = arg?.Trim().ToUpperInvariant();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(usrStr))
|
if (string.IsNullOrWhiteSpace(usrStr))
|
||||||
@ -360,9 +360,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Revimg(IMessage imsg, [Remainder] string imageLink)
|
public async Task Revimg(IMessage imsg, [Remainder] string imageLink = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
imageLink = imageLink?.Trim() ?? "";
|
imageLink = imageLink?.Trim() ?? "";
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(imageLink))
|
if (string.IsNullOrWhiteSpace(imageLink))
|
||||||
@ -372,9 +372,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Safebooru(IMessage imsg, [Remainder] string tag)
|
public async Task Safebooru(IMessage imsg, [Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
tag = tag?.Trim() ?? "";
|
tag = tag?.Trim() ?? "";
|
||||||
var link = await GetSafebooruImageLink(tag).ConfigureAwait(false);
|
var link = await GetSafebooruImageLink(tag).ConfigureAwait(false);
|
||||||
@ -386,9 +386,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Wiki(IMessage imsg, [Remainder] string query)
|
public async Task Wiki(IMessage imsg, [Remainder] string query = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
query = query?.Trim();
|
query = query?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
@ -407,9 +407,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
////todo drawing
|
////todo drawing
|
||||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
//[RequireContext(ContextType.Guild)]
|
//[RequireContext(ContextType.Guild)]
|
||||||
//public async Task Clr(IMessage imsg, [Remainder] string color)
|
//public async Task Clr(IMessage imsg, [Remainder] string color = null)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as IGuildChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// color = color?.Trim().Replace("#", "");
|
// color = color?.Trim().Replace("#", "");
|
||||||
// if (string.IsNullOrWhiteSpace((string)color))
|
// if (string.IsNullOrWhiteSpace((string)color))
|
||||||
@ -432,9 +432,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Videocall(IMessage imsg, [Remainder] string arg)
|
public async Task Videocall(IMessage imsg, [Remainder] string arg = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -455,9 +455,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Avatar(IMessage imsg, [Remainder] string mention)
|
public async Task Avatar(IMessage imsg, [Remainder] string mention = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
var usr = imsg.MentionedUsers.FirstOrDefault();
|
var usr = imsg.MentionedUsers.FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
|
@ -17,9 +17,9 @@ namespace NadekoBot.Modules.Translator
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Translate(IMessage imsg, string langs, [Remainder] string text)
|
public async Task Translate(IMessage imsg, string langs, [Remainder] string text = null)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Translator
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Translangs(IMessage imsg)
|
public async Task Translangs(IMessage imsg)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
await imsg.Channel.SendTableAsync(GoogleTranslator.Instance.Languages, str => str, columns: 4);
|
await imsg.Channel.SendTableAsync(GoogleTranslator.Instance.Languages, str => str, columns: 4);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ServerInfo(IMessage msg, string guild = null)
|
public async Task ServerInfo(IMessage msg, string guild = null)
|
||||||
{
|
{
|
||||||
var channel = msg.Channel as IGuildChannel;
|
var channel = msg.Channel as ITextChannel;
|
||||||
guild = guild?.ToUpperInvariant();
|
guild = guild?.ToUpperInvariant();
|
||||||
IGuild server;
|
IGuild server;
|
||||||
if (guild == null)
|
if (guild == null)
|
||||||
@ -66,7 +66,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task UserInfo(IMessage msg, IGuildUser usr = null)
|
public async Task UserInfo(IMessage msg, IGuildUser usr = null)
|
||||||
{
|
{
|
||||||
var channel = msg.Channel as IGuildChannel;
|
var channel = msg.Channel as ITextChannel;
|
||||||
var user = usr ?? msg.Author as IGuildUser;
|
var user = usr ?? msg.Author as IGuildUser;
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return;
|
return;
|
||||||
|
@ -24,7 +24,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task WhoPlays(IMessage imsg, [Remainder] string game)
|
public async Task WhoPlays(IMessage imsg, [Remainder] string game = null)
|
||||||
{
|
{
|
||||||
var chnl = (IGuildChannel)imsg.Channel;
|
var chnl = (IGuildChannel)imsg.Channel;
|
||||||
game = game.Trim().ToUpperInvariant();
|
game = game.Trim().ToUpperInvariant();
|
||||||
@ -44,11 +44,11 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task InRole(IMessage imsg, [Remainder] string roles)
|
public async Task InRole(IMessage imsg, [Remainder] string roles = null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(roles))
|
if (string.IsNullOrWhiteSpace(roles))
|
||||||
return;
|
return;
|
||||||
var channel = imsg.Channel as IGuildChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
var arg = roles.Split(',').Select(r => r.Trim().ToUpperInvariant());
|
var arg = roles.Split(',').Select(r => r.Trim().ToUpperInvariant());
|
||||||
string send = _l["`Here is a list of users in a specfic role:`"];
|
string send = _l["`Here is a list of users in a specfic role:`"];
|
||||||
foreach (var roleStr in arg.Where(str => !string.IsNullOrWhiteSpace(str) && str != "@EVERYONE" && str != "EVERYONE"))
|
foreach (var roleStr in arg.Where(str => !string.IsNullOrWhiteSpace(str) && str != "@EVERYONE" && str != "EVERYONE"))
|
||||||
@ -110,21 +110,21 @@ namespace NadekoBot.Modules.Utility
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ServerId(IMessage msg)
|
public async Task ServerId(IMessage msg)
|
||||||
{
|
{
|
||||||
await msg.Reply($"This server's ID is {(msg.Channel as IGuildChannel).Guild.Id}");
|
await msg.Reply($"This server's ID is {(msg.Channel as ITextChannel).Guild.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Roles(IMessage msg, IGuildUser target = null)
|
public async Task Roles(IMessage msg, IGuildUser target = null)
|
||||||
{
|
{
|
||||||
var guild = (msg.Channel as IGuildChannel).Guild;
|
var guild = (msg.Channel as ITextChannel).Guild;
|
||||||
if (target != null)
|
if (target != null)
|
||||||
{
|
{
|
||||||
await msg.Reply($"`List of roles for **{target.Username}**:` \n• " + string.Join("\n• ", target.Roles.Except(new[] { guild.EveryoneRole })));
|
await msg.Reply($"`List of roles for **{target.Username}**:` \n• " + string.Join("\n• ", target.Roles.Except(new[] { guild.EveryoneRole })));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await msg.Reply("`List of roles:` \n• " + string.Join("\n• ", (msg.Channel as IGuildChannel).Guild.Roles.Except(new[] { guild.EveryoneRole })));
|
await msg.Reply("`List of roles:` \n• " + string.Join("\n• ", (msg.Channel as ITextChannel).Guild.Roles.Except(new[] { guild.EveryoneRole })));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace NadekoBot
|
|||||||
private async Task Client_MessageReceived(IMessage arg)
|
private async Task Client_MessageReceived(IMessage arg)
|
||||||
{
|
{
|
||||||
var t = await Commands.Execute(arg, 0);
|
var t = await Commands.Execute(arg, 0);
|
||||||
if(!t.IsSuccess)
|
if(!t.IsSuccess && t.Error != CommandError.UnknownCommand)
|
||||||
Console.WriteLine(t.ErrorReason);
|
Console.WriteLine(t.ErrorReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace NadekoBot.Services.Impl
|
namespace NadekoBot.Services.Impl
|
||||||
{
|
{
|
||||||
|
//todo load creds
|
||||||
public class BotCredentials : IBotCredentials
|
public class BotCredentials : IBotCredentials
|
||||||
{
|
{
|
||||||
public string ClientId { get; }
|
public string ClientId { get; }
|
||||||
|
|
||||||
public string GoogleApiKey {
|
public string GoogleApiKey {
|
||||||
get {
|
get {
|
||||||
throw new NotImplementedException();
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ namespace NadekoBot.Services.Impl
|
|||||||
|
|
||||||
public string Token {
|
public string Token {
|
||||||
get {
|
get {
|
||||||
throw new NotImplementedException();
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,25 @@ namespace NadekoBot.Extensions
|
|||||||
{
|
{
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
public static async Task<IMessage> Reply(this IMessage msg, string content) => await msg.Channel.SendMessageAsync(content);
|
public static async Task<IMessage> SendMessageAsync(this IGuildUser user, string message, bool isTTS = false) =>
|
||||||
|
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(message, isTTS).ConfigureAwait(false);
|
||||||
|
|
||||||
|
public static async Task<IMessage> SendFileAsync(this IGuildUser user, string filePath, string caption = null, bool isTTS = false) =>
|
||||||
|
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, caption, isTTS).ConfigureAwait(false);
|
||||||
|
|
||||||
|
public static async Task<IMessage> SendFileAsync(this IGuildUser user, Stream fileStream, string fileName, string caption = null, bool isTTS = false) =>
|
||||||
|
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(fileStream, fileName, caption, isTTS).ConfigureAwait(false);
|
||||||
|
|
||||||
|
public static async Task<IMessage> Reply(this IMessage msg, string content) =>
|
||||||
|
await msg.Channel.SendMessageAsync(content).ConfigureAwait(false);
|
||||||
|
|
||||||
|
public static async Task<IEnumerable<IUser>> Members(this IRole role) =>
|
||||||
|
await role.Members();
|
||||||
|
|
||||||
public static async Task<IMessage[]> ReplyLong(this IMessage msg, string content, string breakOn = "\n", string addToEnd = "", string addToStart = "")
|
public static async Task<IMessage[]> ReplyLong(this IMessage msg, string content, string breakOn = "\n", string addToEnd = "", string addToStart = "")
|
||||||
{
|
{
|
||||||
|
|
||||||
if (content.Length < 2000) return new[] { await msg.Channel.SendMessageAsync(content) };
|
if (content.Length < 2000) return new[] { await msg.Channel.SendMessageAsync(content).ConfigureAwait(false) };
|
||||||
var list = new List<IMessage>();
|
var list = new List<IMessage>();
|
||||||
|
|
||||||
var temp = Regex.Split(content, breakOn).Select(x => x += breakOn).ToList();
|
var temp = Regex.Split(content, breakOn).Select(x => x += breakOn).ToList();
|
||||||
@ -204,6 +217,17 @@ namespace NadekoBot.Extensions
|
|||||||
return d[n, m];
|
return d[n, m];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<Stream> ToStream(this string str)
|
||||||
|
{
|
||||||
|
var ms = new MemoryStream();
|
||||||
|
var sw = new StreamWriter(ms);
|
||||||
|
await sw.WriteAsync(str);
|
||||||
|
await sw.FlushAsync();
|
||||||
|
ms.Position = 0;
|
||||||
|
return ms;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static int KiB(this int value) => value * 1024;
|
public static int KiB(this int value) => value * 1024;
|
||||||
public static int KB(this int value) => value * 1000;
|
public static int KB(this int value) => value * 1000;
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@
|
|||||||
"Microsoft.NETCore.Jit/1.0.2": {
|
"Microsoft.NETCore.Jit/1.0.2": {
|
||||||
"type": "package"
|
"type": "package"
|
||||||
},
|
},
|
||||||
"Microsoft.NETCore.Platforms/1.0.2-beta-24410-01": {
|
"Microsoft.NETCore.Platforms/1.0.1": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"compile": {
|
"compile": {
|
||||||
"lib/netstandard1.0/_._": {}
|
"lib/netstandard1.0/_._": {}
|
||||||
@ -1353,11 +1353,7 @@
|
|||||||
"ref/netstandard1.3/System.Net.Security.dll": {}
|
"ref/netstandard1.3/System.Net.Security.dll": {}
|
||||||
},
|
},
|
||||||
"runtimeTargets": {
|
"runtimeTargets": {
|
||||||
"runtimes/unix/lib/netstandard1.6/System.Net.Security.dll": {
|
"runtimes/win/lib/netstandard1.3/_._": {
|
||||||
"assetType": "runtime",
|
|
||||||
"rid": "unix"
|
|
||||||
},
|
|
||||||
"runtimes/win/lib/netstandard1.3/System.Net.Security.dll": {
|
|
||||||
"assetType": "runtime",
|
"assetType": "runtime",
|
||||||
"rid": "win"
|
"rid": "win"
|
||||||
}
|
}
|
||||||
@ -1407,20 +1403,16 @@
|
|||||||
"lib/netstandard1.3/System.Net.WebSockets.dll": {}
|
"lib/netstandard1.3/System.Net.WebSockets.dll": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"System.Net.WebSockets.Client/4.0.1-beta-24410-01": {
|
"System.Net.WebSockets.Client/4.0.0": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Platforms": "1.0.2-beta-24410-01",
|
"Microsoft.NETCore.Platforms": "1.0.1",
|
||||||
"Microsoft.Win32.Primitives": "4.0.1",
|
"Microsoft.Win32.Primitives": "4.0.1",
|
||||||
"System.Collections": "4.0.11",
|
"System.Collections": "4.0.11",
|
||||||
"System.Diagnostics.Debug": "4.0.11",
|
"System.Diagnostics.Debug": "4.0.11",
|
||||||
"System.Diagnostics.Tracing": "4.1.0",
|
"System.Diagnostics.Tracing": "4.1.0",
|
||||||
"System.Globalization": "4.0.11",
|
"System.Globalization": "4.0.11",
|
||||||
"System.IO": "4.1.0",
|
|
||||||
"System.Net.NameResolution": "4.0.0",
|
|
||||||
"System.Net.Primitives": "4.0.11",
|
"System.Net.Primitives": "4.0.11",
|
||||||
"System.Net.Security": "4.0.0",
|
|
||||||
"System.Net.Sockets": "4.1.0",
|
|
||||||
"System.Net.WebHeaderCollection": "4.0.1",
|
"System.Net.WebHeaderCollection": "4.0.1",
|
||||||
"System.Net.WebSockets": "4.0.0",
|
"System.Net.WebSockets": "4.0.0",
|
||||||
"System.Resources.ResourceManager": "4.0.1",
|
"System.Resources.ResourceManager": "4.0.1",
|
||||||
@ -1428,14 +1420,10 @@
|
|||||||
"System.Runtime.Extensions": "4.1.0",
|
"System.Runtime.Extensions": "4.1.0",
|
||||||
"System.Runtime.Handles": "4.0.1",
|
"System.Runtime.Handles": "4.0.1",
|
||||||
"System.Runtime.InteropServices": "4.1.0",
|
"System.Runtime.InteropServices": "4.1.0",
|
||||||
"System.Security.Cryptography.Algorithms": "4.2.0",
|
|
||||||
"System.Security.Cryptography.Primitives": "4.0.0",
|
|
||||||
"System.Security.Cryptography.X509Certificates": "4.1.0",
|
"System.Security.Cryptography.X509Certificates": "4.1.0",
|
||||||
"System.Text.Encoding": "4.0.11",
|
"System.Text.Encoding": "4.0.11",
|
||||||
"System.Text.Encoding.Extensions": "4.0.11",
|
|
||||||
"System.Threading": "4.0.11",
|
"System.Threading": "4.0.11",
|
||||||
"System.Threading.Tasks": "4.0.11",
|
"System.Threading.Tasks": "4.0.11"
|
||||||
"System.Threading.Timer": "4.0.1"
|
|
||||||
},
|
},
|
||||||
"compile": {
|
"compile": {
|
||||||
"ref/netstandard1.3/System.Net.WebSockets.Client.dll": {}
|
"ref/netstandard1.3/System.Net.WebSockets.Client.dll": {}
|
||||||
@ -2374,7 +2362,7 @@
|
|||||||
"System.Net.Http": "4.1.0",
|
"System.Net.Http": "4.1.0",
|
||||||
"System.Net.NameResolution": "4.0.0",
|
"System.Net.NameResolution": "4.0.0",
|
||||||
"System.Net.Sockets": "4.1.0",
|
"System.Net.Sockets": "4.1.0",
|
||||||
"System.Net.WebSockets.Client": "4.0.1-beta-24410-01",
|
"System.Net.WebSockets.Client": "4.0.0",
|
||||||
"System.Reflection.Extensions": "4.0.1",
|
"System.Reflection.Extensions": "4.0.1",
|
||||||
"System.Runtime.InteropServices": "4.1.0",
|
"System.Runtime.InteropServices": "4.1.0",
|
||||||
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
|
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
|
||||||
@ -2758,12 +2746,12 @@
|
|||||||
"runtime.json"
|
"runtime.json"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Microsoft.NETCore.Platforms/1.0.2-beta-24410-01": {
|
"Microsoft.NETCore.Platforms/1.0.1": {
|
||||||
"sha512": "uc/pGYdE4sVy3OovFF8hg79MvCxptzICxn0jdA6WusGWZa7VieqFoZYc+a6bHUVhMI0s/7SfBriux0RUq+PpbA==",
|
"sha512": "2G6OjjJzwBfNOO8myRV/nFrbTw5iA+DEm0N+qUqhrOmaVtn4pC77h38I1jsXGw5VH55+dPfQsqHD0We9sCl9FQ==",
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"path": "Microsoft.NETCore.Platforms/1.0.2-beta-24410-01",
|
"path": "Microsoft.NETCore.Platforms/1.0.1",
|
||||||
"files": [
|
"files": [
|
||||||
"Microsoft.NETCore.Platforms.1.0.2-beta-24410-01.nupkg.sha512",
|
"Microsoft.NETCore.Platforms.1.0.1.nupkg.sha512",
|
||||||
"Microsoft.NETCore.Platforms.nuspec",
|
"Microsoft.NETCore.Platforms.nuspec",
|
||||||
"ThirdPartyNotices.txt",
|
"ThirdPartyNotices.txt",
|
||||||
"dotnet_library_license.txt",
|
"dotnet_library_license.txt",
|
||||||
@ -5109,12 +5097,12 @@
|
|||||||
"ref/xamarinwatchos10/_._"
|
"ref/xamarinwatchos10/_._"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"System.Net.WebSockets.Client/4.0.1-beta-24410-01": {
|
"System.Net.WebSockets.Client/4.0.0": {
|
||||||
"sha512": "IOqAcR7k+3LwNI6aL7qN61HcCOA9X4MM9LbrZhDeNbeB/IeWTk7zpeb7kh3d7H678s7ndIqN6a7okO8dAAfcYQ==",
|
"sha512": "GY5h9cn0ZVsG4ORQqMytTldrqxet2RC2CSEsgWGf4XNW5jhL5SxzcUZph03xbZsgn7K3qMr+Rq+gkbJNI+FEXg==",
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"path": "System.Net.WebSockets.Client/4.0.1-beta-24410-01",
|
"path": "System.Net.WebSockets.Client/4.0.0",
|
||||||
"files": [
|
"files": [
|
||||||
"System.Net.WebSockets.Client.4.0.1-beta-24410-01.nupkg.sha512",
|
"System.Net.WebSockets.Client.4.0.0.nupkg.sha512",
|
||||||
"System.Net.WebSockets.Client.nuspec",
|
"System.Net.WebSockets.Client.nuspec",
|
||||||
"ThirdPartyNotices.txt",
|
"ThirdPartyNotices.txt",
|
||||||
"dotnet_library_license.txt",
|
"dotnet_library_license.txt",
|
||||||
|
Loading…
Reference in New Issue
Block a user