Esempio n. 1
0
        private async Task KickUser(SocketGuildUser user, [Remainder] string reason)
        {
            if (Helpers.IsRole(UtilityRoles.Moderator, (SocketGuildUser)user))
            {
                await Context.Channel.SendMessageAsync("stop fighting urselves u retards");

                return;
            }

            if (reason.Length < 1)
            {
                reason = "cya";
            }
            string kickTargetName = user.Username;

            try
            {
                await user.KickAsync(reason);

                var embed = new EmbedBuilder();
                embed.WithTitle($"✅     {Context.User.Username} _booted_ {kickTargetName}");
                embed.WithDescription($"reason: **{reason}**");
                embed.WithColor(new Color(0, 255, 0));
                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception ex)
            {
                await ExceptionHandler.HandleExceptionPublically(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
            }


            try
            {
                var storeRoles = new StoreRoleMethods();
                await storeRoles.StoreUserRoles(Context, user as SocketGuildUser);
            }
            catch (Exception ex)
            {
                await ExceptionHandler.HandleExceptionQuietly(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
            }
        }
        private async Task SayCustomMessage([Remainder] string input)
        {
            try
            {
                if (Context.Message.MentionedChannels.Count == 0)
                {
                    await Context.Channel.SendMessageAsync("You must mention the channel: (#channel_name)");

                    return;
                }

                var targetChannel         = Context.Message.MentionedChannels.FirstOrDefault() as ITextChannel;
                var targetChannelAsString = $"<#{targetChannel.Id}>";
                var sanitizedInput        = input.Replace(targetChannelAsString, string.Empty);

                await targetChannel.SendMessageAsync(sanitizedInput);
            }
            catch (Exception ex)
            {
                await ExceptionHandler.HandleExceptionPublically(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
            }
        }
Esempio n. 3
0
        private async Task ChangeSonyaRoleColour(string inputColour)
        {
            try
            {
                var user = Context.User as SocketGuildUser;
                if (!user.Roles.Where(x => x.Name.ToLower() == "sonya").Any())
                {
                    return;
                }

                var    sonyaRole  = Helpers.ReturnRole(Context.Guild, "sonya");
                string conversion = "0x" + inputColour.Replace("#", "");

                var colorHex = Convert.ToUInt32(conversion, 16);
                var color    = new Discord.Color(colorHex);

                if (colorHex != 0)
                {
                    await sonyaRole.ModifyAsync(x =>
                    {
                        x.Color = color;
                    });

                    await Context.Channel.SendMessageAsync($"Colour successfully changed to {inputColour}");
                }
                else
                {
                    var insult = await Personality.Insults.GetInsult();

                    await Context.Channel.SendMessageAsync($"what the F**K is that supposed to be? retard {insult}");
                }
            }
            catch (Exception ex)
            {
                await ExceptionHandler.HandleExceptionPublically(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
            }
        }
Esempio n. 4
0
        private async Task UnbanUser(ulong userID)
        {
            try
            {
                var insult = await Insults.GetInsult();

                var allBans = await Context.Guild.GetBansAsync();

                bool   existingBan    = false;
                string bannedUserName = string.Empty;

                foreach (var item in allBans)
                {
                    if (item.User.Id == userID)
                    {
                        existingBan    = true;
                        bannedUserName = item.User.Username;
                        break;
                    }
                }

                if (!existingBan)
                {
                    await Context.Channel.SendMessageAsync("that's not a valid ID " + insult);
                }
                else
                {
                    await Context.Guild.RemoveBanAsync(userID);

                    await Context.Channel.SendMessageAsync($"✅    *** {bannedUserName} has been unbanned ***");
                }
            }
            catch (Exception ex)
            {
                await ExceptionHandler.HandleExceptionPublically(GetType().FullName, ExceptionHandler.GetAsyncMethodName(), ex);
            }
        }