#Having issues with UserJoined
1 messages · Page 1 of 1 (latest)
Enable the GuildMembers intent in your DiscordSocketConfig and dev portal
For some reason it still does not trigger. This is my Startup.cs ``` public interface IStartup
{
Task Init();
}
public class Startup : IStartup
{
private readonly DiscordSocketClient _client;
private readonly IEventHandler _eventHandler;
public Startup(DiscordSocketClient client, IEventHandler eventHandler)
{
_client = client;
_eventHandler = eventHandler;
}
public async Task Init()
{
try
{
await _client.LoginAsync(TokenType.Bot, "my token");
await _client.StartAsync();
_client.Ready += _eventHandler.ReadyEvent;
_client.UserJoined += (SocketGuildUser user) =>
{
Console.WriteLine($"{user.Id} has joined");
return Task.CompletedTask;
};
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
} ``` This is my main file ``` var config = new DiscordSocketConfig()
{
GatewayIntents = GatewayIntents.GuildMembers | GatewayIntents.Guilds | GatewayIntents.GuildMessages
};
var serviceProvider = new ServiceCollection()
.AddSingleton<DiscordSocketClient>()
.AddSingleton<IStartup, Startup>()
.AddSingleton<INetworkInfo, NetworkInfo>()
.AddSingleton<IEventHandler, EventHandler>()
.AddSingleton<IMembers, Members>()
.BuildServiceProvider();
var startup = serviceProvider.GetRequiredService<IStartup>();
await startup.Init();
Console.ReadLine();
I passed the config before but i deleted it i think hopefully it works now 😂