Beispiel #1
0
        public async Task LeaveGuildAsync(string name)
        {
            var guild = ulong.TryParse(name, out var guildId)
                ? RiasBot.GetGuild(guildId)
                : RiasBot.Client.ShardClients
                        .SelectMany(x => x.Value.Guilds)
                        .FirstOrDefault(x => string.Equals(x.Value.Name, name)).Value;

            if (guild is null)
            {
                await ReplyErrorAsync(Localization.BotGuildNotFound);

                return;
            }

            var embed = new DiscordEmbedBuilder
            {
                Color       = RiasUtilities.ConfirmColor,
                Description = GetText(Localization.BotLeftGuild, guild.Name)
            }.AddField(GetText(Localization.CommonId), guild.Id.ToString(), true).AddField(GetText(Localization.CommonMembers), guild.MemberCount.ToString(), true);

            await ReplyAsync(embed);

            await guild.LeaveAsync();
        }
Beispiel #2
0
        public async Task HelpAsync()
        {
            var embed = new LocalEmbedBuilder
            {
                Color  = RiasUtilities.ConfirmColor,
                Author = new LocalEmbedAuthorBuilder
                {
                    Name    = GetText(Localization.HelpTitle, RiasBot.CurrentUser.Name, Rias.Version),
                    IconUrl = RiasBot.CurrentUser.GetAvatarUrl()
                },
                Footer = new LocalEmbedFooterBuilder().WithText("© 2018-2020 Copyright: Koneko#0001")
            };

            embed.WithDescription(GetText(Localization.HelpInfo, Context.Prefix));

            var          links     = new StringBuilder();
            const string delimiter = " • ";

            if (!string.IsNullOrEmpty(Credentials.OwnerServerInvite))
            {
                var ownerServer = RiasBot.GetGuild(Credentials.OwnerServerId);
                links.Append(delimiter)
                .Append(GetText(Localization.HelpSupportServer, ownerServer.Name, Credentials.OwnerServerInvite))
                .Append("\n");
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Credentials.Invite))
            {
                links.Append(GetText(Localization.HelpInviteMe, Credentials.Invite)).Append("\n");
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Credentials.Website))
            {
                links.Append(GetText(Localization.HelpWebsite, Credentials.Website)).Append("\n");
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Credentials.Patreon))
            {
                links.Append(GetText(Localization.HelpDonate, Credentials.Patreon)).Append("\n");
            }

            embed.AddField(GetText(Localization.HelpLinks), links.ToString());
            await ReplyAsync(embed);
        }
Beispiel #3
0
        public async Task HelpAsync()
        {
            var embed = new DiscordEmbedBuilder()
                        .WithColor(RiasUtilities.ConfirmColor)
                        .WithAuthor(GetText(Localization.HelpTitle, RiasBot.CurrentUser !.Username, RiasBot.Version), RiasBot.CurrentUser.GetAvatarUrl(ImageFormat.Auto))
                        .WithFooter(GetText(Localization.HelpFooter))
                        .WithDescription(GetText(Localization.HelpInfo, Context.Prefix));

            var          links     = new StringBuilder();
            const string delimiter = " • ";

            if (!string.IsNullOrEmpty(Configuration.OwnerServerInvite))
            {
                var ownerServer = RiasBot.GetGuild(Configuration.OwnerServerId);
                links.Append(delimiter)
                .Append(GetText(Localization.HelpSupportServer, ownerServer !.Name, Configuration.OwnerServerInvite))
                .AppendLine();
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Configuration.Invite))
            {
                links.Append(GetText(Localization.HelpInviteMe, Configuration.Invite)).AppendLine();
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Configuration.Website))
            {
                links.Append(GetText(Localization.HelpWebsite, Configuration.Website)).AppendLine();
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Configuration.Patreon))
            {
                links.Append(GetText(Localization.HelpDonate, Configuration.Patreon)).AppendLine();
            }

            embed.AddField(GetText(Localization.HelpLinks), links.ToString());
            await ReplyAsync(embed);
        }
Beispiel #4
0
            public MuteContext(RiasBot riasBot, ulong guildId, ulong moderatorId, ulong memberId, ulong channelId)
            {
                Guild    = riasBot.GetGuild(guildId);
                GuildId  = guildId;
                MemberId = memberId;

                if (Guild != null)
                {
                    if (Guild.Members.TryGetValue(moderatorId, out var moderator))
                    {
                        Moderator = moderator;
                    }

                    if (Guild.Members.TryGetValue(memberId, out var member))
                    {
                        Member = member;
                    }

                    SourceChannel = Guild.GetChannel(channelId);
                }

                SentByTimer = true;
            }
Beispiel #5
0
        public async Task LeaveGuildAsync(string name)
        {
            var guild = Snowflake.TryParse(name, out var guildId)
                ? RiasBot.GetGuild(guildId)
                : RiasBot.Guilds.FirstOrDefault(x => string.Equals(x.Value.Name, name)).Value;

            if (guild is null)
            {
                await ReplyErrorAsync(Localization.BotGuildNotFound);

                return;
            }

            var embed = new LocalEmbedBuilder()
            {
                Color       = RiasUtilities.ConfirmColor,
                Description = GetText(Localization.BotLeftGuild, guild.Name)
            }.AddField(GetText(Localization.CommonId), guild.Id, true).AddField(GetText(Localization.CommonUsers), guild.MemberCount, true);

            await ReplyAsync(embed);

            await guild.LeaveAsync();
        }
            public async Task StatsAsync()
            {
                var embed = new LocalEmbedBuilder
                {
                    Color  = RiasUtilities.ConfirmColor,
                    Author = new LocalEmbedAuthorBuilder
                    {
                        Name    = GetText(Localization.UtilityStats, RiasBot.CurrentUser.Name, Rias.Version),
                        IconUrl = RiasBot.CurrentUser.GetAvatarUrl()
                    },
                    ThumbnailUrl = RiasBot.CurrentUser.GetAvatarUrl(),
                    Footer       = new LocalEmbedFooterBuilder().WithText("© 2018-2020 Copyright: Koneko#0001")
                }.AddField(GetText(Localization.UtilityAuthor), Rias.Author, true)
                .AddField(GetText(Localization.UtilityBotId), RiasBot.CurrentUser.Id, true)
                .AddField(GetText(Localization.UtilityMasterId), Credentials.MasterId, true)
                .AddField(GetText(Localization.UtilityShard), $"{RiasBot.GetShardId(Context.Guild?.Id ?? 0) + 1}/{RiasBot.Shards.Count}", true)
                .AddField(GetText(Localization.UtilityInServer), Context.Guild?.Name ?? "-", true)
                .AddField(GetText(Localization.UtilityCommandsAttempted), CommandHandlerService.CommandsAttempted, true)
                .AddField(GetText(Localization.UtilityCommandsExecuted), CommandHandlerService.CommandsExecuted, true)
                .AddField(GetText(Localization.UtilityUptime), Rias.UpTime.Elapsed.Humanize(5, new CultureInfo(Localization.GetGuildLocale(Context.Guild?.Id)),
                                                                                            TimeUnit.Month, TimeUnit.Second), true)
                .AddField(GetText(Localization.UtilityPresence), $"{RiasBot.Guilds.Count} {GetText(Localization.UtilityServers)}\n" +
                          $"{RiasBot.Guilds.Sum(x => x.Value.TextChannels.Count)} {GetText(Localization.UtilityTextChannels)}\n" +
                          $"{RiasBot.Guilds.Sum(x => x.Value.TextChannels.Count)} {GetText(Localization.UtilityVoiceChannels)}\n" +
                          $"{RiasBot.Users.Count} {GetText(Localization.CommonUsers)}\n", true);

                var          links     = new StringBuilder();
                const string delimiter = " • ";

                if (!string.IsNullOrEmpty(Credentials.OwnerServerInvite))
                {
                    var ownerServer = RiasBot.GetGuild(Credentials.OwnerServerId);
                    links.Append(delimiter)
                    .Append(GetText(Localization.HelpSupportServer, ownerServer.Name, Credentials.OwnerServerInvite))
                    .Append("\n");
                }

                if (links.Length > 0)
                {
                    links.Append(delimiter);
                }
                if (!string.IsNullOrEmpty(Credentials.Invite))
                {
                    links.Append(GetText(Localization.HelpInviteMe, Credentials.Invite)).Append("\n");
                }

                if (links.Length > 0)
                {
                    links.Append(delimiter);
                }
                if (!string.IsNullOrEmpty(Credentials.Website))
                {
                    links.Append(GetText(Localization.HelpWebsite, Credentials.Website)).Append("\n");
                }

                if (links.Length > 0)
                {
                    links.Append(delimiter);
                }
                if (!string.IsNullOrEmpty(Credentials.Patreon))
                {
                    links.Append(GetText(Localization.HelpDonate, Credentials.Patreon)).Append("\n");
                }

                embed.AddField(GetText(Localization.HelpLinks), links.ToString());

                await ReplyAsync(embed);
            }