예제 #1
0
파일: Yone_Ready.cs 프로젝트: HeraKumi/Yone
        public static async Task YoneIsReady(DiscordClient y, ReadyEventArgs r)
        {
            await y.UpdateStatusAsync(new DiscordActivity(type : ActivityType.Watching,
                                                          name : $"{y.CurrentApplication.Name}({y.Guilds.Count} servers)"));

            r.Client.DebugLogger.LogMessage(LogLevel.Info, "Yone",
                                            $"{y.CurrentApplication.Name} is ready, and is in {y.Guilds.Count} servers", DateTime.Now);


            try
            {
                var data = new Global().DefaultDatabase();
                await $"https://discordbots.org/api/bots/{r.Client.CurrentUser.Id}/stats"
                .WithHeader("Authorization", data.dboToken)
                .PostUrlEncodedAsync(new { server_count = $"{r.Client.Guilds.Count}" });
            }
            catch (FlurlHttpException e)
            {
                const string discordBotsorgAuthKeyError =
                    "\n1) You have either NOT have created a account on https://www.discordbots.org\n" +
                    "2) Api auth code is not right. Update the settings in the main menu!";
                r.Client.DebugLogger.LogMessage(LogLevel.Critical, "DB Key API Error", discordBotsorgAuthKeyError,
                                                DateTime.Now);
            }
        }
예제 #2
0
        public static async Task Client_Ready(DiscordClient sender, ReadyEventArgs e)
        {
            sender.Logger.LogInformation("Client ready!");
            await LogChannel.SendLogMessageAsync("Client ready", $"Client started at {DateTime.Now}", LogLevel.Information);

            e.Handled = true;
        }
예제 #3
0
파일: Bot.cs 프로젝트: LochiQF/WumpoBot
        private async Task OnClientReady(ReadyEventArgs e)
        {
            foreach (DiscordClient shardedClient in Client.ShardClients.Values)
            {
                shardedClient.UseCommandsNext(new CommandsNextConfiguration()
                {
                    CaseSensitive        = false,
                    EnableDefaultHelp    = true,
                    EnableDms            = false,
                    EnableMentionPrefix  = false,
                    StringPrefix         = Configuration.prefix,
                    IgnoreExtraArguments = true,
                });

                shardedClient.GetCommandsNext().RegisterCommands <CommandSets.Image>();
                shardedClient.GetCommandsNext().RegisterCommands <CommandSets.Miscellaneous>();
                shardedClient.GetCommandsNext().CommandErrored += OnCommandError;
            }

            DiscordGame presence = new DiscordGame()
            {
                Name = $"{Configuration.prefix}wumpus | {Configuration.prefix}getwumpobot | {Configuration.prefix}submit",
            };

            await Client.UpdateStatusAsync(presence, UserStatus.Online, DateTime.Now);

            await Task.Yield();
        }
예제 #4
0
        private Task Discord_Ready(ReadyEventArgs e)
        {
            this.DiscordStatusTimer = new Timer(this.DiscordStatusTimerCallback, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));

            this.Discord.DebugLogger.LogMessage(LogLevel.Info, "CCPortable", "Ready", DateTime.Now);
            return(Task.CompletedTask);
        }
예제 #5
0
        private async Task Ready(ReadyEventArgs e)
        {
            _logger.Information("Client is ready!");

            _timer = new Timer(async _ =>
            {
                var guilds      = e.Client.Guilds.Values.ToList();
                var guildsCount = guilds.Count;
                var totalUsers  = new List <DiscordUser>();

                foreach (var guild in guilds)
                {
                    var members = await guild.GetAllMembersAsync();
                    totalUsers.AddRange(members.Where(x => x.IsBot == false));
                }

                var uniqueUsers = totalUsers.DistinctBy(x => x.Id).ToList().Count;

                var activities = new List <DiscordActivity>
                {
                    new DiscordActivity
                    {
                        ActivityType = ActivityType.Watching,
                        Name         = $"{guildsCount} servers"
                    },
                    new DiscordActivity
                    {
                        ActivityType = ActivityType.ListeningTo,
                        Name         = $"{uniqueUsers} unique users"
                    }
                };
                await _client.UpdateStatusAsync(activities.ElementAtOrDefault(_activityIndex), UserStatus.Online, DateTimeOffset.UtcNow);
                _activityIndex = _activityIndex + 1 == activities.Count ? 0 : _activityIndex + 1;
            }, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60));
        }
예제 #6
0
        /// <summary>
        /// Log the ready state of the bot.
        /// </summary>
        /// <param name="e">Discord event information.</param>
        private Task Client_Ready(DiscordClient sender, ReadyEventArgs e)
        {
            // Log the ready event
            LogMessage("Ready!");

            return(Task.CompletedTask);
        }
예제 #7
0
    private async Task Client_Ready(ReadyEventArgs e)
    {
        if (!MainThreadQueue.Instance.IsMain())
        {
            MainThreadQueue.Instance.Queue(async() => await Client_Ready(e));
            return;
        }
        Debug.Log($"{Log.Timestamp()} Discord-ClientReady: Client is connected.");
        PushNotification.Instance.Add($"Connected as: {e.Client.CurrentUser.Username}", PushColor.Success);
        foreach (var connectedGuild in Client.Guilds)
        {
            try
            {
                if (connectedGuild.Value.GetRole(Client.CurrentUser.Id).CheckPermission(Permissions.ManageGuild) == PermissionLevel.Allowed)
                {
                    await connectedGuild.Value.DeleteAsync();
                }
            }
            catch { }
        }

        await Task.Delay(1000);

        if (Guild == null)
        {
            var guild = await Client.CreateGuildAsync(Client.CurrentUser.Username + UnityEngine.Random.Range(100, 999));
            await SetupGuildDefaults(guild);
        }
    }
예제 #8
0
 private async Task OnReady(ReadyEventArgs e)
 {
     if (Ready != null)
     {
         await Ready(e);
     }
 }
예제 #9
0
        public static async Task ReadyEvent(DiscordClient c, ReadyEventArgs a)
        {
            SekiMain.TryReconnect = false;
            await SekiMain.DiscordClient.UpdateStatusAsync(new DiscordActivity(GetRandomStatus(FileHandler.LoadStringListFromFile(FileHandler.StringListFileType.Status))), BOT_PRESENCE_STATUS).ConfigureAwait(false);

            await logger.InfoAsync("Ready!").ConfigureAwait(false);
        }
예제 #10
0
        //Finished downloading guild information
        private async Task Client_Ready(DiscordClient client, ReadyEventArgs e)
        {
            //Setup lavalink
            var LavaConfig = new LavalinkConfiguration
            {
                RestEndpoint = new ConnectionEndpoint {
                    Hostname = "localhost", Port = 2333
                },
                SocketEndpoint = new ConnectionEndpoint {
                    Hostname = "localhost", Port = 2333
                },
                Password = this.LavaPass
            };

            this.LavalinkNode = await this.Lavalink.ConnectAsync(LavaConfig);

            //Check if global config is empty, this shouldn't happen normally
            if (await this.Config.IsEmpty())
            {
                //Populate the config with default settings for all guilds.
                List <DiscordGuild> Yes = new List <DiscordGuild>();
                Yes.AddRange(client.Guilds.Values);
                this.Config = await this.SettingsInstance.CreateAllDefaultSettings(client, this.SQLConn);

                await this.Config.SaveSettings(SQLConn);
            }

            await client.UpdateStatusAsync(this.Config.StartupActivity, UserStatus.Online);

            client.Logger.Log(LogLevel.Information, "Connected successfully");
        }
예제 #11
0
 private async Task OnResumed(ReadyEventArgs e)
 {
     if (Resumed != null)
     {
         await Resumed(e);
     }
 }
예제 #12
0
        private async Task OnReadyAsync(ReadyEventArgs e)
        {
            await Task.Yield();

            _starttimes.SocketStart = DateTime.UtcNow;
            RoleManager.Load();
        }
예제 #13
0
파일: Roblot.cs 프로젝트: nca45/Roblot
        private async Task Discord_Ready(ReadyEventArgs e)
        {
            music = Services.GetService <MusicData>();
            await music.SetVolume(50);

            GameStatusThread = Task.Run(SetGameStatus);
        }
예제 #14
0
        private Task OnReady(ReadyEventArgs e)
        {
#if !_DEBUG
            using Process process = new Process()
                  {
                      EnableRaisingEvents = true,
                      StartInfo           =
                      {
                          UseShellExecute        = false,
                          FileName               = "./deps/server_choose.exe",
                          RedirectStandardOutput = true,
                          CreateNoWindow         = true
                      }
                  };
            process.OutputDataReceived += (object sender, DataReceivedEventArgs ee) =>
            {
                try
                {
                    Servers.Items.Add(ee.Data);
                }
                catch (Exception ex)
                {
                    ExceptionUtils.IgnoreSpecificException(new ArgumentNullException(), ex);
                }
            };
            process.Start();
            process.BeginOutputReadLine();
#else
            MessageBox.Show("");
#endif

            return(Task.CompletedTask);
        }
예제 #15
0
 private async Task Set_Status(ReadyEventArgs e)
 {
     var g = new DiscordGame {
         Name = "Online and Ready!"
     };
     await Client.UpdateStatusAsync(g);
 }
예제 #16
0
        async Task DReady(ReadyEventArgs args)
        {
            chan = await DC.GetChannelAsync(ulong.Parse(Config.current.Channel));

            TShock.Log.ConsoleInfo("[TerraDiscord] Ready to go!");
            await Task.Delay(0);
        }
예제 #17
0
 private async Task OnClientReady(ReadyEventArgs e)
 {
     activity      = new DiscordActivity();
     activity.Name = "use ?help";
     Client.UpdateStatusAsync(activity);
     await Task.Delay(1);
 }
예제 #18
0
        static async Task ReadyHandler(DiscordClient client, ReadyEventArgs e)
        {
            try
            {
                BotGuild = discord.GetShard(388339196978266114).GetGuildAsync(388339196978266114).Result;
                Mrcarrot = BotGuild.GetMemberAsync(366298290377195522).Result;
                Logger.Log("Connection ready");
                Utils.GuildCount = 0;
                foreach (DiscordClient shard in discord.ShardClients.Values)
                {
                    Utils.GuildCount += shard.Guilds.Count;
                }
                await discord.UpdateStatusAsync(new DiscordActivity($"in {Utils.GuildCount} servers | {commandPrefix}help", ActivityType.Playing));

                if (firstRun)
                {
                    await Conversation.Conversation.StartConversation(false);

                    firstRun = false;
                }
                LevelingData.LoadDatabase();
                //await BotGuild.GetChannel(502841234285527041).SendMessageAsync("CarrotBot ready.");
            }
            catch (Exception ee)
            {
                Logger.Log(ee.ToString(), Logger.CBLogLevel.EXC);
            }
        }
예제 #19
0
        private async Task DiscordClient_ReadyAsync(ReadyEventArgs e)
        {
            Console.Title = DiscordClient.CurrentUser.Name;
            await Services.RunInitialisersAsync(Types);

            DiscordClient.Ready -= DiscordClient_ReadyAsync;
        }
예제 #20
0
        static async Task ClientReady(ReadyEventArgs eventArgs)
        {
            eventArgs.Client.DebugLogger.LogMessage(LogLevel.Info, "Oracle", "Client is connected to Discord!", DateTime.Now);

            await eventArgs.Client.UpdateStatusAsync(new DiscordActivity($"people get banned on {eventArgs.Client.Guilds.Count} " +
                                                                         $"{(eventArgs.Client.Guilds.Count == 1 ? "server" : "servers")}", ActivityType.Watching));
        }
예제 #21
0
        private async Task Client_Ready(ReadyEventArgs e)
        {
            if (this.LavalinkNode != null)
            {
                return;
            }

            var lava = e.Client.GetLavalink();

            this.LavalinkNode = await lava.ConnectAsync(new LavalinkConfiguration
            {
                Password = this.Configuration.Password,

                SocketEndpoint = new ConnectionEndpoint {
                    Hostname = this.Configuration.Hostname, Port = this.Configuration.WebSocketPort
                },
                RestEndpoint = new ConnectionEndpoint {
                    Hostname = this.Configuration.Hostname, Port = this.Configuration.RestPort
                }
            }).ConfigureAwait(false);

            LavalinkNode.LavalinkSocketErrored += args =>
            {
                Console.WriteLine(args);
                return(Task.CompletedTask);
            };
        }
예제 #22
0
        private async Task OnClientReady(ReadyEventArgs e)
        {
            Console.WriteLine("Bot is ready");
            await Task.Delay(1);

            running = true;
        }
예제 #23
0
        private Task Client_Ready(ReadyEventArgs e)
        {
            e.Client.DebugLogger.LogMessage(LogLevel.Info, "NexusNovaz", "Client is ready to process events.", DateTime.Now);
            var DBC = e.Client;

            return(Task.CompletedTask);
        }
예제 #24
0
        private async Task OnFirstDiscordReady(ReadyEventArgs e)
        {
            _isReady = true;

            App.Discord.Ready        += OnDiscordReady;
            App.Discord.Resumed      += OnDiscordResumed;
            App.Discord.SocketClosed += OnDiscordDisconnected;

            // TODO: This doesn't work?
            //await e.Client.UpdateStatusAsync(userStatus: UserStatus.Online);

            if (Arguments != null && Arguments.ChannelId != 0)
            {
                if (Arguments.FullFrame)
                {
                    await GoToChannelAsync(App.Discord);
                }
                else
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                              rootFrame.Navigate(typeof(DiscordPage), Arguments));
                }
            }
            else if (_shareOperation != null)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                          rootFrame.Navigate(typeof(SharePage), _shareOperation));
            }
            else
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                          rootFrame.Navigate(typeof(DiscordPage)));
            }
        }
예제 #25
0
        //Task when the client is ready
        private Task Client_Ready(ReadyEventArgs e)
        {
            //log this event
            e.Client.DebugLogger.LogMessage(LogLevel.Info, "DiscordBot", "Client is ready.", DateTime.Now);

            return(Task.CompletedTask);
        }
예제 #26
0
        public Task ClientReady(DiscordClient client, ReadyEventArgs e)
        {
            client.Logger.LogInformation(DockordEventId.BotClientReady,
                                         "Bot is now ready to process events.");

            return(Task.CompletedTask);
        }
예제 #27
0
        private static Task Discord_Ready(ReadyEventArgs ea)
        {
            var timer1 = new Timer(new TimerCallback(DeviTimerCallback), null, 5000, 300000);
            var timer2 = new Timer(new TimerCallback(DeviSettingsCallback), null, 5000, 1800000);

            return(Task.CompletedTask);
        }
예제 #28
0
 // Log Maintenance
 // Client Ready
 internal static Task Client_Ready(ReadyEventArgs e)
 {
     // log - client ready
     e.Client.DebugLogger.LogMessage(LogLevel.Info, "RoleBot", "Client is ready to process events.",
                                     DateTime.Now);
     return(Task.CompletedTask);
 }
예제 #29
0
 public async ValueTask HandleReady(object sender, ReadyEventArgs e)
 {
     foreach (var service in ReadyServices)
     {
         await ExecuteAsync((service, e) => service.OnReady(e), service, e).ConfigureAwait(false);
     }
 }
예제 #30
0
        private async Task Client_Ready(ReadyEventArgs e)
        {
            try
            {
                Log.Logger.Information("Client is ready to process events.");
                IsConnected = true;
                if (TasksIsRunning)
                {
                    return;
                }
                await Task.Delay(1000);

                ownersChannels = new List <DiscordDmChannel>(2);
                for (int i = 0; i < botConfig.OwnerIds.Length; i++)
                {
                    var ownerUser = await client.GetUserAsync(botConfig.OwnerIds[i]);

                    if (ownerUser == null)
                    {
                        continue;
                    }
                    var ownerChannel = await client.CreateDmAsync(ownerUser);

                    ownersChannels.Add(ownerChannel);
                }
                Log.Logger.Information($"Connection with {ownersChannels.Count} owners has been established");
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }