mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-05 13:36:30 +03:00
ton of stuff
- new command handler - multilanguage support - time out support - responses - a ton of stuff
This commit is contained in:
parent
1c9caf6d75
commit
f30485dd71
29 changed files with 1686 additions and 520 deletions
47
Boyfriend/Commands/KickCommand.cs
Normal file
47
Boyfriend/Commands/KickCommand.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public class KickCommand : Command {
|
||||
public override async Task Run(SocketCommandContext context, string[] args) {
|
||||
var reason = Utils.JoinString(args, 1);
|
||||
var author = context.Guild.GetUser(context.User.Id);
|
||||
var toKick = await Utils.ParseMember(context.Guild, args[0]);
|
||||
await CommandHandler.CheckPermissions(author, GuildPermission.KickMembers);
|
||||
await CommandHandler.CheckInteractions(author, toKick);
|
||||
KickMember(context.Guild, context.Channel as ITextChannel, context.Guild.GetUser(context.User.Id), toKick,
|
||||
reason);
|
||||
}
|
||||
|
||||
private static async void KickMember(IGuild guild, ITextChannel? channel, IUser author, IGuildUser toKick,
|
||||
string reason) {
|
||||
var authorMention = author.Mention;
|
||||
await Utils.SendDirectMessage(toKick, string.Format(Messages.YouWereKicked, authorMention, guild.Name,
|
||||
Utils.WrapInline(reason)));
|
||||
var guildKickMessage = $"({author.Username}#{author.Discriminator}) {reason}";
|
||||
await toKick.KickAsync(guildKickMessage);
|
||||
var notification = string.Format(Messages.MemberKicked, authorMention, toKick.Mention,
|
||||
Utils.WrapInline(reason));
|
||||
await Utils.SilentSendAsync(channel, string.Format(Messages.KickResponse, toKick.Mention,
|
||||
Utils.WrapInline(reason)));
|
||||
await Utils.SilentSendAsync(await guild.GetSystemChannelAsync(), notification);
|
||||
await Utils.SilentSendAsync(await Utils.GetAdminLogChannel(guild), notification);
|
||||
}
|
||||
|
||||
public override List<string> GetAliases() {
|
||||
return new List<string> {"kick", "кик"};
|
||||
}
|
||||
|
||||
public override int GetArgumentsAmountRequired() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public override string GetSummary() {
|
||||
return "Выгоняет участника";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue