Reputation: 3
I see everyone is using anything that is called "Context" and 90% define this with Discord.Commands.SocketCommandContext
, now I want to create an bot which is able to read all users in a channel, without the use of commands, just when bot is connected it should bring an list with all users of the defined channel.
Everything I do doesn't works, it always just prints the name of the bot with the "#".
source part:
var guild = _client.GetGuild(1234);
var channel = guild.GetChannel(1234);
var users = guild.Users;
while (true)
{
await Task.Delay(5000);
foreach (IGuildUser guser in users)
{
Console.WriteLine(guser);
}
}
Upvotes: 0
Views: 968
Reputation:
This is for a Text Channel
var guild = this.client.GetGuild(123);
var channel = guild.GetTextChannel(123);
foreach (var user in channel.Users)
{
Console.WriteLine(user);
}
This is for a Voice Channel
var guild = this.client.GetGuild(123);
var channel = guild.GetChannel(123);
foreach (var user in channel.Users)
{
Console.WriteLine(user);
}
This is for a Guild
var guild = this.client.GetGuild(123);
foreach (var user in guild.Users)
{
Console.WriteLine(user);
}
Upvotes: 1