more work!
This commit is contained in:
parent
fc4ee94c3a
commit
ed505a7809
@ -12,13 +12,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NadekoBot", "src\NadekoBot\NadekoBot.xproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NadekoBot", "src\NadekoBot\NadekoBot.xproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.WebSocket", "Discord.Net\src\Discord.Net.WebSocket\Discord.Net.WebSocket.xproj", "{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net", "discord.net\src\Discord.Net\Discord.Net.xproj", "{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.Commands", "discord.net\src\Discord.Net.Commands\Discord.Net.Commands.xproj", "{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.Core", "Discord.Net\src\Discord.Net.Core\Discord.Net.Core.xproj", "{E5F4786F-58F3-469E-8C87-1908A95436B7}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.Core", "Discord.Net\src\Discord.Net.Core\Discord.Net.Core.xproj", "{E5F4786F-58F3-469E-8C87-1908A95436B7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.Rest", "Discord.Net\src\Discord.Net.Rest\Discord.Net.Rest.xproj", "{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.Rest", "Discord.Net\src\Discord.Net.Rest\Discord.Net.Rest.xproj", "{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.Commands", "Discord.Net\src\Discord.Net.Commands\Discord.Net.Commands.xproj", "{8CBA56CD-A954-481E-8358-F36273757A6B}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.Rpc", "discord.net\src\Discord.Net.Rpc\Discord.Net.Rpc.xproj", "{0E741C78-869B-4E05-A300-0C5B32F07734}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net.WebSocket", "Discord.Net\src\Discord.Net.WebSocket\Discord.Net.WebSocket.xproj", "{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -33,12 +37,18 @@ Global
|
|||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.GlobalNadeko|Any CPU.Build.0 = GlobalNadeko|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.GlobalNadeko|Any CPU.Build.0 = GlobalNadeko|Any CPU
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.Build.0 = Release|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.GlobalNadeko|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.GlobalNadeko|Any CPU.Build.0 = Release|Any CPU
|
||||||
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.GlobalNadeko|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.GlobalNadeko|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{E5F4786F-58F3-469E-8C87-1908A95436B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{E5F4786F-58F3-469E-8C87-1908A95436B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{E5F4786F-58F3-469E-8C87-1908A95436B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E5F4786F-58F3-469E-8C87-1908A95436B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E5F4786F-58F3-469E-8C87-1908A95436B7}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
{E5F4786F-58F3-469E-8C87-1908A95436B7}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
@ -51,12 +61,18 @@ Global
|
|||||||
{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}.Release|Any CPU.Build.0 = Release|Any CPU
|
{63F5B5C8-56FE-4B53-8003-B58CEB451EF9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{8CBA56CD-A954-481E-8358-F36273757A6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0E741C78-869B-4E05-A300-0C5B32F07734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{8CBA56CD-A954-481E-8358-F36273757A6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0E741C78-869B-4E05-A300-0C5B32F07734}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{8CBA56CD-A954-481E-8358-F36273757A6B}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
{0E741C78-869B-4E05-A300-0C5B32F07734}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{8CBA56CD-A954-481E-8358-F36273757A6B}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{0E741C78-869B-4E05-A300-0C5B32F07734}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{8CBA56CD-A954-481E-8358-F36273757A6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0E741C78-869B-4E05-A300-0C5B32F07734}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{8CBA56CD-A954-481E-8358-F36273757A6B}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0E741C78-869B-4E05-A300-0C5B32F07734}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E9800F7A-3354-41B1-BDBB-2D59F8124EC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -25,6 +25,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
private static ConcurrentDictionary<ulong, string> GuildMuteRoles { get; } = new ConcurrentDictionary<ulong, string>();
|
private static ConcurrentDictionary<ulong, string> GuildMuteRoles { get; } = new ConcurrentDictionary<ulong, string>();
|
||||||
|
|
||||||
|
private static ConcurrentHashSet<ulong> DeleteMessagesOnCommand { get; } = new ConcurrentHashSet<ulong>();
|
||||||
|
|
||||||
private new static Logger _log { get; }
|
private new static Logger _log { get; }
|
||||||
|
|
||||||
public Administration() : base()
|
public Administration() : base()
|
||||||
@ -36,6 +38,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
NadekoBot.CommandHandler.CommandExecuted += DelMsgOnCmd_Handler;
|
NadekoBot.CommandHandler.CommandExecuted += DelMsgOnCmd_Handler;
|
||||||
|
|
||||||
|
DeleteMessagesOnCommand = new ConcurrentHashSet<ulong>(NadekoBot.AllGuildConfigs.Where(g => g.DeleteMessageOnCommand).Select(g => g.GuildId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,15 +49,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var channel = msg.Channel as SocketTextChannel;
|
var channel = msg.Channel as SocketTextChannel;
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
return;
|
return;
|
||||||
|
if (DeleteMessagesOnCommand.Contains(channel.Guild.Id))
|
||||||
//todo cache this
|
|
||||||
bool shouldDelete;
|
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
|
||||||
{
|
|
||||||
shouldDelete = uow.GuildConfigs.For(channel.Guild.Id, set => set).DeleteMessageOnCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldDelete)
|
|
||||||
await msg.DeleteAsync().ConfigureAwait(false);
|
await msg.DeleteAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -99,9 +94,15 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await uow.CompleteAsync();
|
await uow.CompleteAsync();
|
||||||
}
|
}
|
||||||
if (enabled)
|
if (enabled)
|
||||||
|
{
|
||||||
|
DeleteMessagesOnCommand.Add(Context.Guild.Id);
|
||||||
await Context.Channel.SendConfirmAsync("✅ **Now automatically deleting successful command invokations.**").ConfigureAwait(false);
|
await Context.Channel.SendConfirmAsync("✅ **Now automatically deleting successful command invokations.**").ConfigureAwait(false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
DeleteMessagesOnCommand.TryRemove(Context.Guild.Id);
|
||||||
await Context.Channel.SendConfirmAsync("❗**Stopped automatic deletion of successful command invokations.**").ConfigureAwait(false);
|
await Context.Channel.SendConfirmAsync("❗**Stopped automatic deletion of successful command invokations.**").ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
@ -38,9 +38,6 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
.ToDictionary(g => g.Key, g => g.ToList()));
|
.ToDictionary(g => g.Key, g => g.ToList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ClashOfClans() : base()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task CheckWar(TimeSpan callExpire, ClashWar war)
|
private static async Task CheckWar(TimeSpan callExpire, ClashWar war)
|
||||||
{
|
{
|
||||||
@ -52,7 +49,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
{
|
{
|
||||||
Bases[i] = null;
|
Bases[i] = null;
|
||||||
try { await war.Channel.SendErrorAsync($"❗🔰**Claim from @{Bases[i].CallUser} for a war against {war.ShortPrint()} has expired.**").ConfigureAwait(false); } catch { }
|
try { await war.Channel.SendErrorAsync($"❗🔰**Claim from @{Bases[i].CallUser} for a war against {war.ShortPrint()} has expired.**").ConfigureAwait(false); } catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using NLog;
|
|||||||
|
|
||||||
namespace NadekoBot.Modules
|
namespace NadekoBot.Modules
|
||||||
{
|
{
|
||||||
public class DiscordModule : ModuleBase
|
public abstract class DiscordModule : ModuleBase
|
||||||
{
|
{
|
||||||
protected Logger _log { get; }
|
protected Logger _log { get; }
|
||||||
protected string _prefix { get; }
|
protected string _prefix { get; }
|
||||||
|
@ -21,6 +21,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
private Regex dndRegex { get; } = new Regex(@"^(?<n1>\d+)d(?<n2>\d+)(?:\+(?<add>\d+))?(?:\-(?<sub>\d+))?$", RegexOptions.Compiled);
|
private Regex dndRegex { get; } = new Regex(@"^(?<n1>\d+)d(?<n2>\d+)(?:\+(?<add>\d+))?(?:\-(?<sub>\d+))?$", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
public enum RoleOrderType {
|
||||||
|
Ordered,
|
||||||
|
Unordered
|
||||||
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task Roll()
|
public async Task Roll()
|
||||||
{
|
{
|
||||||
@ -43,37 +48,6 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
await Context.Channel.SendFileAsync(imageStream, "dice.png", $"{Context.User.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false);
|
await Context.Channel.SendFileAsync(imageStream, "dice.png", $"{Context.User.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
//todo merge into internallDndRoll and internalRoll
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
|
||||||
[Priority(1)]
|
|
||||||
public async Task Roll(string arg)
|
|
||||||
{
|
|
||||||
var ordered = true;
|
|
||||||
var rng = new NadekoRandom();
|
|
||||||
Match match;
|
|
||||||
if ((match = dndRegex.Match(arg)).Length != 0)
|
|
||||||
{
|
|
||||||
int n1;
|
|
||||||
int n2;
|
|
||||||
if (int.TryParse(match.Groups["n1"].ToString(), out n1) &&
|
|
||||||
int.TryParse(match.Groups["n2"].ToString(), out n2) &&
|
|
||||||
n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0)
|
|
||||||
{
|
|
||||||
var add = 0;
|
|
||||||
var sub = 0;
|
|
||||||
int.TryParse(match.Groups["add"].Value, out add);
|
|
||||||
int.TryParse(match.Groups["sub"].Value, out sub);
|
|
||||||
|
|
||||||
var arr = new int[n1];
|
|
||||||
for (int i = 0; i < n1; i++)
|
|
||||||
{
|
|
||||||
arr[i] = rng.Next(1, n2 + 1) + add - sub;
|
|
||||||
}
|
|
||||||
var elemCnt = 0;
|
|
||||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[Priority(0)]
|
[Priority(0)]
|
||||||
@ -123,37 +97,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
await Context.Channel.SendFileAsync(ms, "dice.png", $"{Context.User.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false);
|
await Context.Channel.SendFileAsync(ms, "dice.png", $"{Context.User.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
|
||||||
public async Task Rolluo(string arg)
|
|
||||||
{
|
|
||||||
var ordered = false;
|
|
||||||
var rng = new NadekoRandom();
|
|
||||||
Match match;
|
|
||||||
if ((match = dndRegex.Match(arg)).Length != 0)
|
|
||||||
{
|
|
||||||
int n1;
|
|
||||||
int n2;
|
|
||||||
if (int.TryParse(match.Groups["n1"].ToString(), out n1) &&
|
|
||||||
int.TryParse(match.Groups["n2"].ToString(), out n2) &&
|
|
||||||
n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0)
|
|
||||||
{
|
|
||||||
var add = 0;
|
|
||||||
var sub = 0;
|
|
||||||
int.TryParse(match.Groups["add"].Value, out add);
|
|
||||||
int.TryParse(match.Groups["sub"].Value, out sub);
|
|
||||||
|
|
||||||
var arr = new int[n1];
|
|
||||||
for (int i = 0; i < n1; i++)
|
|
||||||
{
|
|
||||||
arr[i] = rng.Next(1, n2 + 1) + add - sub;
|
|
||||||
}
|
|
||||||
var elemCnt = 0;
|
|
||||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task Rolluo(int num)
|
public async Task Rolluo(int num)
|
||||||
{
|
{
|
||||||
@ -202,6 +146,73 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
await Context.Channel.SendFileAsync(ms, "dice.png", $"{Context.User.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false);
|
await Context.Channel.SendFileAsync(ms, "dice.png", $"{Context.User.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo merge into internallDndRoll and internalRoll
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
[Priority(1)]
|
||||||
|
public async Task Roll(string arg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
public async Task Rolluo(string arg)
|
||||||
|
{
|
||||||
|
var ordered = false;
|
||||||
|
var rng = new NadekoRandom();
|
||||||
|
Match match;
|
||||||
|
if ((match = dndRegex.Match(arg)).Length != 0)
|
||||||
|
{
|
||||||
|
int n1;
|
||||||
|
int n2;
|
||||||
|
if (int.TryParse(match.Groups["n1"].ToString(), out n1) &&
|
||||||
|
int.TryParse(match.Groups["n2"].ToString(), out n2) &&
|
||||||
|
n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0)
|
||||||
|
{
|
||||||
|
var add = 0;
|
||||||
|
var sub = 0;
|
||||||
|
int.TryParse(match.Groups["add"].Value, out add);
|
||||||
|
int.TryParse(match.Groups["sub"].Value, out sub);
|
||||||
|
|
||||||
|
var arr = new int[n1];
|
||||||
|
for (int i = 0; i < n1; i++)
|
||||||
|
{
|
||||||
|
arr[i] = rng.Next(1, n2 + 1) + add - sub;
|
||||||
|
}
|
||||||
|
var elemCnt = 0;
|
||||||
|
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalDndRoll(string arg, RoleOrderType ordType)
|
||||||
|
{
|
||||||
|
var ordered = ordType == RoleOrderType.Ordered;
|
||||||
|
var rng = new NadekoRandom();
|
||||||
|
Match match;
|
||||||
|
if ((match = dndRegex.Match(arg)).Length != 0)
|
||||||
|
{
|
||||||
|
int n1;
|
||||||
|
int n2;
|
||||||
|
if (int.TryParse(match.Groups["n1"].ToString(), out n1) &&
|
||||||
|
int.TryParse(match.Groups["n2"].ToString(), out n2) &&
|
||||||
|
n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0)
|
||||||
|
{
|
||||||
|
var add = 0;
|
||||||
|
var sub = 0;
|
||||||
|
int.TryParse(match.Groups["add"].Value, out add);
|
||||||
|
int.TryParse(match.Groups["sub"].Value, out sub);
|
||||||
|
|
||||||
|
var arr = new int[n1];
|
||||||
|
for (int i = 0; i < n1; i++)
|
||||||
|
{
|
||||||
|
arr[i] = rng.Next(1, n2 + 1) + add - sub;
|
||||||
|
}
|
||||||
|
var elemCnt = 0;
|
||||||
|
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task NRoll([Remainder] string range)
|
public async Task NRoll([Remainder] string range)
|
||||||
{
|
{
|
||||||
@ -215,7 +226,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
.Select(int.Parse)
|
.Select(int.Parse)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
if (arr[0] > arr[1])
|
if (arr[0] > arr[1])
|
||||||
throw new ArgumentException("First argument should be bigger than the second one.");
|
throw new ArgumentException("Second argument must be larger than the first one.");
|
||||||
rolled = new NadekoRandom().Next(arr[0], arr[1] + 1);
|
rolled = new NadekoRandom().Next(arr[0], arr[1] + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -53,7 +53,6 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
MemoryStream bitmapStream = new MemoryStream();
|
MemoryStream bitmapStream = new MemoryStream();
|
||||||
images.Merge().SaveAsPng(bitmapStream);
|
images.Merge().SaveAsPng(bitmapStream);
|
||||||
bitmapStream.Position = 0;
|
bitmapStream.Position = 0;
|
||||||
//todo CARD NAMES?
|
|
||||||
var toSend = $"{Context.User.Mention}";
|
var toSend = $"{Context.User.Mention}";
|
||||||
if (cardObjects.Count == 5)
|
if (cardObjects.Count == 5)
|
||||||
toSend += $" drew `{Cards.GetHandValue(cardObjects)}`";
|
toSend += $" drew `{Cards.GetHandValue(cardObjects)}`";
|
||||||
|
@ -64,16 +64,10 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// todo update this
|
var removed = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)Context.User, "Betflip Gamble", amount, false).ConfigureAwait(false);
|
||||||
long userFlowers;
|
if (!removed)
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
|
||||||
{
|
{
|
||||||
userFlowers = uow.Currency.GetOrCreate(Context.User.Id).Amount;
|
await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {Gambling.CurrencyPluralName}.").ConfigureAwait(false);
|
||||||
}
|
|
||||||
|
|
||||||
if (userFlowers < amount)
|
|
||||||
{
|
|
||||||
await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {Gambling.CurrencyPluralName}. You only have {userFlowers}{Gambling.CurrencySign}.").ConfigureAwait(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +143,7 @@ namespace NadekoBot.Modules.Games.Commands.Hangman
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var guess = char.ToUpperInvariant(msg.Content[0]);
|
var guess = char.ToUpperInvariant(msg.Content[0]);
|
||||||
// todo hmmmm
|
|
||||||
// how do i want to limit the users on guessing?
|
|
||||||
// one guess every 5 seconds if wrong?
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -16,8 +16,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace NadekoBot.Modules.Games
|
namespace NadekoBot.Modules.Games
|
||||||
{
|
{
|
||||||
//todo make currency generation change and cooldown modifyable
|
|
||||||
//only by bot owner through commands
|
|
||||||
public partial class Games
|
public partial class Games
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -8,7 +8,7 @@ using System.Collections.Concurrent;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
//todo Rewrite? Fix trivia not stopping bug
|
|
||||||
namespace NadekoBot.Modules.Games
|
namespace NadekoBot.Modules.Games
|
||||||
{
|
{
|
||||||
public partial class Games
|
public partial class Games
|
||||||
|
@ -38,9 +38,9 @@ namespace NadekoBot.Modules.Help
|
|||||||
public async Task Modules()
|
public async Task Modules()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var mdls = NadekoBot.CommandService.Modules.GroupBy(mi => mi.GetTopLevelModule()).Select(m => m.Key.Name).OrderBy(m => m);
|
||||||
await Context.Channel.SendMessageAsync("📜 **List of modules:** ```css\n• " + string.Join("\n• ",
|
await Context.Channel.SendMessageAsync("📜 **List of modules:** ```css\n• " + string.Join("\n• ",
|
||||||
NadekoBot.CommandService.Modules.GroupBy(mi => mi.GetTopLevelModule()).Select(m => m.Key.Name).OrderBy(m => m)) +
|
mdls) + $"\n``` ℹ️ **Type** `-commands module_name` **to get a list of commands in that module.** ***e.g.*** `-commands games`")
|
||||||
$"\n``` ℹ️ **Type** `-commands module_name` **to get a list of commands in that module.** ***e.g.*** `-commands games`")
|
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Music thread almost crashed.");
|
Console.WriteLine("Music thread almost crashed.");
|
||||||
Console.WriteLine(ex);
|
Console.WriteLine(ex);
|
||||||
|
await Task.Delay(30000);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -24,22 +24,22 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
public string Query { get; set; }
|
public string Query { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string Uri { get; set; }
|
public string Uri { get; set; }
|
||||||
public string AlbumArt { get; set; }
|
public string AlbumArt { get; set; }
|
||||||
}
|
}
|
||||||
public class Song
|
public class Song
|
||||||
{
|
{
|
||||||
public StreamState State { get; set; }
|
public StreamState State { get; set; }
|
||||||
public string PrettyName =>
|
public string PrettyName =>
|
||||||
$"**{SongInfo.Title.TrimTo(55)} `{(SongInfo.Provider ?? "-")} by {QueuerName}`**";
|
$"**{SongInfo.Title.TrimTo(55)} `{(SongInfo.Provider ?? "-")} by {QueuerName}`**";
|
||||||
//$"{SongInfo.Title.TrimTo(70)}";
|
//$"{SongInfo.Title.TrimTo(70)}";
|
||||||
public SongInfo SongInfo { get; }
|
public SongInfo SongInfo { get; }
|
||||||
public MusicPlayer MusicPlayer { get; set; }
|
public MusicPlayer MusicPlayer { get; set; }
|
||||||
|
|
||||||
public string PrettyUser =>
|
public string PrettyUser =>
|
||||||
$"{QueuerName}";
|
$"{QueuerName}";
|
||||||
public string QueuerName { get; set; }
|
public string QueuerName { get; set; }
|
||||||
|
|
||||||
public string PrettyProvider =>
|
public string PrettyProvider =>
|
||||||
$"{(SongInfo.Provider ?? "No Provider")}";
|
$"{(SongInfo.Provider ?? "No Provider")}";
|
||||||
|
|
||||||
public string PrettyCurrentTime()
|
public string PrettyCurrentTime()
|
||||||
@ -320,7 +320,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
Uri = svideo.StreamLink,
|
Uri = svideo.StreamLink,
|
||||||
ProviderType = musicType,
|
ProviderType = musicType,
|
||||||
Query = svideo.TrackLink,
|
Query = svideo.TrackLink,
|
||||||
AlbumArt = svideo.artwork_url,
|
AlbumArt = svideo.artwork_url,
|
||||||
})
|
})
|
||||||
{ TotalLength = TimeSpan.FromMilliseconds(svideo.Duration) };
|
{ TotalLength = TimeSpan.FromMilliseconds(svideo.Duration) };
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
Uri = svideo.StreamLink,
|
Uri = svideo.StreamLink,
|
||||||
ProviderType = MusicType.Normal,
|
ProviderType = MusicType.Normal,
|
||||||
Query = svideo.TrackLink,
|
Query = svideo.TrackLink,
|
||||||
AlbumArt = svideo.artwork_url,
|
AlbumArt = svideo.artwork_url,
|
||||||
})
|
})
|
||||||
{ TotalLength = TimeSpan.FromMilliseconds(svideo.Duration) };
|
{ TotalLength = TimeSpan.FromMilliseconds(svideo.Duration) };
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
var battletag = query.Replace("#", "-");
|
var battletag = query.Replace("#", "-");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
await Context.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||||
var model = await GetProfile(region, battletag);
|
var model = await GetProfile(region, battletag);
|
||||||
|
|
||||||
var rankimg = $"{model.Competitive.rank_img}";
|
var rankimg = $"{model.Competitive.rank_img}";
|
||||||
|
@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
"Equals",
|
"Equals",
|
||||||
"GetHashCode",
|
"GetHashCode",
|
||||||
"GetType"});
|
"GetType"});
|
||||||
await Context.Channel.SendConfirmAsync(string.Join(", ", selection));
|
await Context.Channel.SendConfirmAsync("Available functions in calc", string.Join(", ", selection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,11 +125,27 @@ namespace NadekoBot.Modules.Utility
|
|||||||
return;
|
return;
|
||||||
if (target != null)
|
if (target != null)
|
||||||
{
|
{
|
||||||
await channel.SendConfirmAsync($"⚔ **Page #{page} of roles for {target.Username}**", $"```css\n• " + string.Join("\n• ", target.GetRoles().Except(new[] { guild.EveryoneRole }).OrderBy(r => -r.Position).Skip((page - 1) * RolesPerPage).Take(RolesPerPage)).SanitizeMentions() + "\n```");
|
var roles = target.GetRoles().Except(new[] { guild.EveryoneRole }).OrderBy(r => -r.Position).Skip((page - 1) * RolesPerPage).Take(RolesPerPage);
|
||||||
|
if (!roles.Any())
|
||||||
|
{
|
||||||
|
await channel.SendErrorAsync("No roles on this page.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await channel.SendConfirmAsync($"⚔ **Page #{page} of roles for {target.Username}**", $"```css\n• " + string.Join("\n• ", roles).SanitizeMentions() + "\n```");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await channel.SendConfirmAsync($"⚔ **Page #{page} of all roles on this server:**", $"```css\n• " + string.Join("\n• ", guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => -r.Position).Skip((page - 1) * RolesPerPage).Take(RolesPerPage)).SanitizeMentions() + "\n```");
|
var roles = guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => -r.Position).Skip((page - 1) * RolesPerPage).Take(RolesPerPage);
|
||||||
|
if (!roles.Any())
|
||||||
|
{
|
||||||
|
await channel.SendErrorAsync("No roles on this page.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await channel.SendConfirmAsync($"⚔ **Page #{page} of all roles on this server:**", $"```css\n• " + string.Join("\n• ", roles).SanitizeMentions() + "\n```");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,15 +135,15 @@ namespace NadekoBot.Services
|
|||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
string messageContent = usrMsg.Content;
|
string messageContent = usrMsg.Content;
|
||||||
foreach (var k in NadekoBot.ModulePrefixes.Values)
|
//foreach (var k in NadekoBot.ModulePrefixes.Values)
|
||||||
{
|
//{
|
||||||
if (usrMsg.Content.ToLowerInvariant().StartsWith(k))
|
// if (usrMsg.Content.ToLowerInvariant().StartsWith(k))
|
||||||
{
|
// {
|
||||||
messageContent = messageContent.Insert(k.Length, " ");
|
// messageContent = messageContent.Insert(k.Length, " ");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
var throwaway = Task.Run(async () =>
|
var throwaway = Task.Run(async () =>
|
||||||
|
@ -9,7 +9,7 @@ namespace NadekoBot.Services
|
|||||||
{
|
{
|
||||||
public static class CurrencyHandler
|
public static class CurrencyHandler
|
||||||
{
|
{
|
||||||
public static async Task<bool> RemoveCurrencyAsync(IGuildUser author, string reason, long amount, bool sendMessage)
|
public static async Task<bool> RemoveCurrencyAsync(IUser author, string reason, long amount, bool sendMessage)
|
||||||
{
|
{
|
||||||
var success = await RemoveCurrencyAsync(author.Id, reason, amount);
|
var success = await RemoveCurrencyAsync(author.Id, reason, amount);
|
||||||
|
|
||||||
|
@ -167,7 +167,8 @@ namespace NadekoBot.Services.Impl
|
|||||||
remaining -= toGet;
|
remaining -= toGet;
|
||||||
|
|
||||||
var q = yt.Videos.List("contentDetails");
|
var q = yt.Videos.List("contentDetails");
|
||||||
q.Id = string.Join(",", videoIds);
|
q.Id = string.Join(",", videoIdsList.Take(toGet));
|
||||||
|
videoIdsList = videoIdsList.Skip(toGet).ToList();
|
||||||
var items = (await q.ExecuteAsync().ConfigureAwait(false)).Items;
|
var items = (await q.ExecuteAsync().ConfigureAwait(false)).Items;
|
||||||
foreach (var i in items)
|
foreach (var i in items)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
|
using NadekoBot.Extensions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ namespace NadekoBot.TypeReaders
|
|||||||
public override Task<TypeReaderResult> Read(CommandContext context, string input)
|
public override Task<TypeReaderResult> Read(CommandContext context, string input)
|
||||||
{
|
{
|
||||||
input = input.ToUpperInvariant();
|
input = input.ToUpperInvariant();
|
||||||
var module = NadekoBot.CommandService.Modules.FirstOrDefault(m => m.Name.ToUpperInvariant() == input);
|
var module = NadekoBot.CommandService.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToUpperInvariant() == input);
|
||||||
if (module == null)
|
if (module == null)
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
||||||
|
|
||||||
|
@ -79,34 +79,34 @@ namespace NadekoBot.Extensions
|
|||||||
|
|
||||||
public static double UnixTimestamp(this DateTime dt) => dt.ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
public static double UnixTimestamp(this DateTime dt) => dt.ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
public static async Task<IUserMessage> SendMessageAsync(this IGuildUser user, string message, bool isTTS = false) =>
|
public static async Task<IUserMessage> SendMessageAsync(this IUser user, string message, bool isTTS = false) =>
|
||||||
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(message, isTTS).ConfigureAwait(false);
|
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(message, isTTS).ConfigureAwait(false);
|
||||||
|
|
||||||
public static async Task<IUserMessage> SendConfirmAsync(this IGuildUser user, string text)
|
public static async Task<IUserMessage> SendConfirmAsync(this IUser user, string text)
|
||||||
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(text));
|
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(text));
|
||||||
|
|
||||||
public static async Task<IUserMessage> SendConfirmAsync(this IGuildUser user, string title, string text, string url = null)
|
public static async Task<IUserMessage> SendConfirmAsync(this IUser user, string title, string text, string url = null)
|
||||||
=> await(await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(text)
|
=> await(await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(text)
|
||||||
.WithTitle(title).WithUrl(url));
|
.WithTitle(title).WithUrl(url));
|
||||||
|
|
||||||
public static async Task<IUserMessage> SendErrorAsync(this IGuildUser user, string title, string error, string url = null)
|
public static async Task<IUserMessage> SendErrorAsync(this IUser user, string title, string error, string url = null)
|
||||||
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(error)
|
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(error)
|
||||||
.WithTitle(title).WithUrl(url));
|
.WithTitle(title).WithUrl(url));
|
||||||
|
|
||||||
public static async Task<IUserMessage> SendErrorAsync(this IGuildUser user, string error)
|
public static async Task<IUserMessage> SendErrorAsync(this IUser user, string error)
|
||||||
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(error));
|
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new EmbedBuilder().WithColor(NadekoBot.OkColor).WithDescription(error));
|
||||||
|
|
||||||
public static async Task<IUserMessage> SendFileAsync(this IGuildUser user, string filePath, string caption = null, string text = null, bool isTTS = false) =>
|
public static async Task<IUserMessage> SendFileAsync(this IUser user, string filePath, string caption = null, string text = null, bool isTTS = false) =>
|
||||||
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(File.Open(filePath, FileMode.Open), caption ?? "x", text, isTTS).ConfigureAwait(false);
|
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(File.Open(filePath, FileMode.Open), caption ?? "x", text, isTTS).ConfigureAwait(false);
|
||||||
|
|
||||||
public static async Task<IUserMessage> SendFileAsync(this IGuildUser user, Stream fileStream, string fileName, string caption = null, bool isTTS = false) =>
|
public static async Task<IUserMessage> SendFileAsync(this IUser user, Stream fileStream, string fileName, string caption = null, bool isTTS = false) =>
|
||||||
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(fileStream, fileName, caption, isTTS).ConfigureAwait(false);
|
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(fileStream, fileName, caption, isTTS).ConfigureAwait(false);
|
||||||
|
|
||||||
public static bool IsAuthor(this IUserMessage msg) =>
|
public static bool IsAuthor(this IUserMessage msg) =>
|
||||||
NadekoBot.Client.CurrentUser().Id == msg.Author.Id;
|
NadekoBot.Client.CurrentUser().Id == msg.Author.Id;
|
||||||
|
|
||||||
public static IEnumerable<IUser> Members(this IRole role) =>
|
public static IEnumerable<IUser> Members(this IRole role) =>
|
||||||
role.Guild.GetUsersAsync().GetAwaiter().GetResult() ?? Enumerable.Empty<IUser>();
|
role.Guild.GetUsersAsync().GetAwaiter().GetResult().Where(u => u.RoleIds.Contains(role.Id)) ?? Enumerable.Empty<IUser>();
|
||||||
|
|
||||||
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "")
|
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "")
|
||||||
=> ch.SendMessageAsync(msg, embed: embed);
|
=> ch.SendMessageAsync(msg, embed: embed);
|
||||||
|
Loading…
Reference in New Issue
Block a user