I am creating a Discord bot that should send messages to hundreds of servers in parallel.
What should I use for this?
Now I tried doing it with C# and Discord.Net. And I can send messages like this
var client = new DiscordSocketClient();
Login(_client, BotToken).GetAwaiter().GetResult();
var Current_guild = guilds.FirstOrDefault(u =>u.Id == server_id);
var channel = Current_guild.Channels.FirstOrDefault(u =>u.Name.Equals(channel_name, StringComparison.InvariantCultureIgnoreCase))
channel.SendMessageAsync(message).GetAwaiter().GetResult();
private async Task < bool > Login(DiscordSocketClient client, string bot_token) {
var result = false;
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
try {
await client.LoginAsync(TokenType.Bot, bot_token);
await client.StartAsync();
result = await WaitForConnected(client, cts.Token);
}
catch(Exception ex) {
Console.ForegroundColor = ConsoleColor.Red;
Logger.Log($ "Exception {ex.Message}");
Console.ResetColor();
}
return result;
}
But errors appear with connecting to the server when sending in parallel to more than 2 servers
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…