Пример #1
0
            public async Task <RuntimeResult> CheckSummaryAsync(SocketUser user = null)
            {
                var targetUser = user ?? Context.User;
                var record     = await UserRepository.GetOrCreateProfileAsync(targetUser).ConfigureAwait(false);

                return(CommandRuntimeResult.FromInfo($"Current Summary: {Format.Bold(record.Summary)}"));
            }
Пример #2
0
        public async Task <RuntimeResult> ListRemindersAsync()
        {
            var entries = UserRepository.GetReminders(Context.User)
                          .OrderBy(x => x.Time);

            if (!entries.Any())
            {
                return(CommandRuntimeResult.FromError("You do not have a reminder set yet!"));
            }

            var sb             = new StringBuilder();
            var embed          = ReminderService.GetReminderEmbed("");
            var userTimeOffset = GetUserTimeOffset(Context.User);

            if (userTimeOffset > TimeSpan.Zero)
            {
                embed.WithFooter(x => x.Text = $"Converted to {Context.User.GetFullnameOrDefault()}'s timezone.");
            }
            foreach (var entry in entries)
            {
                var time = entry.Time.ToOffset(userTimeOffset);
                sb.AppendLine($"**{time} ({entry.Time.Humanize()})**");
                string channelname = Context.Guild.GetChannel(entry.ChannelId)?.Name ?? "Unknown Channel";
                sb.AppendLine($@"   '{entry.Content}' at #{channelname}");
                sb.AppendLine();
            }
            await ReplyAsync("", embed : embed.WithDescription(sb.ToString()).Build()).ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess());
        }
Пример #3
0
        public async Task <RuntimeResult> ChangeGuildIconAsync(Uri url = null)
        {
            if (url == null)
            {
                await ReplyAsync("", embed : EmbedHelper.FromInfo("New icon", "Please upload your new server icon.").Build()).ConfigureAwait(false);

                var response = await InteractiveService.NextMessageAsync(Context, timeout : TimeSpan.FromMinutes(5)).ConfigureAwait(false);

                if (response == null)
                {
                    return(CommandRuntimeResult.FromError("You did not upload your picture in time."));
                }
                if (!Uri.TryCreate(response.Content, UriKind.RelativeOrAbsolute, out url))
                {
                    var attachment = response.Attachments.FirstOrDefault();
                    if (attachment?.Height != null)
                    {
                        url = new Uri(response.Attachments.FirstOrDefault().Url);
                    }
                    else
                    {
                        return(CommandRuntimeResult.FromError("You did not upload any valid pictures."));
                    }
                }
            }
            using (var image = await WebHelper.GetFileStreamAsync(HttpClient, url).ConfigureAwait(false))
            {
                // ReSharper disable once AccessToDisposedClosure
                await Context.Guild.ModifyAsync(x => x.Icon = new Image(image)).ConfigureAwait(false);
            }
            return(CommandRuntimeResult.FromSuccess("The server icon has been changed!"));
        }
Пример #4
0
        public async Task <RuntimeResult> ThinkingAsync()
        {
            using (var response = await HttpClient.GetAsync("https://www.reddit.com/r/Thinking/.json").ConfigureAwait(false))
            {
                if (!response.IsSuccessStatusCode)
                {
                    return(CommandRuntimeResult.FromError("Reddit is out of reach, please try again later!"));
                }

                var result =
                    JsonConvert.DeserializeObject <RedditResponseModel>(await response.Content.ReadAsStringAsync().ConfigureAwait(false));
                var children = (Context.Channel as SocketTextChannel).IsNsfw
                    ? result.Data.Children
                    : result.Data.Children.Where(x => !x.Data.IsNsfw).ToList();
                int    index   = Random.Next(children.Count);
                var    post    = children[index];
                string title   = Config.Commands.ThinkingTitles[Random.Next(Config.Commands.ThinkingTitles.Count)];
                var    builder = new EmbedBuilder
                {
                    Title        = post.Data.Title,
                    Description  = $"{(post.Data.IsNsfw ? $"{title} (NSFW)" : title)}\n\nPosted by u/{post.Data.Author}",
                    Url          = "https://www.reddit.com/" + post.Data.Permalink,
                    Color        = ColorHelper.GetRandomColor(),
                    ThumbnailUrl = post.Data.Url
                };
                await ReplyAsync("", embed : builder.Build()).ConfigureAwait(false);

                return(CommandRuntimeResult.FromSuccess());
            }
        }
Пример #5
0
        public async Task <RuntimeResult> GetWeatherForLocationAsync([Summary("User")] SocketUser user = null)
        {
            var targetUser = user ?? Context.User;
            var record     = UserRepository.GetCoordinates(targetUser);

            if (record == null)
            {
                return(CommandRuntimeResult.FromError(
                           "Location is not set yet! Please set the location first!"));
            }
            var geocodeResults = await Geocoder.ReverseGeocodeAsync(record.Latitude, record.Longitude).ConfigureAwait(false);

            var geocode = geocodeResults.FirstOrDefault();

            if (geocode == null)
            {
                return(CommandRuntimeResult.FromError(
                           "I could not find the set location! Try setting another location."));
            }
            var forecast = await DarkSkyService.GetForecast(
                geocode.Coordinates.Latitude,
                geocode.Coordinates.Longitude,
                _darkSkyParams
                ).ConfigureAwait(false);

            var embeds = await Weather.GetWeatherEmbedsAsync(forecast, geocode).ConfigureAwait(false);

            await ReplyAsync("", embed : embeds.WeatherResults.FirstOrDefault().Build()).ConfigureAwait(false);

            foreach (var alert in embeds.Alerts)
            {
                await ReplyAsync("", embed : alert.Build()).ConfigureAwait(false);
            }
            return(CommandRuntimeResult.FromSuccess());
        }
Пример #6
0
        public async Task <RuntimeResult> GetWeatherForLocationAsync([Summary("Location")][Remainder] string location)
        {
            var geocodeResults = await Geocoder.GeocodeAsync(location).ConfigureAwait(false);

            var geocode = geocodeResults.FirstOrDefault();

            if (geocode == null)
            {
                return(CommandRuntimeResult.FromError($"I could not find {location}! Try another location."));
            }
            var forecast = await DarkSkyService.GetForecast(
                geocode.Coordinates.Latitude,
                geocode.Coordinates.Longitude,
                _darkSkyParams).ConfigureAwait(false);

            var embeds = await Weather.GetWeatherEmbedsAsync(forecast, geocode).ConfigureAwait(false);

            await ReplyAsync("", embed : embeds.WeatherResults.FirstOrDefault().Build()).ConfigureAwait(false);

            foreach (var alert in embeds.Alerts)
            {
                await ReplyAsync("", embed : alert.Build()).ConfigureAwait(false);
            }
            return(CommandRuntimeResult.FromSuccess());
        }
Пример #7
0
        public async Task <RuntimeResult> LiquifyAsync()
        {
            var message =
                (await Context.Channel.GetMessagesAsync().FlattenAsync().ConfigureAwait(false))?
                .FirstOrDefault(x => x.Attachments.Any(a => a.Width.HasValue));

            if (message == null)
            {
                return(CommandRuntimeResult.FromError("No images found!"));
            }
            foreach (var attachment in message.Attachments)
            {
                using (var attachmentStream = await WebHelper.GetFileStreamAsync(HttpClient, new Uri(attachment.Url)).ConfigureAwait(false))
                    using (var image = new MagickImage(attachmentStream))
                        using (var imageStream = new MemoryStream())
                        {
                            image.LiquidRescale(Convert.ToInt32(image.Width * 0.5), Convert.ToInt32(image.Height * 0.5));
                            image.LiquidRescale(Convert.ToInt32(image.Width * 1.5), Convert.ToInt32(image.Height * 1.5));
                            image.Write(imageStream, MagickFormat.Png);
                            imageStream.Seek(0, SeekOrigin.Begin);
                            await Context.Channel.SendFileAsync(imageStream, "liquify.png").ConfigureAwait(false);
                        }
            }
            return(CommandRuntimeResult.FromSuccess());
        }
Пример #8
0
        public async Task <RuntimeResult> AngeryAsync()
        {
            var message =
                (await Context.Channel.GetMessagesAsync().FlattenAsync().ConfigureAwait(false))?
                .FirstOrDefault(x => x.Attachments.Any(a => a.Width.HasValue));

            if (message == null)
            {
                return(CommandRuntimeResult.FromError("No images found!"));
            }
            foreach (var attachment in message.Attachments)
            {
                using (var attachmentStream = await WebHelper.GetFileStreamAsync(HttpClient, new Uri(attachment.Url)).ConfigureAwait(false))
                    using (var image = Image.Load(attachmentStream))
                        using (var imageStream = new MemoryStream())
                        {
                            image.DrawPolygon(Rgba32.Red, 1000000,
                                              new PointF[] { new Point(0, 0), new Point(image.Width, image.Height) },
                                              new GraphicsOptions {
                                BlenderMode = PixelBlenderMode.Screen, BlendPercentage = 25
                            })
                            .SaveAsPng(imageStream);
                            imageStream.Seek(0, SeekOrigin.Begin);
                            await Context.Channel.SendFileAsync(imageStream, "angery.png").ConfigureAwait(false);
                        }
            }
            return(CommandRuntimeResult.FromSuccess());
        }
Пример #9
0
        public async Task <RuntimeResult> NeedsMoreJpegAsync()
        {
            var message =
                (await Context.Channel.GetMessagesAsync().FlattenAsync().ConfigureAwait(false))?
                .FirstOrDefault(x => x.Attachments.Any(a => a.Width.HasValue));

            if (message == null)
            {
                return(CommandRuntimeResult.FromError("No images found!"));
            }
            foreach (var attachment in message.Attachments)
            {
                using (var attachmentStream = await WebHelper.GetFileStreamAsync(HttpClient, new Uri(attachment.Url)).ConfigureAwait(false))
                    using (var image = Image.Load(attachmentStream))
                        using (var imageStream = new MemoryStream())
                        {
                            image.SaveAsJpeg(imageStream, new JpegEncoder {
                                Quality = 2
                            });
                            imageStream.Seek(0, SeekOrigin.Begin);
                            await Context.Channel.SendFileAsync(imageStream, "needsmorejpeg.jpeg").ConfigureAwait(false);
                        }
            }
            return(CommandRuntimeResult.FromSuccess());
        }
Пример #10
0
        public async Task <RuntimeResult> EightBallAsync([Remainder] string input)
        {
            int responseCount = Config.Commands.EightBallResponses.Count;

            if (responseCount == 0)
            // This should hopefully never happen.
            {
                return(CommandRuntimeResult.FromError(
                           "The 8ball responses are not yet set, contact the bot developers."));
            }
            string response = Config.Commands.EightBallResponses[Random.Next(0, responseCount)];
            var    embed    = new EmbedBuilder
            {
                Author = new EmbedAuthorBuilder
                {
                    Name    = "The Magic 8Ball",
                    IconUrl = Context.Client.CurrentUser.GetAvatarUrlOrDefault()
                },
                Color        = ColorHelper.GetRandomColor(),
                ThumbnailUrl = Config.Icons.EightBall
            }
            .AddField("You asked...", input)
            .AddField("The 8 ball says...", response);

            await ReplyAsync("", embed : embed.Build()).ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess());
        }
Пример #11
0
        public async Task <RuntimeResult> GetInfoAsync()
        {
            var embedBuilder = new EmbedBuilder
            {
                Author = new EmbedAuthorBuilder
                {
                    Name    = "Bot Info:",
                    IconUrl = Context.Client.CurrentUser.GetAvatarUrlOrDefault()
                },
                ThumbnailUrl =
                    "https://emojipedia-us.s3.amazonaws.com/thumbs/120/twitter/103/information-source_2139.png",
                Color = new Color(61, 138, 192)
            };

            // Owners
            embedBuilder.AddField("Owners",
                                  string.Join(", ", Config.Owners.Select(x => Context.Client.GetUser(x).ToString())));

            // Application uptime
            var currentProcess = Process.GetCurrentProcess();

            embedBuilder.AddField("Uptime", (DateTime.Now - currentProcess.StartTime).Humanize());

            // Memory report
            var memInfoTitleBuilder       = new StringBuilder();
            var memInfoDescriptionBuilder = new StringBuilder();
            var heapBytes = GC.GetTotalMemory(false).Bytes();

            memInfoTitleBuilder.Append("Heap Size");
            memInfoDescriptionBuilder.Append(
                $"{Math.Round(heapBytes.LargestWholeNumberValue, 2)} {heapBytes.LargestWholeNumberSymbol}");
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                var workingSetBytes = currentProcess.WorkingSet64.Bytes();
                memInfoTitleBuilder.Append(" / Working Set");
                memInfoDescriptionBuilder.Append(
                    $" / {Math.Round(workingSetBytes.LargestWholeNumberValue, 2)} {workingSetBytes.LargestWholeNumberSymbol}");
            }
            embedBuilder.AddField(memInfoTitleBuilder.ToString(), memInfoDescriptionBuilder, true);

            // Application latency
            embedBuilder.AddField("Latency", Context.Client.Latency + "ms", true);

            // Discord application creation date
            var appInfo = await Context.Client.GetApplicationInfoAsync().ConfigureAwait(false);

            embedBuilder.AddField("Created On", appInfo.CreatedAt.UtcDateTime, true);

            // Last updated on based on file modification date
            embedBuilder.AddField("Last Update",
                                  File.GetLastWriteTimeUtc(Assembly.GetEntryAssembly().Location), true);

            // Lib version
            embedBuilder.AddField("Discord.NET Version", DiscordConfig.Version, true);
            await ReplyAsync("", embed : embedBuilder.Build()).ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess());
        }
Пример #12
0
        public async Task <RuntimeResult> ConfigPrefixAsync(string prefix)
        {
            var record = await CoreRepository.GetOrCreateGuildSettingsAsync(Context.Guild).ConfigureAwait(false);

            record.CommandPrefix = prefix;
            await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess($"Successfully changed prefix to {Format.Bold(prefix)}."));
        }
Пример #13
0
            public async Task <RuntimeResult> ConfigChannelAsync(SocketTextChannel channel)
            {
                var record = await CoreRepository.GetOrCreateGreetingsAsync(Context.Guild).ConfigureAwait(false);

                record.ChannelId = channel.Id;
                await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false);

                return(CommandRuntimeResult.FromSuccess($"Welcome channel set to: {channel.Mention}"));
            }
Пример #14
0
                public async Task <RuntimeResult> SetFriendCodeAsync([Remainder] string username)
                {
                    var record = await UserRepository.GetOrCreateGameAsync(Context.User).ConfigureAwait(false);

                    record.NintendoFriendCode = username;
                    await UserRepository.SaveRepositoryAsync().ConfigureAwait(false);

                    return(CommandRuntimeResult.FromSuccess(
                               $"Successfully set Nintendo Friend Code to {Format.Bold(username)}"));
                }
Пример #15
0
        public async Task <RuntimeResult> ModeratorPermsSetAsync([Remainder] GuildPermission guildPermission)
        {
            var record = await CoreRepository.GetOrCreateGuildSettingsAsync(Context.Guild).ConfigureAwait(false);

            record.ModeratorPermission = guildPermission;
            await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess(
                       $"Successfully changed the required moderator permission to {Format.Bold(guildPermission.Humanize(LetterCasing.Title))}."));
        }
Пример #16
0
                public Task <RuntimeResult> CheckFriendCodeAsync(SocketUser user = null)
                {
                    var targetUser = user ?? Context.User;
                    var record     = UserRepository.GetGame(targetUser);

                    return(Task.FromResult <RuntimeResult>(record?.NintendoFriendCode == null
                        ? CommandRuntimeResult.FromError("User hasn't setup their Nintendo Friend Code yet!")
                        : CommandRuntimeResult.FromInfo(
                                                               $"{targetUser.Mention}'s Nintendo Friend Code: {Format.Bold(record.NintendoFriendCode)}")));
                }
Пример #17
0
                public Task <RuntimeResult> CheckRiotAsync(SocketUser user = null)
                {
                    var targetUser = user ?? Context.User;
                    var record     = UserRepository.GetGame(targetUser);

                    return(Task.FromResult <RuntimeResult>(record?.RiotId == null
                        ? CommandRuntimeResult.FromError("User hasn't setup their Riot Id yet!")
                        : CommandRuntimeResult.FromInfo(
                                                               $"{targetUser.Mention}'s Riot Id: {Format.Bold(record.RiotId)}")));
                }
Пример #18
0
        public async Task <RuntimeResult> KickUserAsync(
            [RequireHierarchy] SocketGuildUser user,
            [Remainder] string reason = null)
        {
            await user.KickAsync(reason, new RequestOptions()
            {
                AuditLogReason = $"{Context.User} ({Context.User.Id}): {reason}"
            }).ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess($"User {user} has been kicked from the server."));
        }
Пример #19
0
        public async Task <RuntimeResult> NicknameChangeAsync([RequireHierarchy] SocketGuildUser user,
                                                              [Remainder] string nickname)
        {
            await user.ModifyAsync(x => x.Nickname = nickname,
                                   new RequestOptions()
            {
                AuditLogReason = $"{Context.User} ({Context.User.Id}): Nickname Update"
            })
            .ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess($"Successfully changed {user}'s name to {nickname}."));
        }
Пример #20
0
        public async Task <RuntimeResult> SearchAsync([Remainder] string query)
        {
            var embedQuery = await GoogleService.SearchAsync(query).ConfigureAwait(false);

            if (embedQuery == null)
            {
                return(CommandRuntimeResult.FromError("I could not get the search result for now, try again later."));
            }
            await ReplyAsync("", embed : embedQuery).ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess());
        }
Пример #21
0
                public async Task <RuntimeResult> SetSteamAsync([Remainder] string username)
                {
                    ulong id = await SteamService.GetIdFromVanityAsync(username).ConfigureAwait(false);

                    var record = await UserRepository.GetOrCreateGameAsync(Context.User).ConfigureAwait(false);

                    record.SteamId = id;
                    await UserRepository.SaveRepositoryAsync().ConfigureAwait(false);

                    return(CommandRuntimeResult.FromSuccess(
                               $"Successfully set steam to {Format.Bold((await SteamService.GetProfileAsync(id).ConfigureAwait(false))?.CustomURL ?? id.ToString())}"));
                }
Пример #22
0
        public async Task <RuntimeResult> LocationRemoveAsync()
        {
            var record = UserSettings.GetCoordinates(Context.User);

            if (record == null)
            {
                return(CommandRuntimeResult.FromError("You do not have a location set up yet!"));
            }
            await UserSettings.RemoveCoordinatesAsync(Context.User).ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess("You have successfully removed your location!"));
        }
Пример #23
0
        public async Task <RuntimeResult> ProfileAsync(SocketUser user = null)
        {
            //User Data
            var targetUser = user ?? Context.User;
            var record     = await UserRepository.GetOrCreateProfileAsync(targetUser).ConfigureAwait(false);

            using (var profileBase = Image.Load("Resources/Profile/base.png"))
                using (var avatarFrame = Image.Load("Resources/Profile/avatarFrame.png"))
                    using (var badge = Image.Load("Resources/Profile/badge.png"))
                        using (var avatarStream = await WebHelper.GetFileStreamAsync(HttpClient, new Uri(targetUser.GetAvatarUrl())).ConfigureAwait(false))
                            using (var finalImage = new MemoryStream())
                                using (var avatar = Image.Load(avatarStream))
                                {
                                    //Fonts & text rendering
                                    var robotoItalic = new FontCollection().Install("Resources/Profile/Fonts/Roboto-Italic.ttf");
                                    var roboto       = new FontCollection().Install("Resources/Profile/Fonts/Roboto-Regular.ttf");
                                    var textOptions  = new TextGraphicsOptions {
                                        HorizontalAlignment = HorizontalAlignment.Center
                                    };

                                    //Actual Image
                                    var final = profileBase.DrawImage(avatar.Resize(540, 540), new Size(), new Point(935, 134),
                                                                      GraphicsOptions.Default)
                                                .DrawImage(avatarFrame, new Size(), new Point(0, 0), GraphicsOptions.Default)
                                                .DrawText(targetUser.Username, robotoItalic.CreateFont(130), new Rgba32(106, 161, 196),
                                                          new Point(profileBase.Width / 2, 690), textOptions)
                                                .DrawText($"Member Since {targetUser.CreatedAt:M/d/yy}", robotoItalic.CreateFont(73),
                                                          new Rgba32(138, 145, 153),
                                                          new Point(profileBase.Width / 2, 840), textOptions)
                                                .DrawText($"Balance: {record.Balance}", roboto.CreateFont(82), new Rgba32(138, 145, 153),
                                                          new Point(profileBase.Width / 2, 930), textOptions)
                                                .DrawText("About Me:", robotoItalic.CreateFont(90), new Rgba32(106, 161, 196), new Point(340, 1130),
                                                          TextGraphicsOptions.Default)
                                                .DrawText(Regex.Replace(record.Summary, ".{55}", "$0\n"), roboto.CreateFont(70), new Rgba32(138, 145, 153), new Point(340, 1250),
                                                          TextGraphicsOptions.Default);

                                    //Verified Badge
                                    //TODO: Add some kind of verification system/reputation system?
                                    if (Config.Owners.Contains(targetUser.Id))
                                    {
                                        final.DrawImage(badge, new Size(), new Point(0, 0), GraphicsOptions.Default).Resize(500, 500).SaveAsPng(finalImage);
                                    }
                                    else
                                    {
                                        final.Resize(500, 500).SaveAsPng(finalImage);
                                    }

                                    //Sending the image
                                    finalImage.Seek(0, SeekOrigin.Begin);
                                    await Context.Channel.SendFileAsync(finalImage, "profile.png", $"Profile card for `{targetUser}`").ConfigureAwait(false);
                                }
            return(CommandRuntimeResult.FromSuccess());
        }
Пример #24
0
            public async Task <RuntimeResult> ConfigMessageAsync([Remainder] string message)
            {
                var record = await CoreRepository.GetOrCreateGreetingsAsync(Context.Guild).ConfigureAwait(false);

                if (message.Length > 1024)
                {
                    return(CommandRuntimeResult.FromError("Your welcome message is too long!"));
                }
                record.WelcomeMessage = message;
                await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false);

                return(CommandRuntimeResult.FromSuccess($"Welcome message set to: {Format.Bold(message)}"));
            }
Пример #25
0
        public async Task <RuntimeResult> GetLuminanceAsync(byte r, byte g, byte b)
        {
            var color = new Color(r, g, b);
            var embed = new EmbedBuilder
            {
                Color       = color,
                Description = $"Luminance value = {color.GetLuminanceFromColor()}"
            };

            await ReplyAsync("", embed : embed.Build()).ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess());
        }
Пример #26
0
            public async Task <RuntimeResult> CleanUserAsync(SocketUser user, int amount = 25)
            {
                var messages = (await GetMessageAsync(amount).ConfigureAwait(false)).Where(x => x.Author.Id == user.Id).ToList();

                if (messages.Count == 0)
                {
                    return(CommandRuntimeResult.FromError(MessagesNotFound));
                }
                await DeleteMessagesAsync(messages).ConfigureAwait(false);

                return(CommandRuntimeResult.FromSuccess(
                           $"Deleted {Format.Bold(messages.Count.ToString())} message(s) from user {Format.Bold(user.Mention)}!"));
            }
Пример #27
0
            public async Task <RuntimeResult> CleanAttachmentsAsync(int amount = 25)
            {
                var messages = (await GetMessageAsync(amount).ConfigureAwait(false)).Where(x => x.Attachments.Count > 0).ToList();

                if (messages.Count == 0)
                {
                    return(CommandRuntimeResult.FromError(MessagesNotFound));
                }
                await DeleteMessagesAsync(messages).ConfigureAwait(false);

                return(CommandRuntimeResult.FromSuccess(
                           $"Deleted {Format.Bold(messages.Count.ToString())} message(s) containing attachments!"));
            }
Пример #28
0
        public async Task <RuntimeResult> BanUserAsync(
            [RequireHierarchy] ulong userId,
            int days = 0,
            [Remainder] string reason = null)
        {
            await Context.Guild.AddBanAsync(userId, days, reason, new RequestOptions()
            {
                AuditLogReason = $"{Context.User} ({Context.User.Id}): {reason} (BAN)"
            })
            .ConfigureAwait(false);

            return(CommandRuntimeResult.FromSuccess($"User {userId} has been banned from the server."));
        }
Пример #29
0
            public async Task <RuntimeResult> SetSummaryAsync([Remainder] string summary)
            {
                if (summary.Length > 500)
                {
                    return(CommandRuntimeResult.FromError("Your summary needs to be shorter than 500 characters!"));
                }
                var record = await UserRepository.GetOrCreateProfileAsync(Context.User).ConfigureAwait(false);

                record.Summary = summary;
                await UserRepository.SaveRepositoryAsync().ConfigureAwait(false);

                return(CommandRuntimeResult.FromSuccess($"Successfully set summary to {Format.Bold(summary)}"));
            }
Пример #30
0
            public async Task <RuntimeResult> DisableWelcomeAsync()
            {
                var record = await CoreRepository.GetOrCreateGreetingsAsync(Context.Guild).ConfigureAwait(false);

                if (!record.IsJoinEnabled)
                {
                    return(CommandRuntimeResult.FromError("The welcome message is already disabled!"));
                }
                record.IsJoinEnabled = false;
                await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false);

                return(CommandRuntimeResult.FromSuccess("Successfully disabled the welcome message!"));
            }