discord.net

The role is not issued when clicking on the reaction

≡放荡痞女 提交于 2021-01-01 20:37:46
问题 My exception says that user = null but I don't understand why? UserId is passed in the debugger private async Task ReactionAdd(Cacheable<IUserMessage, ulong> cache, ISocketMessageChannel socketMessageChannel, SocketReaction reaction) { if (reaction.MessageId == 771361839917170748) { var emote = Emote.Parse("<:NepSmug:740928682310500412>").ToString(); if (reaction.Emote.ToString() == emote) { var sockettextChannel = socketMessageChannel as SocketTextChannel; ulong roleid = 741342300499738715;

The role is not issued when clicking on the reaction

眉间皱痕 提交于 2021-01-01 20:37:40
问题 My exception says that user = null but I don't understand why? UserId is passed in the debugger private async Task ReactionAdd(Cacheable<IUserMessage, ulong> cache, ISocketMessageChannel socketMessageChannel, SocketReaction reaction) { if (reaction.MessageId == 771361839917170748) { var emote = Emote.Parse("<:NepSmug:740928682310500412>").ToString(); if (reaction.Emote.ToString() == emote) { var sockettextChannel = socketMessageChannel as SocketTextChannel; ulong roleid = 741342300499738715;

Discord.NET assigning roles

时光怂恿深爱的人放手 提交于 2020-12-15 07:13:20
问题 I am trying to get my discord bot to assign a role to a user when they input the command '!stream' I am very new to programming in c# and discord.net especially. Right now I have the code that should be assigning the role inside of a message received method. This probably isn't the best way to do it but I'm not super sure a better way right now. Anyways, here is the code: IGuildUser user = (IGuildUser)arg.Author; IRole role = ((IGuildChannel)arg.Channel).Guild.GetRole(theRoleID); if (arg

Send a Discord Embed via Webhook C#

时间秒杀一切 提交于 2020-07-22 08:07:41
问题 I have this code that I want to send to a discord webhook via an embedded message: var builder = new EmbedBuilder(); builder.WithTitle("Ice Wizard Stats"); builder.AddField("Hit Speed", "1.5sec", true); // True for inline builder.WithThumbnailUrl("https://i.ibb.co/rc66Lq8/logonew.png"); builder.WithColor(Color.Red); How am I supposed to send that? 回答1: public class dWebHook: IDisposable { private readonly WebClient dWebClient; private static NameValueCollection discord = new

How do I make a discord bot respond only to people with a certain role? [C#]

和自甴很熟 提交于 2020-06-01 05:08:00
问题 I want to make my discord bot respond exclusively to people with a @Member role, so when a person without that role writes a command (ex. >say Hello), the bot will not respond to it, but when a person with the @Member role writes that, it will. 回答1: Ideally, if this is being used for a command or rather multiple commands, a precondition should be used (example administration commands). This allows you to not have to duplicate the checks within each command. Ah example of such a precondition

How do I make a discord bot respond only to people with a certain role? [C#]

情到浓时终转凉″ 提交于 2020-06-01 05:07:13
问题 I want to make my discord bot respond exclusively to people with a @Member role, so when a person without that role writes a command (ex. >say Hello), the bot will not respond to it, but when a person with the @Member role writes that, it will. 回答1: Ideally, if this is being used for a command or rather multiple commands, a precondition should be used (example administration commands). This allows you to not have to duplicate the checks within each command. Ah example of such a precondition

C# Discord bot get senders avatar

假如想象 提交于 2020-02-06 08:39:01
问题 Hi I was wondering if anyone knew how to make my c# bot get a senders avatar and then have it reply with the users avatar in the message. Here is what I have: [Command("testuser")] public async Task testuser() { EmbedBuilder builder = new EmbedBuilder(); builder.WithTitle("Message response") .WithDescription("Message" + **SENDERS USER AVATAR HERE**); await ReplyAsync("", false, builder.Build()); } I tried using: .withurl() and .withimageurl() combined with Context.User.GetAvatarUrl and

C# Discord bot get senders avatar

蹲街弑〆低调 提交于 2020-02-06 08:38:08
问题 Hi I was wondering if anyone knew how to make my c# bot get a senders avatar and then have it reply with the users avatar in the message. Here is what I have: [Command("testuser")] public async Task testuser() { EmbedBuilder builder = new EmbedBuilder(); builder.WithTitle("Message response") .WithDescription("Message" + **SENDERS USER AVATAR HERE**); await ReplyAsync("", false, builder.Build()); } I tried using: .withurl() and .withimageurl() combined with Context.User.GetAvatarUrl and

Discord.Net - Sending command and then getting response

霸气de小男生 提交于 2020-01-30 12:01:10
问题 I have been struggling to find an answer to this question. I would like to get the response to a command and use that as a parameter - argument. Example: User: /say Bot: What would you like me to say? User: Hello, how is your day going? Bot: Hello, how is your day going? Any help is greatly appreciated! 回答1: You can achieve this with Discord.Addons.Interactive Example code 来源: https://stackoverflow.com/questions/50054535/discord-net-sending-command-and-then-getting-response

How can I have my Discord C# respond to mentions?

梦想的初衷 提交于 2020-01-06 07:26:32
问题 I'm in the middle of developing a C# discord bot and I have been successful with making the bot respond to phrases starting with "c! " and responding with the correct command, however I want the bot to reply with a GIF if the bot is mentioned. If someone could help explain why this does not work and how to fix it that would be nice. This is my code right now: private async Task HandleCommandAsync(SocketMessage arg) { var message = arg as SocketUserMessage; if (message is null || message