【发布时间】:2017-12-24 03:20:26
【问题描述】:
我只需要一行代码,每五秒钟发送一次垃圾邮件,然后在输入另一个命令后停止。例如,如果用户输入“~raid”,则机器人将每五秒发送一次“RAID RAID”垃圾邮件,并在用户输入“~stop”时停止。如果有人可以提供帮助,那就太好了。
这是我目前得到的: MyBot 类 { DiscordClient 不和谐; CommandService 命令;
public MyBot()
{
discord = new DiscordClient(x =>
{
x.LogLevel = LogSeverity.Info;
x.LogHandler = Log;
});
discord.UsingCommands(x =>
{
x.PrefixChar = '~';
x.AllowMentionPrefix = true;
});
commands = discord.GetService<CommandService>();
commands.CreateCommand("checked")
.Do(async (e) =>
{
commands.CreateCommand("weewoo")
.Do(async (e) =>
{
await e.Channel.SendMessage("**WEE WOO**");
});
discord.ExecuteAndWait(async () =>
{
await discord.Connect("discordkeyhere", TokenType.Bot);
});
}
public void Log(object sender, LogMessageEventArgs e)
{
Console.WriteLine(e.Message);
}
}
}
【问题讨论】:
-
问题是执行停止命令?
-
是的,以及如何使消息每 5 秒重复一次