commit
a9299f842d
@ -30,12 +30,14 @@ namespace NadekoBot.Modules.Administration
|
||||
commands.Add(new InfoCommands(this));
|
||||
commands.Add(new CustomReactionsCommands(this));
|
||||
commands.Add(new AutoAssignRole(this));
|
||||
commands.Add(new SelfCommands(this));
|
||||
}
|
||||
|
||||
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Administration;
|
||||
|
||||
public override void Install(ModuleManager manager)
|
||||
{
|
||||
|
||||
manager.CreateCommands("", cgb =>
|
||||
{
|
||||
|
||||
@ -720,11 +722,13 @@ namespace NadekoBot.Modules.Administration
|
||||
var avatarAddress = e.GetArg("img");
|
||||
var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
|
||||
var image = System.Drawing.Image.FromStream(imageStream);
|
||||
// Save the image to disk.
|
||||
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
|
||||
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: image.ToStream()).ConfigureAwait(false);
|
||||
|
||||
// Send confirm.
|
||||
await e.Channel.SendMessage("New avatar set.").ConfigureAwait(false);
|
||||
|
||||
// Save the image to disk.
|
||||
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "setgame")
|
||||
@ -998,6 +1002,21 @@ namespace NadekoBot.Modules.Administration
|
||||
await e.Channel.SendMessage("```xl\n" + string.Join("\n", arr.GroupBy(item => (i++) / 3).Select(ig => string.Join("", ig.Select(el => $"• {el,-35}")))) + "\n```");
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "leave")
|
||||
.Description("Leaves a server with a supplied ID.\n**Usage**: `.leave 493243292839`")
|
||||
.Parameter("num", ParameterType.Required)
|
||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||
.Do(async e =>
|
||||
{
|
||||
var srvr = NadekoBot.Client.Servers.Where(s => s.Id.ToString() == e.GetArg("num").Trim()).FirstOrDefault();
|
||||
if (srvr == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await srvr.Leave();
|
||||
await e.Channel.SendMessage("`Done.`");
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
internal override void Init(CommandGroupBuilder cgb)
|
||||
{
|
||||
cgb.CreateCommand(Module.Prefix + "aar")
|
||||
.Alias(Module.Prefix + "autoassignrole")
|
||||
cgb.CreateCommand(Module.Prefix + "autoassignrole")
|
||||
.Alias(Module.Prefix + "aar")
|
||||
.Description($"Automaticaly assigns a specified role to every user who joins the server. Type `.aar` to disable, `.aar Role Name` to enable")
|
||||
.Parameter("role", ParameterType.Unparsed)
|
||||
.AddCheck(new SimpleCheckers.ManageRoles())
|
||||
@ -42,6 +42,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (!e.Server.CurrentUser.ServerPermissions.ManageRoles)
|
||||
{
|
||||
await e.Channel.SendMessage("I do not have the permission to manage roles.");
|
||||
return;
|
||||
}
|
||||
var r = e.GetArg("role")?.Trim();
|
||||
|
||||
|
@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Module.Prefix + "lsar")
|
||||
.Description("Lits all self-assignable roles.")
|
||||
.Description("Lists all self-assignable roles.")
|
||||
.Parameter("roles", ParameterType.Multiple)
|
||||
.Do(async e =>
|
||||
{
|
||||
|
46
NadekoBot/Modules/Administration/Commands/SelfCommands.cs
Normal file
46
NadekoBot/Modules/Administration/Commands/SelfCommands.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using NadekoBot.Classes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
|
||||
namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
class SelfCommands : DiscordCommand
|
||||
{
|
||||
public SelfCommands(DiscordModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
internal override void Init(CommandGroupBuilder cgb)
|
||||
{
|
||||
cgb.CreateCommand(Module.Prefix + "leave")
|
||||
.Description("Makes Nadeko leave the server. Either name or id required.\n**Usage**:.leave NSFW")
|
||||
.Parameter("arg", ParameterType.Required)
|
||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||
.Do(async e =>
|
||||
{
|
||||
var arg = e.GetArg("arg")?.Trim();
|
||||
var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
|
||||
NadekoBot.Client.FindServers(arg.Trim()).FirstOrDefault();
|
||||
if (server == null)
|
||||
{
|
||||
await e.Channel.SendMessage("Cannot find that server").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (!server.IsOwner)
|
||||
{
|
||||
await server.Leave();
|
||||
}
|
||||
else
|
||||
{
|
||||
await server.Delete();
|
||||
}
|
||||
await NadekoBot.SendMessageToOwner("Left server " + server.Name);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -258,28 +258,6 @@ namespace NadekoBot.Modules.Conversations
|
||||
await e.Channel.SendMessage("I can't find a message mentioning you.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("hide")
|
||||
.Description("Hides Nadeko in plain sight!11!!")
|
||||
.Do(async e =>
|
||||
{
|
||||
using (var ms = Resources.hidden.ToStream(ImageFormat.Png))
|
||||
{
|
||||
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: ms).ConfigureAwait(false);
|
||||
}
|
||||
await e.Channel.SendMessage("*hides*").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("unhide")
|
||||
.Description("Unhides Nadeko in plain sight!1!!1")
|
||||
.Do(async e =>
|
||||
{
|
||||
using (var fs = new FileStream("data/avatar.png", FileMode.Open))
|
||||
{
|
||||
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: fs).ConfigureAwait(false);
|
||||
}
|
||||
await e.Channel.SendMessage("*unhides*").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("dump")
|
||||
.Description("Dumps all of the invites it can to dump.txt.** Owner Only.**")
|
||||
.Do(async e =>
|
||||
|
@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "award")
|
||||
.Description("Gives someone a certain amount of flowers. **Owner only!**")
|
||||
.Description("Gives someone a certain amount of flowers. **Owner only!**\n**Usage**: `$award 100 @person`")
|
||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||
.Parameter("amount", ParameterType.Required)
|
||||
.Parameter("receiver", ParameterType.Unparsed)
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -79,10 +78,7 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
||||
await Task.Delay(QuestionDurationMiliseconds - HintTimeoutMiliseconds, token).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
Console.WriteLine("Trivia cancelled");
|
||||
}
|
||||
catch (TaskCanceledException) { } //means someone guessed the answer
|
||||
GameActive = false;
|
||||
if (!triviaCancelSource.IsCancellationRequested)
|
||||
await channel.Send($":clock2: :question: **Time's up!** The correct answer was **{CurrentQuestion.Answer}**").ConfigureAwait(false);
|
||||
|
@ -63,30 +63,12 @@ namespace NadekoBot.Modules.Trello
|
||||
}
|
||||
};
|
||||
|
||||
manager.CreateCommands("trello ", cgb =>
|
||||
manager.CreateCommands("", cgb =>
|
||||
{
|
||||
|
||||
cgb.AddCheck(PermissionChecker.Instance);
|
||||
|
||||
cgb.CreateCommand("join")
|
||||
.Alias("j")
|
||||
.Description("Joins a server")
|
||||
.Parameter("code", Discord.Commands.ParameterType.Required)
|
||||
.Do(async e =>
|
||||
{
|
||||
if (!NadekoBot.IsOwner(e.User.Id) || NadekoBot.IsBot) return;
|
||||
try
|
||||
{
|
||||
await (await client.GetInvite(e.GetArg("code")).ConfigureAwait(false)).Accept()
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
});
|
||||
|
||||
cgb.CreateCommand("bind")
|
||||
cgb.CreateCommand(Prefix + "bind")
|
||||
.Description("Bind a trello bot to a single channel. " +
|
||||
"You will receive notifications from your board when something is added or edited." +
|
||||
"\n**Usage**: bind [board_id]")
|
||||
@ -109,7 +91,7 @@ namespace NadekoBot.Modules.Trello
|
||||
}
|
||||
});
|
||||
|
||||
cgb.CreateCommand("unbind")
|
||||
cgb.CreateCommand(Prefix + "unbind")
|
||||
.Description("Unbinds a bot from the channel and board.")
|
||||
.Do(async e =>
|
||||
{
|
||||
@ -122,8 +104,8 @@ namespace NadekoBot.Modules.Trello
|
||||
|
||||
});
|
||||
|
||||
cgb.CreateCommand("lists")
|
||||
.Alias("list")
|
||||
cgb.CreateCommand(Prefix + "lists")
|
||||
.Alias(Prefix + "list")
|
||||
.Description("Lists all lists yo ;)")
|
||||
.Do(async e =>
|
||||
{
|
||||
@ -133,7 +115,7 @@ namespace NadekoBot.Modules.Trello
|
||||
.ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("cards")
|
||||
cgb.CreateCommand(Prefix + "cards")
|
||||
.Description("Lists all cards from the supplied list. You can supply either a name or an index.")
|
||||
.Parameter("list_name", Discord.Commands.ParameterType.Unparsed)
|
||||
.Do(async e =>
|
||||
|
@ -48,21 +48,6 @@ namespace NadekoBot
|
||||
{
|
||||
Console.OutputEncoding = Encoding.Unicode;
|
||||
|
||||
//var lines = File.ReadAllLines("data/input.txt");
|
||||
//HashSet<dynamic> list = new HashSet<dynamic>();
|
||||
//for (int i = 0; i < lines.Length; i += 3) {
|
||||
// dynamic obj = new JArray();
|
||||
// obj.Text = lines[i];
|
||||
// obj.Author = lines[i + 1];
|
||||
// if (obj.Author.StartsWith("-"))
|
||||
// obj.Author = obj.Author.Substring(1, obj.Author.Length - 1).Trim();
|
||||
// list.Add(obj);
|
||||
//}
|
||||
|
||||
//File.WriteAllText("data/quotes.json", Newtonsoft.Json.JsonConvert.SerializeObject(list, Formatting.Indented));
|
||||
|
||||
//Console.ReadKey();
|
||||
// generate credentials example so people can know about the changes i make
|
||||
try
|
||||
{
|
||||
File.WriteAllText("data/config_example.json", JsonConvert.SerializeObject(new Configuration(), Formatting.Indented));
|
||||
@ -252,7 +237,7 @@ namespace NadekoBot
|
||||
|
||||
public static bool IsOwner(ulong id) => Creds.OwnerIds.Contains(id);
|
||||
|
||||
public async Task SendMessageToOwner(string message)
|
||||
public static async Task SendMessageToOwner(string message)
|
||||
{
|
||||
if (Config.ForwardMessages && OwnerPrivateChannel != null)
|
||||
await OwnerPrivateChannel.SendMessage(message).ConfigureAwait(false);
|
||||
|
@ -136,6 +136,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Modules\Administration\Commands\AutoAssignRole.cs" />
|
||||
<Compile Include="Modules\Administration\Commands\CustomReactionsCommands.cs" />
|
||||
<Compile Include="Modules\Administration\Commands\SelfCommands.cs" />
|
||||
<Compile Include="Modules\ClashOfClans\ClashOfClans.cs" />
|
||||
<Compile Include="Classes\DBHandler.cs" />
|
||||
<Compile Include="Classes\FlowersHandler.cs" />
|
||||
|
@ -142,7 +142,7 @@ namespace NadekoBot.Classes.JSONModels
|
||||
public string ClashOfClans { get; set; } = ",";
|
||||
public string Help { get; set; } = "-";
|
||||
public string Music { get; set; } = "!m";
|
||||
public string Trello { get; set; } = "trello";
|
||||
public string Trello { get; set; } = "trello ";
|
||||
public string Games { get; set; } = ">";
|
||||
public string Gambling { get; set; } = "$";
|
||||
public string Permissions { get; set; } = ";";
|
||||
|
@ -81,7 +81,7 @@
|
||||
"ClashOfClans": ",",
|
||||
"Help": "-",
|
||||
"Music": "!m",
|
||||
"Trello": "trello",
|
||||
"Trello": "trello ",
|
||||
"Games": ">",
|
||||
"Gambling": "$",
|
||||
"Permissions": ";",
|
||||
|
Loading…
Reference in New Issue
Block a user