我想使用c#通过ID对用户进行DM,以下是我尝试过的
var u = "user-id";
string msg = "your message";
await UserExtensions.SendMessageAsync(u, msg);
返回:
cannot convert from 'string' to 'Discord.IUser'
我已经搜索过了,但我找不到将字符串转到Discord.IUser.
您需要将用户作为IUser获取,要将用户作为IUser,您可以使用_client.GetUserAsync('UserID'(:
ulong u = 0; // Insert the user ID here
string msg = "your message";
// Get the user with the ID from your DiscordSocketClient
var user = _client.GetUserAsync(u).Result;
await UserExtensions.SendMessageAsync(user, msg);
var user = Context.Guild.GetUser(Context.Message.Author.Id);
await user.SendMessageAsync("This is my message!");