Exemplo n.º 1
0
        public static async Task Initialize()
        {
            var timer = new Timer(900000);

            timer.Enabled   = true;
            timer.AutoReset = true;
            timer.Elapsed  += async(s, e) =>
            {
                DiscordShardedClient  client = ConfigProperties.Client;
                AuthDiscordBotListApi api    = ConfigProperties.TopGgApi;

                int guildCount = client.Guilds.Count;
                int shardCount = client.Shards.Count;

                try
                {
                    await api.UpdateStats(guildCount, shardCount);
                }
                catch (Exception exception)
                {
                    await ConsoleLogger.LogAsync(exception, "An exception occurred when trying to update the " +
                                                 "Top.GG guild and shard stats.");
                }

                await ConsoleLogger.LogAsync($"Guild and shard counts have been " +
                                             $"posted to Top.GG. [Guilds: {guildCount:N0} | " +
                                             $"Shards: {shardCount:N0}]", LogLvl.INFO);
            };
        }
Exemplo n.º 2
0
 private async Task UpdateDiscordBots(SocketGuild _)
 {
     if (_topGGAPI != null && _lastDiscordBotsSent.AddMinutes(10).CompareTo(DateTime.Now) < 0)
     {
         _lastDiscordBotsSent = DateTime.Now;
         await _topGGAPI.UpdateStats(Client.Guilds.Count);
     }
 }
Exemplo n.º 3
0
 private async Task UpdateDiscordBots()
 {
     if (dblApi != null && lastDiscordBotsSent.AddMinutes(10).CompareTo(DateTime.Now) < 0)
     {
         lastDiscordBotsSent = DateTime.Now;
         await dblApi.UpdateStats(client.Guilds.Count);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Updates the server statistics for DBL
 /// </summary>
 /// <param name="guildCount">The number of servers the bot is in</param>
 public async void UpdateStats(int guildCount)
 {
     if (AuthAPI == null)
     {
         return;
     }
     await AuthAPI.UpdateStats(guildCount);
 }
Exemplo n.º 5
0
        private static async Task Client_JoinedGuild(SocketGuild arg)
        {
            var List = new List <EmbedFieldBuilder>()
            {
                new EmbedFieldBuilder()
                {
                    Name  = "Thank you!",
                    Value = "Thank you for inviting me! 💜 - I'm still learning and growing, so it means a lot."
                },
                new EmbedFieldBuilder()
                {
                    Name  = "Links:",
                    Value = $"[MGX's Server](https://discord.gg/yPGer64)\n[Invite](https://discordapp.com/oauth2/authorize?client_id={Client.CurrentUser.Id}&scope=bot&permissions=8)"
                }
            };
            EmbedBuilder ToSend = new EmbedBuilder()
            {
                Color  = Color.Teal,
                Fields = List,
                Footer = new EmbedFooterBuilder()
                {
                    Text = $"MGX"
                },
                Timestamp = DateTime.UtcNow
            };

            await arg.TextChannels.First().SendMessageAsync("", false, ToSend.Build());

            var Builder = new EmbedBuilder()
            {
                Footer = new EmbedFooterBuilder()
                {
                    Text = $"MGX • {DateTime.UtcNow.ToShortTimeString()}"
                },
                Color       = Color.Teal,
                Title       = $"Thank you, {arg.Owner.Username}",
                Description = $"Thank you so much for using MGX!  :pleading_face:  - To get started, simply use `{Prefix}help` in your server.\n\nIf you need any support, just [click here](https://discord.gg/yPGer64)"
            };
            await arg.Owner.SendMessageAsync("", false, Builder.Build());

            var Log = new EmbedBuilder()
            {
                Color       = Color.DarkerGrey,
                Description = $"Joined guild: {arg.Name}",
                Timestamp   = DateTime.UtcNow,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{arg.Id}"
                },
                ThumbnailUrl = arg.IconUrl ?? Client.CurrentUser.GetAvatarUrl(),
            };

            LogEvent.SendLog(Log);

            await Client.SetGameAsync($"{Client.Guilds.Count} Guilds | {Prefix}help", null, ActivityType.Watching);

            await DiscordBotListClient.UpdateStats(Client.Guilds.Count);
        }
 internal void UpdateServerCount(DiscordSocketClient client)
 {
     if (!connected)
     {
         return;
     }
     if (client.CurrentUser.Id == botID)
     {
         DblApiAuth.UpdateStats(client.Guilds.Count);
     }
 }
Exemplo n.º 7
0
        public virtual async Task RunAsync()
        {
            if (DateTime.Now > lastTimeUpdated + updateTime)
            {
                await api.UpdateStats(
                    (await client.GetGuildsAsync()).Count
                    );

                lastTimeUpdated = DateTime.Now;
                SendLog("Submitted stats to Top.gg!");
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Updates the guild count, by displaying it as an activity.
        /// </summary>
        /// <returns>A Task that sets the activity</returns>
        public static async Task UpdateServerCount()
        {
            await Program.Client.SetActivityAsync(new Game($"{Program.Client.Guilds.Count} servers", ActivityType.Watching));

            try
            {
                if (Program.Client.CurrentUser.Id == 305398845389406209)
                {
                    await DiscordBotList.UpdateStats(Program.Client.Guilds.Count);
                }
            }
            catch (Exception e)
            {
                await Program.MopsLog(new LogMessage(LogSeverity.Error, "", "discord bot list api failed", e));
            }
        }
Exemplo n.º 9
0
 public static void UpdateGuildCount(int amount)
 {
     Task.Run(() => DblApi.UpdateStats(amount));
 }