private static void BotActivityChangeCallback(object?_) { if (_ is TheGodfatherBot bot) { if (bot.Client is null || bot.Client.CurrentUser is null) { Log.Error("BotActivityChangeCallback detected null client/user - this should not happen but is not nececarily an error"); return; } BotActivityService bas = bot.Services.GetRequiredService <BotActivityService>(); if (!bas.StatusRotationEnabled) { return; } try { BotStatus?status = bas.GetRandomStatus(); if (status is null) { Log.Warning("No extra bot statuses present in the database."); } DiscordActivity activity = status is { } ? new DiscordActivity(status.Status, status.Activity) : new DiscordActivity($"@{bot.Client?.CurrentUser.Username} help", ActivityType.Playing); AsyncExecutionService async = bot.Services.GetRequiredService <AsyncExecutionService>(); async.Execute(bot.Client !.UpdateStatusAsync(activity)); Log.Debug("Changed bot status to {ActivityType} {ActivityName}", activity.ActivityType, activity.Name); } catch (Exception e) {
private async Task OnClientReady(ReadyEventArgs e) { activity = new DiscordActivity(); activity.Name = "use ?help"; Client.UpdateStatusAsync(activity); await Task.Delay(1); }
public async Task RunAsync() { var act = new DiscordActivity("the screams of your ancestors", ActivityType.ListeningTo); await Discord.ConnectAsync(act, UserStatus.DoNotDisturb).ConfigureAwait(false); await Task.Delay(-1).ConfigureAwait(false); }
private async Task SetGameStatus() { await Task.CompletedTask; var status = configuration.games; int index = 0; // Update the status indefinitely while (true) { if (index >= status.Length) { index = 0; } DiscordActivity updateActivity = new DiscordActivity { Name = status[index], ActivityType = ActivityType.Watching }; await Discord.UpdateStatusAsync(updateActivity); await Task.Delay(TimeSpan.FromMinutes(5)); index++; } }
public async Task SetGame(CommandContext ctx, [RemainingTextAttribute] string game) { bool isOwner = false; foreach (var owner in ctx.Client.CurrentApplication.Owners) { if (ctx.User.Id == owner.Id) { isOwner = true; break; } } if (isOwner) { var Game = new DiscordActivity() { Name = $"{game}" }; await ctx.Client.UpdateStatusAsync(Game); await ctx.RespondAsync($"Game is now: **{game}**"); } else { await ctx.RespondAsync("Only Bot Owners can use this command!"); } }
// copy-pasted function from kekbotSharp, but heavily modifyed to suit my needs // thanks, jorge! private static async void GameTimerCallback(object _) { var client = _ as DiscordClient; try { DiscordActivity dank = null; var rng = rand.Next(3); switch (rng) { case 0: dank = new DiscordActivity(games[rand.Next(games.Length)], ActivityType.ListeningTo); break; case 1: dank = new DiscordActivity(games[rand.Next(games.Length)], ActivityType.Playing); break; case 2: dank = new DiscordActivity(games[rand.Next(games.Length)], ActivityType.Watching); break; } await client.UpdateStatusAsync(dank, UserStatus.Online); Console.WriteLine($"Presense updated to {dank.ActivityType.ToString()} - {dank.Name.ToString()} at {DateTime.Now.ToString()}"); GC.Collect(); } catch (Exception e) { Console.WriteLine("ERROR UPDATING STATUS!!!!!"); } }
public Task SetActivityAsync(Action <DiscordActivity> activity) { var model = new DiscordActivity(); activity(model); return(this.SetActivityAsync(model, null)); }
public async Task setGame() { await Task.CompletedTask; while (true) { DiscordActivity test = new DiscordActivity { Name = "m%help for commands!", ActivityType = ActivityType.Playing }; await bot.UpdateStatusAsync(activity : test, userStatus : UserStatus.Online); await Task.Delay(TimeSpan.FromMinutes(5)); DiscordActivity test2 = new DiscordActivity { Name = "Check the new playlist commands!", ActivityType = ActivityType.Playing }; await bot.UpdateStatusAsync(activity : test2, userStatus : UserStatus.Online); await Task.Delay(TimeSpan.FromMinutes(5)); DiscordActivity test3 = new DiscordActivity { Name = "Full NND support!", ActivityType = ActivityType.Playing }; await bot.UpdateStatusAsync(activity : test3, userStatus : UserStatus.Online); await Task.Delay(TimeSpan.FromMinutes(5)); } }
private Task OnClientReady(DiscordClient sender, ReadyEventArgs e) { var activity = new DiscordActivity("ds help", ActivityType.Playing); Client.UpdateStatusAsync(activity); return(Task.CompletedTask); }
public async Task StatusLookingAt(CommandContext ctx) { var activity = new DiscordActivity(" на " + ctx.Member.DisplayName, ActivityType.Watching); // При шардировании надо будет изменить эмодзю await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(Connections.Connections.Discord, ":angry_eyes:")); await Connections.Connections.Discord.UpdateStatusAsync(activity); }
public async Task SetGame(CommandContext ctx, [RemainingText] string game) { DiscordActivity activity = new DiscordActivity(game); await ctx.Client.UpdateStatusAsync(activity).ConfigureAwait(false); await ctx.Channel.SendMessageAsync(embed : Vembed("Successfully changed game to " + game + ".")).ConfigureAwait(false); }
internal DiscordActivity(DiscordActivity other) { this.Name = other.Name; this.ActivityType = other.ActivityType; this.StreamUrl = other.StreamUrl; this.RichPresence = new DiscordRichPresence(other.RichPresence); this.CustomStatus = new DiscordCustomStatus(other.CustomStatus); }
private async Task Cliente_Ready(DiscordClient cliente, ReadyEventArgs e) { var atividade = new DiscordActivity("Bot do MetaGames", ActivityType.Streaming) { StreamUrl = "https://www.twitch.tv/avj255" }; await Cliente.UpdateStatusAsync(activity : atividade, userStatus : UserStatus.Online); }
private async Task Cliente_ClientErrored(DiscordClient client, ClientErrorEventArgs e) { var atividade = new DiscordActivity("Vish Pifei", ActivityType.Streaming) { StreamUrl = "https://www.twitch.tv/avj255" }; await Cliente.UpdateStatusAsync(activity : atividade, userStatus : UserStatus.Idle); }
public static Splash GetFromDiscordActivity(DiscordActivity discordActivity) { return(new() { Name = discordActivity.Name, Type = discordActivity.ActivityType, StreamUrl = discordActivity.StreamUrl }); }
public async Task SetMsg(CommandContext ctx, int type, [RemainingText] string text) { var Activity = new DiscordActivity(text, (ActivityType)type); await ctx.Client.UpdateStatusAsync(Activity); discordUrie.Config.StartupActivity = Activity; await discordUrie.Config.SaveSettings(discordUrie.SQLConn); await ctx.Message.DeleteAsync(); }
private Task OnClientReady(DiscordClient _discord, ReadyEventArgs e) { DiscordActivity status = new DiscordActivity("you fail exams :')", ActivityType.Watching); _discord.UpdateStatusAsync(status); Console.WriteLine($"[Jack] Updated status to \"{status.Name}\"!"); StartReminders(); Console.WriteLine($"[Jack] Personal reminders are up!"); return(Task.CompletedTask); }
public async Task RunAsync() { var activity = new DiscordActivity("with startup code.", ActivityType.Playing); await Client.ConnectAsync(activity); var channel = await Client.GetChannelAsync(LogChannel); BaseEventHandler.SetUpEvents(Client, channel); await Task.Delay(-1); }
public static Task RegisterDiscord() { if (!Ready) { try { // Windows Vista - 8.1 if (Environment.OSVersion.Platform.Equals(PlatformID.Win32NT) && Environment.OSVersion.Version.Major == 6) { Discord = new DiscordClient(new DiscordConfiguration { Token = AlliancePlugin.config.DiscordBotToken, TokenType = TokenType.Bot, WebSocketClientFactory = WebSocket4NetClient.CreateNew, AutoReconnect = true }); } else { Discord = new DiscordClient(new DiscordConfiguration { Token = AlliancePlugin.config.DiscordBotToken, TokenType = TokenType.Bot, AutoReconnect = true }); } } catch (Exception ex) { AlliancePlugin.Log.Error(ex); Ready = false; return(Task.CompletedTask); } try { Discord.ConnectAsync(); } catch (Exception) { return(Task.CompletedTask); } Discord.MessageCreated += Discord_MessageCreated; game = new DiscordActivity(); Discord.Ready += async e => { Ready = true; await Task.CompletedTask; }; } return(Task.CompletedTask); }
/// <summary> /// Updates playing statuses on all shards. /// </summary> /// <param name="activity">Activity to set.</param> /// <param name="userStatus">Status of the user.</param> /// <param name="idleSince">Since when is the client performing the specified activity.</param> /// <returns>Asynchronous operation.</returns> public async Task UpdateStatusAsync(DiscordActivity activity = null, UserStatus?userStatus = null, DateTimeOffset?idleSince = null) { var tasks = new List <Task>(); foreach (var client in this._shards.Values) { tasks.Add(client.UpdateStatusAsync(activity, userStatus, idleSince)); } await Task.WhenAll(tasks).ConfigureAwait(false); }
internal TransportActivity(DiscordActivity game) { if (game == null) { return; } this.Name = game.Name; this.ActivityType = game.ActivityType; this.StreamUrl = game.StreamUrl; }
private Task OnClientReady(ReadyEventArgs e) { //Status machen string[] status = { "I Serve Fooi. I am a Slave of the Micha!" }; var x = new DiscordActivity(name: status[0], type: ActivityType.Playing); Client.UpdateStatusAsync(x); Console.WriteLine("Online Bitch"); return(Task.CompletedTask); }
internal static Task OnClientReady(DiscordClient sender, ReadyEventArgs _) { //DiscordActivity activity = new DiscordActivity("a Turtle.", ActivityType.Streaming) //{ // StreamUrl = "https://www.twitch.tv/lathland" //}; DiscordActivity activity = new DiscordActivity("flamethrower music.", ActivityType.ListeningTo); sender.UpdateStatusAsync(activity); return(Task.CompletedTask); }
public static Task RotateActivity(Clan clan) { var activity = new DiscordActivity() { Name = string.Format("over {0}...", clan.details.Name), ActivityType = ActivityType.Watching, }; Log.Information("Rotating status to " + clan.details.Name); Core.Discord.discord.UpdateStatusAsync(activity); return(Task.CompletedTask); }
public async Task StartAsync() { // prepare activity var activity = new DiscordActivity(); activity.ActivityType = Config.Activity.Type; activity.Name = Config.Activity.Text; // start connection await _client.ConnectAsync(activity, Config.Activity.Status); await Task.Delay(-1); }
public async Task botStatusAsync(ReadyEventArgs e) { string[] statusArray = { "test", "test2", "test3" }; Random rand = new Random(); DiscordActivity active = new DiscordActivity(); active.ActivityType = ActivityType.Streaming; active.Name = statusArray[rand.Next(0, 2)]; active.StreamUrl = "https://twitch.tv/ceariusx"; await this.bot.UpdateStatusAsync(active); }
public async Task SetStatus(CommandContext ctx, string type = "Watching", [RemainingText] string status = "over the seven Seas") { if (ctx.Member.PermissionsIn(ctx.Channel).HasPermission(Permissions.ManageChannels)) { //Define ActivityType var activityType = type.Equals("Watching") ? ActivityType.Watching : type.Equals("Competing") ? ActivityType.Competing : type.Equals("ListeningTo") ? ActivityType.ListeningTo : type.Equals("Streaming") ? ActivityType.Streaming : ActivityType.Playing; var activity = new DiscordActivity($"{status}", activityType); await ctx.Client.UpdateStatusAsync(activity, UserStatus.Online); } }
private async Task OnHeartbeat(HeartbeatEventArgs e) { //calculate time left till new mission var timeLeft = TimeSpan.FromMinutes(60 - DateTime.Now.Minute); //get all the other data in here boys var serverCount = Bot.Client.Guilds.Count; var memberCount = Bot.Client.Guilds.Sum(x => x.Value.MemberCount); var activity = new DiscordActivity($"⚔ {Math.Floor(timeLeft.TotalMinutes)} minutes until next event. [{serverCount} servers with {memberCount} members]", ActivityType.Streaming); await Bot.Client.UpdateStatusAsync(activity, UserStatus.Online); }
private Task Discord_Ready(DiscordClient client, ReadyEventArgs e) { client.Logger.LogInformation($"Client v{Version} {RuntimeInfo} ready."); var game = new DiscordActivity { ActivityType = ActivityType.Playing, Name = $"v{Version} {RuntimeInfo} on {HostOsInfo}" }; _discord.UpdateStatusAsync(game, UserStatus.Online); return(Task.CompletedTask); }
public async Task RunAsync() { var activity = new DiscordActivity { Name = NexusConfiguration.PlayingStatus, ActivityType = NexusConfiguration.PlayingType }; await Client.ConnectAsync(activity); NexusInformation.PluginRepository = new PluginRepository(); await Task.Delay(0); }