mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-05 13:36:30 +03:00
general code refactor and bug fixes
This commit is contained in:
parent
4d838e5af3
commit
04facc3de2
15 changed files with 197 additions and 132 deletions
|
@ -9,24 +9,27 @@ 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);
|
||||
|
||||
await KickMember(context.Guild, context.Channel as ITextChannel, author, toKick, Utils.JoinString(args, 1));
|
||||
}
|
||||
|
||||
private static async void KickMember(IGuild guild, ITextChannel? channel, IUser author, IGuildUser toKick,
|
||||
private static async Task 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 guildKickMessage = $"({Utils.GetNameAndDiscrim(author)}) {reason}";
|
||||
var notification = string.Format(Messages.MemberKicked, authorMention, toKick.Mention,
|
||||
Utils.WrapInline(reason));
|
||||
|
||||
await Utils.SendDirectMessage(toKick, string.Format(Messages.YouWereKicked, authorMention, guild.Name,
|
||||
Utils.WrapInline(reason)));
|
||||
|
||||
await toKick.KickAsync(guildKickMessage);
|
||||
|
||||
await Utils.SilentSendAsync(channel, string.Format(Messages.KickResponse, toKick.Mention,
|
||||
Utils.WrapInline(reason)));
|
||||
await Utils.SilentSendAsync(await guild.GetSystemChannelAsync(), notification);
|
||||
|
@ -44,4 +47,4 @@ public class KickCommand : Command {
|
|||
public override string GetSummary() {
|
||||
return "Выгоняет участника";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue