public async Task UnlinkServices(CommandContext ctx) { var msg = await ctx.RespondAsync(embed : EmbedTemplates.CreateInfoEmbed("Unlink Services", "Unlinking all services. Please wait...")); DiscordService.ResetAllServices(ctx); await msg.ModifyAsync( embed : new Optional <DiscordEmbed>( EmbedTemplates.CreateSuccessEmbed(description: "Unlinked all services."))); }
void OnGameStart() { Ui.CloseWindow(); var state = skirmishMode ? DiscordState.PlayingSkirmish : DiscordState.PlayingMultiplayer; DiscordService.UpdateStatus(state); onStart(); }
public Worker(ILogger <Worker> logger, IConfiguration configuration, ILogger <Bot> botLogger, DiscordService discordService) { Logger = logger; Configuration = configuration; DiscordService = discordService; Instance = this; bot = new Bot(configuration, botLogger, discordService); }
public ApiSandboxController(SuperChatService superChatService, DiscordService discordService, ApplicationDbContext applicationDbContext, SiteContext siteContext, CoreService coreService, IconCheckService iconCheckService, StaticSettings staticSettings) { SuperChatService = superChatService; DiscordService = discordService; DbContext = applicationDbContext; SiteContext = siteContext; CoreService = coreService; IconCheckService = iconCheckService; StaticSettings = staticSettings; }
/// <summary> /// Synchronizes the channels in the <paramref name="context"/> with the /// channels from the <paramref name="discordService"/> /// </summary> /// <param name="context">The database context</param> /// <param name="discordService">The discord service</param> public static void SyncChannels( DatabaseContext context , DiscordService discordService) { IEnumerable <SocketTextChannel> textChannels = discordService.GetTextChannels(); EnableChannels(context, textChannels); DisableDroppedChannels(context, textChannels); }
public GuildWelcomeMessageService(IOptions <AppSettings> options, DiscordService discord, DiscordErrorReporter errorReporter) { _settings = options.Value; _discord = discord; _errorReporter = errorReporter; _discord.JoinedGuild += HandleJoinedGuild; }
/// <summary> /// Lists trackers for the guild in which the command was sent in /// </summary> /// <param name="message">The request message</param> /// <param name="discordService">The discord service</param> /// <param name="context">The database context</param> private static async Task ListTrackersAsync( SocketMessage message , DiscordService discordService , DatabaseContext context ) { Channel?channel = context.GetChannel(message.Channel.Id); if (channel == null) { return; } IEnumerable <Tracker> trackers = context.GetActiveTrackers(channel.Guild); if (!trackers.Any()) { await discordService .ReplyAsync(message, "No active trackers found!") .ConfigureAwait(false); return; } int gameAbbreviationLength = Math .Max(trackers .OrderByDescending(t => t.Game.Abbreviation.Length) .Select(t => t.Game) .First() .Abbreviation.Length + 2 , "Abbreviation".Length + 2); int gameNameLength = trackers .OrderByDescending(t => t.Game.Name.Length) .Select(t => t.Game) .First() .Name .Length + 2; string reply = "```\r\n"; reply += "Abbreviation".PadRight(gameAbbreviationLength); reply += "Game".PadRight(gameNameLength); reply += "Channel\r\n"; foreach (Tracker tracker in trackers) { string entry = $"{tracker.Game.Abbreviation.PadRight(gameAbbreviationLength)}{tracker.Game.Name.PadRight(gameNameLength)}#{tracker.Channel.DisplayName}"; reply += $"{entry}\r\n"; } reply += "```"; await discordService.ReplyAsync(message, reply).ConfigureAwait(false); }
/// <summary> /// Initializes the discord service /// </summary> private static void InitDiscordService() { _discordService = new DiscordService(); _discordService.OnDisconnected += OnDiscordDisconnected; _discordService.OnReady += OnDiscordReady; _discordService.OnChannelCreated += OnDiscordChannelCreated; _discordService.OnChannelDestroyed += OnDiscordChannelDeleted; _discordService.OnGuildJoined += OnDiscordGuildJoined; _discordService.OnGuildLeft += OnDiscordGuildLeft; _discordService.OnCommandReceived += OnDiscordCommandReceived; }
void OnGameStart() { Ui.CloseWindow(); var state = skirmishMode ? DiscordState.PlayingSkirmish : DiscordState.PlayingMultiplayer; var details = map.Title + " - " + orderManager.LobbyInfo.GlobalSettings.ServerName; DiscordService.UpdateStatus(state, details); onStart(); }
void WatchReplay() { if (selectedReplay != null && ReplayUtils.PromptConfirmReplayCompatibility(selectedReplay)) { cancelLoadingReplays = true; DiscordService.UpdateStatus(DiscordState.WatchingReplay); Game.JoinReplay(selectedReplay.FilePath); } }
public ScheduledExecutionHostedService(IServiceProvider services, // IOptions<AppSettings> options, DiscordService discordService, ILogger <ScheduledExecutionHostedService <T> > logger ) { Services = services; DiscordService = discordService; Logger = logger; // AppSettings = options.Value; }
public async Task InviteTests_ValidateDiscorcdInviteExpired_ReturnsFalse() { //Arrange DiscordService _workspaceService = new DiscordService(); string inviteLink = "https://discordapp.com/invite/BFydMyn"; //Act var result = await _workspaceService.GetInviteStatus(inviteLink); //Assert Assert.False(result.Valid); }
/// <summary> /// Initializes a new instance of the <see cref="SetCommands"/> class. /// </summary> /// <param name="discordService">The Discord integration service.</param> /// <param name="characterService">The character service.</param> /// <param name="characterRoles">The character role service.</param> public SetCommands ( DiscordService discordService, CharacterDiscordService characterService, CharacterRoleService characterRoles ) { _discord = discordService; _characters = characterService; _characterRoles = characterRoles; }
public async Task InviteTests_ValidateDiscorcdInviteNotExpired_ReturnsTrue() { //Arrange DiscordService _workspaceService = new DiscordService(); string inviteLink = "https://discord.gg/GmurfHD"; //Act var result = await _workspaceService.GetInviteStatus(inviteLink); //Assert Assert.True(result.Valid); }
public BaseCommands(IStatisticsManager statisticsManager, IYouTubeManager youtubeManager, IApiAiManager apiAiManager, DiscordService discordService, DiscordShardedClient discord, IOptions <BotSettings> botSettings, FileService fileService) : base(botSettings) { _statisticsManager = statisticsManager; _youtubeManager = youtubeManager; _apiAiManager = apiAiManager; _discordService = discordService; _discord = discord; _botSettings = botSettings.Value; _fileService = fileService; }
public View(DiscordService discord, MessageHandlerService messageHandler, ReactionHandlerService reactionHandler, InteractiveManager interactive, FeedChannelUpdateService feedChannelUpdater) { _discord = discord; _messageHandler = messageHandler; _reactionHandler = reactionHandler; _interactive = interactive; _feedChannelUpdater = feedChannelUpdater; }
public DiscordErrorReporter(IOptions <AppSettings> options, IHostingEnvironment environment, DiscordService discord, InteractiveManager interactiveManager, ILogger <DiscordErrorReporter> logger) { _settings = options.Value; _environment = environment; _discord = discord; _interactiveManager = interactiveManager; _logger = logger; }
/// <summary> /// Triggers every time a game is won. /// </summary> /// <param name="winner"></param> /// <param name="gameID"></param> public void ProcessWinner(string winner, int gameID) { // Wait until someone has won two games, then report the results to Discord. match.Winners.GetRecordData(out var first, out var record); if (first.Wins == 2) { var loser = match.Players.FirstOrDefault(d => d != winner); #pragma warning disable CS4014 // We don't actually want to block on the message. DiscordService.SendToArbiraryChannelAsync($":trophy: {winner} {record} {loser}", 291179039291473920); #pragma warning restore CS4014 } }
public ScheduledExecutionService( DiscordService discordService, CoreService coreService, IconCheckService iconCheckService, StaticSettings staticSettings ) { DiscordService = discordService; CoreService = coreService; IconCheckService = iconCheckService; StaticSettings = staticSettings; }
/// <summary> /// Initializes a new instance of the <see cref="SetCommands"/> class. /// </summary> /// <param name="discordService">The Discord integration service.</param> /// <param name="feedbackService">The feedback service.</param> /// <param name="characterService">The character service.</param> /// <param name="characterRoles">The character role service.</param> public SetCommands ( DiscordService discordService, UserFeedbackService feedbackService, CharacterDiscordService characterService, CharacterRoleService characterRoles ) { _discord = discordService; _feedback = feedbackService; _characters = characterService; _characterRoles = characterRoles; }
void mss_SampleRequested(MediaStreamSource sender, MediaStreamSourceSampleRequestedEventArgs args) { DiscordService discordService = (DiscordService)App.Current.Services.GetRequiredService <IDiscordService>(); foreach ((string key, WebrtcManager manager) in discordService.Streams) { if (key.EndsWith(UserId.ToString())) { manager.GenerateSample(args.Request); return; } } }
public async Task ForceLinkService(CommandContext ctx, int serviceId) { await ctx.Message.DeleteAsync(); if (DiscordService.LinkService(ctx.Guild.Id, serviceId)) { await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed(description: "**Linked Service**")); } else { await ctx.RespondAsync( embed : EmbedTemplates.CreateErrorEmbed(description: "**Failed to link service**")); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { var discordService = new DiscordService("NzI5MjU5NzU1ODYzODAxOTQ2.XwGcnQ.6goBosxHNX7o02qThz-AcJPX32g"); await discordService.Start(); while (!stoppingToken.IsCancellationRequested) { _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); await Task.Delay(1000, stoppingToken); } await discordService.Stop(); }
void UpdateDiscordStatus() { var mapTitle = map.Title; var numberOfPlayers = 0; var slots = 0; if (!skirmishMode) { foreach (var kv in orderManager.LobbyInfo.Slots) { if (kv.Value.Closed) { continue; } slots++; var client = orderManager.LobbyInfo.ClientInSlot(kv.Key); if (client != null) { numberOfPlayers++; } } } if (updateDiscordStatus) { string secret = null; if (orderManager.LobbyInfo.GlobalSettings.Dedicated) { var endpoint = orderManager.Endpoint.GetConnectEndPoints().First(); secret = string.Concat(endpoint.Address, "|", endpoint.Port); } var state = skirmishMode ? DiscordState.InSkirmishLobby : DiscordState.InMultiplayerLobby; DiscordService.UpdateStatus(state, mapTitle, secret, numberOfPlayers, slots); updateDiscordStatus = false; } else { if (!skirmishMode) { DiscordService.UpdatePlayers(numberOfPlayers, slots); } DiscordService.UpdateDetails(mapTitle); } }
public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText) { Settings = new PluginSettings(this); DiscordService = new DiscordService(); ACTTabControl = new ACTTabControl(this); pluginScreenSpace.Text = "Kikisen Talk"; pluginScreenSpace.Controls.Add(ACTTabControl); Settings.Load(); ClearParamMessages(); ClearBatchMessage(); ActGlobals.oFormActMain.OnLogLineRead += OnLogLineRead; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterCommands"/> class. /// </summary> /// <param name="database">A database context from the context pool.</param> /// <param name="contentService">The content service.</param> /// <param name="discordService">The Discord integration service.</param> /// <param name="feedbackService">The feedback service.</param> /// <param name="characterService">The character service.</param> public CharacterCommands ( GlobalInfoContext database, ContentService contentService, DiscordService discordService, UserFeedbackService feedbackService, CharacterService characterService ) { this.Database = database; this.Content = contentService; this.Discord = discordService; this.Feedback = feedbackService; this.Characters = characterService; }
public async Task PlayersTask(CommandContext ctx) { var settings = new NexusModuleConfiguration <PlayersMenuSettings>("PlayerMenuSettings", "./Config/TCAdminModule/") .GetConfiguration(); await ctx.TriggerTypingAsync(); var service = await DiscordService.GetService(ctx); var server = new Server(service.ServerId); var query = ServerQuery.GetQueryResults(server, new TCAdmin.GameHosting.SDK.Objects.Game(service.GameId), service); if (query.NumPlayers == 0) { await ctx.RespondAsync( embed : EmbedTemplates.CreateErrorEmbed(service.NameNoHtml, "**No players online**")); return; } if (query.NumPlayers != query.Players.Count) { await ctx.RespondAsync(embed : EmbedTemplates.CreateInfoEmbed(service.NameNoHtml, $"There are **{query.NumPlayers}/{query.MaxPlayers}** online!")); return; } var embed = new DiscordEmbedBuilder { Title = $"{service.Name} | Players: {query.NumPlayers}/{query.MaxPlayers}", Color = new Optional <DiscordColor>(new DiscordColor(settings.HexColor)), Timestamp = DateTime.Now, Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = settings.ThumbnailUrl } }; foreach (var player in query.Players.OrderBy(x => x.Name)) { embed.Description += $":bust_in_silhouette: {player.Name}\n"; } await ctx.RespondAsync(embed : embed); }
public ReactionHandlerService(DiscordService discord, GuildSettingsCache guildSettingsCache, DiscordErrorReporter errorReporter, ILogger <ReactionHandlerService> logger, InteractiveManager interactiveManager) { _discord = discord; _guildSettingsCache = guildSettingsCache; _errorReporter = errorReporter; _logger = logger; _reactionHandlers = new IReactionHandler[] { interactiveManager }; }
public GuildSettingsSyncService(IServiceProvider services, GuildSettingsCache cache, DiscordService discord) { _services = services; _cache = cache; _discord = discord; _discord.GuildAvailable += RefreshGuildAsync; _discord.JoinedGuild += RefreshGuildAsync; foreach (var guild in discord.Guilds) { cache.RefreshQueue.Enqueue(guild.Id); } }
private async Task Notification(UserContext userContext, Donation donation, Doner doner) { var fields = new List <DiscordService.DiscordEmbed.Field>(); fields.Add(new DiscordService.DiscordEmbed.Field { name = "金額", value = $"{doner.Amount}{StaticSettings.CurrenryUnit}", inline = false }); if (!string.IsNullOrWhiteSpace(doner.Comment)) { fields.Add(new DiscordService.DiscordEmbed.Field { name = "メッセージ", value = doner.Comment, inline = false }); } var total = DbContext.Doners.AsQueryable().Where(c => c.DonationId == donation.Id) .Where(c => c.DonerState != DonerState.Cancel) .Where(c => c.VetMemberId != donation.VetMemberId) .Sum(c => c.Amount); fields.Add(new DiscordService.DiscordEmbed.Field { name = "支援総額", value = $"{total}{StaticSettings.CurrenryUnit}", inline = false }); await DiscordService.SendMessage(DiscordService.Channel.CrowdFundingNotification, string.Empty, new DiscordService.DiscordEmbed { title = donation.Title, url = $"{StaticSettings.SiteBaseUrl}Donations/Details?id={donation.Id}", author = new DiscordService.DiscordEmbed.Author { url = userContext.CurrentUser.GetMemberPageUrl(StaticSettings.SiteBaseUrl), icon_url = userContext.CurrentUser.GetAvaterIconUrl(), name = userContext.CurrentUser.Name }, fields = fields.ToArray() }); }