#Commands not registering inside discord

1 messages · Page 1 of 1 (latest)

viral saffron
#

I am using this code and am not able to register commands for a new bot or update commands for an existing bot, any ideas? I just recently switched to using modules

public async Task StartAsync(CancellationToken cancellationToken)
        {
            var token = _secrets.Secrets.DiscordBotToken;

            _client = new DiscordSocketClient();

            await _client.LoginAsync(TokenType.Bot, token);
            await _client.StartAsync();

            _client.Ready += async () =>
            {
                Console.WriteLine("Discord Bot Ready");

                _interactions = new InteractionService(_client);
                await _interactions.AddModulesAsync(Assembly.GetEntryAssembly(), _services);

                foreach (var guildId in _client.Guilds.Select(x=>x.Id))
                {
                    await _interactions.RegisterCommandsToGuildAsync(guildId);
                }

                _client.InteractionCreated += async interaction =>
                {
                    var scope = _services.CreateScope();
                    var ctx = new SocketInteractionContext(_client, interaction);
                    await _interactions.ExecuteCommandAsync(ctx, scope.ServiceProvider);
                };
            };
        }
viral saffron
#

Any idea?