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); } }
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; }
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(); }
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); }
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)); }
/// <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); }
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); } }
private async Task OnReady(ReadyEventArgs e) { if (Ready != null) { await Ready(e); } }
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); }
//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"); }
private async Task OnResumed(ReadyEventArgs e) { if (Resumed != null) { await Resumed(e); } }
private async Task OnReadyAsync(ReadyEventArgs e) { await Task.Yield(); _starttimes.SocketStart = DateTime.UtcNow; RoleManager.Load(); }
private async Task Discord_Ready(ReadyEventArgs e) { music = Services.GetService <MusicData>(); await music.SetVolume(50); GameStatusThread = Task.Run(SetGameStatus); }
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); }
private async Task Set_Status(ReadyEventArgs e) { var g = new DiscordGame { Name = "Online and Ready!" }; await Client.UpdateStatusAsync(g); }
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); }
private async Task OnClientReady(ReadyEventArgs e) { activity = new DiscordActivity(); activity.Name = "use ?help"; Client.UpdateStatusAsync(activity); await Task.Delay(1); }
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); } }
private async Task DiscordClient_ReadyAsync(ReadyEventArgs e) { Console.Title = DiscordClient.CurrentUser.Name; await Services.RunInitialisersAsync(Types); DiscordClient.Ready -= DiscordClient_ReadyAsync; }
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)); }
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); }; }
private async Task OnClientReady(ReadyEventArgs e) { Console.WriteLine("Bot is ready"); await Task.Delay(1); running = true; }
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); }
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))); } }
//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); }
public Task ClientReady(DiscordClient client, ReadyEventArgs e) { client.Logger.LogInformation(DockordEventId.BotClientReady, "Bot is now ready to process events."); return(Task.CompletedTask); }
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); }
// 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); }
public async ValueTask HandleReady(object sender, ReadyEventArgs e) { foreach (var service in ReadyServices) { await ExecuteAsync((service, e) => service.OnReady(e), service, e).ConfigureAwait(false); } }
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()); } }