如何使用C#在Discord中创建用户欢迎消息

时间:2018-05-25 20:24:11

标签: c# discord

这是我的代码,但它不起作用:用户加入时没有消息。我该如何解决这个问题?

public async Task Client_Userjoined()  
 {
     var name = Context.Message.Author.Id;
     ulong id = 447147292617736203;  
     var chnl = Client.GetChannel(id) as IMessageChannel;  
     await chnl.SendMessageAsync($"Welcome!<@n{name}> ");

 }

1 个答案:

答案 0 :(得分:0)

以下是[1.0]

中的操作方法

这是在依赖关系图中但在“handlecommand”

之下
client.UserJoined += AnnounceJoinedUser; //Check if userjoined

这是在依赖关系图

    public async Task AnnounceJoinedUser(SocketGuildUser user) //welcomes New Players
{
    var channel = client.GetChannel(%TextChannelID%) as SocketTextChannel; //gets channel to send message in
    await channel.SendMessageAsync("Welcome " + user.Mention + " to the server!"); //Welcomes the new user
}