public async Task SetGame([Summary("The game for the bot to play")][Remainder] string game)
        {
            await Context.Channel.TriggerTypingAsync();

            _logger.LogInformation("{username}#{discriminator} invoked game ({game}) on {server}/{channel}",
                                   Context.User.Username, Context.User.Discriminator, game, Context.Guild?.Name ?? "DM", Context.Channel.Name);

            if (Context.User.Username != _settings.OwnerName || Context.User.Discriminator != _settings.OwnerDiscriminator)
            {
                await ReplyAsync("Sorry, only the bot's owner can set the game!");
            }
            else
            {
                var settings = await _discordBotSettingsRepository.Get();

                await _client.SetGameAsync(game);

                settings.Game = game;
                await _discordBotSettingsRepository.EditAsync(settings);

                await ReplyAsync("Game changed!");

                await _servers.SendLogsAsync(Context.Guild, "Game Updated", $"{Context.User.Mention} has changed the game to {game}.");
            }
        }
Exemple #2
0
        private async Task OnReady()
        {
            _logger.LogInformation("Connected as {username}#{discriminator}", _client.CurrentUser.Username, _client.CurrentUser.Discriminator);

            if (_settings.EnableLavaLink && !_lavaNode.IsConnected)
            {
                _logger.LogDebug("Connecting to Lavalink");
                await _lavaNode.ConnectAsync();
            }

            var settings = await _discordBotSettingsRepository.Get();

            await _client.SetGameAsync(settings.Game);

            Console.WriteLine("SocketClient is ready");
            Console.WriteLine($"Connected as {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator}");

            if (ShowJoinAndPartMessages)
            {
                foreach (var guild in _client.Guilds)
                {
                    foreach (var channel in guild.Channels)
                    {
                        if (channel.Name.ToLowerInvariant() == "bot" || channel.Name.ToLowerInvariant().Contains("bot-spam"))
                        {
                            if (channel != null && channel is SocketTextChannel textChannel)
                            {
                                var builder = new EmbedBuilder()
                                              .WithThumbnailUrl(_client.CurrentUser.GetAvatarUrl() ?? _client.CurrentUser.GetDefaultAvatarUrl())
                                              .WithDescription($"{_settings.BotName} Starting\nMIT License Copyright(c) 2021 JoyfulReaper\n{_settings.BotWebsite}")
                                              .WithColor(await _servers.GetEmbedColor(guild.Id))
                                              .WithCurrentTimestamp();

                                var embed = builder.Build();
                                await textChannel.SendMessageAsync(null, false, embed);
                            }
                        }
                    }
                }
            }
        }