问题描述
npm i moment
我想要做的是当用户没有提供参数时,我想通知他这个命令需要一个参数。我怎样才能做到这一点?
解决方法
类似于小 ReplyAsync()
的东西应该可以解决问题。
例如,使用您的代码:
[Command("userstatus"),Summary("Provides you the info of the given user status")]
public async Task UserStatus([Remainder] SocketUser user)
{
if (user is null)
{
await ReplyAsync($"{Context.User.Mention} Please @mention another user to use this command.");
}
else
{
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.AddField("User Status",CommandHandler._discord.GetUser(user.Username,user.Discriminator).Status);
embedBuilder.AddField("Current Activity",user.Activity);
await Context.Channel.SendMessageAsync(null,false,embedBuilder.Build());
}
}
话虽如此,确实存在其他“更复杂”的方法,但我的建议是保持简单;)