Questions tagged [discord.net]

1

votes
1

answer
97

Views

Count Number Of Messages Cleared By Bot

I have made this command for my discord bot that clears a certain number of messages in a channel. It currently does its job and does it well but when it shows the message at the end it shows the number of messages they wanted to clear. But lets say the channel only contains 20 messages but they do...
Atlntic
1

votes
1

answer
1.3k

Views

Getting error “A MessageReceived handler is blocking the gateway task.” In Spambot Discord C#

In this command, I want the user to input an integer, and then the string he/she wants to spam. After it asks for the string, I get an error in the CMD saying 'A MessageReceived handler is blocking the gateway task.' For example the user could say !spamstring 29 then Get on CSGO! The bot will spam...
1

votes
1

answer
851

Views

Discord Bot Event for Members Joining Channel

I want my Discord bot to greet members when they join a channel. I have been unable to find an event that fires when this happens. I have tried myClient.UserJoined += MyMethod; and others but they never get fired as I hope. Here is my main code: public class Program { private DiscordSocketClient _c...
Emery Weist
1

votes
1

answer
44

Views

Discord.net event only calls the first subscriber

I have two methods subscribed to the ReactionAdded event, but when the event triggers, only the first subscriber called and the others are not. Why doesn't it work and how can it be repaired? Code _client.ReactionAdded += HelpPageUpdater.ReactionAdded; _client.ReactionAdded += GameCore.ReactionAdded...
Noel Nemeth
1

votes
1

answer
39

Views

Make command work once and for 1 user only until next bot order is posted

I am currently trying to make so if a new order is posted in the discord channel, the first user to write !accept gets a message thrown back to them in chat, while if people after first guy tries to write !accept will get an error message. How should I do this? AcceptCommand Class: public class Acc...
Jørgen Klaastad
1

votes
2

answer
168

Views

DiscordClient not found and LogMessageEventArgs error

The error messages in the output Upon running the code I get multiple errors about the DiscordClient which could not be found and the LogMessageEventArgs which could not be found. I have checked for an answer but most say to its due to updates, I have the latest update but it is still an error. Coul...
Max Thomas
1

votes
0

answer
64

Views

Discord.net Shards randomly disconnecting

Im randomly getting the error: A MessageReceived handler is blocking the gateway task and when that happens my shard were the error ocurred disconnects without reconnecting. The problem seems to occur with all the commands. But there is only a small change of it actually occurring. Most of the time...
Bram esendam
-2

votes
1

answer
65

Views

Adding to a list returns null

I am working on a system where users can buy items from a shop. Each user is listed in a database, and when they buy that item it should add it to the list ownedItems in the database, however when executing the line of the code to add the item it's returning System.NullReferenceException: Object re...
Tim
1

votes
1

answer
1.5k

Views

How I can parse HTML table content in Discord Chat? Discord.NET C#

Good day, I want to parse the content from a websites table. On the Website there is a Ranking of Top Weekly Exp Players. And with the command ~weekly i want to outpot the best 20 players. For now I have the following Code: commands.CreateCommand('weekly') .Do(async (e) => { WebClient webClient = n...
xKushGene
1

votes
1

answer
1.7k

Views

Discord BOT check for a message containing certain text

I'm trying to make it so it'll send a message if that channel has any message with that users name saying '@BLAH 1/3 Foul Language' that'll check then send a new message saying '@BLAH 2/3 Foul Language' if (warningsChannel.Messages.ToString().Contains(e.User.Mention + ' 1/3 foul language')) { await...
Phil Ramsey
1

votes
1

answer
187

Views

e.After.VoiceChannel.Name Discord.NET - Can't figure out null error

Before you judge me for posting ANOTHER NullReferenceException problem, please read my code. I've been googling NullReferenceException errors for a while now and, it doesn't explain why this specific section gives me an error. if (e.After.VoiceChannel.Name != null) I've also looked at the documentat...
ExoticDoom
1

votes
2

answer
730

Views

Discord.NET 1.0 send message event?

I'm trying to make a plugin in Discord.NET 1.0 which censor certain words, and was looking online for an event that would trigger when someone sent a text message, but couldn't fine one anywhere. I know how to do this in 0.9.6, but is there a way in 1.0? Any help would be much appreciated!
Daniel Lewis
1

votes
1

answer
187

Views

Setup a Dotnet core project

I want to code a application and deploy it on my Raspberry Pi 3. It will be a discord bot app using Discord.net library (C#). To do this i guess i need to use .net core because it will be deployed on another platform than Windows. But i'm not a expert in .net core as a matter of fact i always failed...
Shiglet
1

votes
3

answer
4.7k

Views

How to use Embedding with C#? Discord BOT

I am looking to embed the following: Using the Discord API. I have looked and the only resources I can find are for Python, Java, Ruby, etc. But when using: var embed = new Message.Embed( { Author = { Name = 'Name', Url = 'www.url.com' } }); It comes back with the message: And: Not sure What I need...
Zack Arnett
0

votes
0

answer
18

Views

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

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.
phob
1

votes
2

answer
676

Views

Program crashes when I try to get the IAudioClient for a channel

I am using Discord.Net Api to make a bot the connects to a discord server and I want to bot to play music and audio. I can make the bot join a channel and it works great, but when I try to get the IAudioClient for the channel(from the IAudioClient I can get the audio output stream so I can write the...
Eldar Azulay
1

votes
1

answer
8.2k

Views

Connecting to a voice channel and sending audio in Discord.net

After looking for hours I still can't find how should I set up sending an audio using Discord.net 1.0. All of the solutions I encountered have been for pre-1.0 relases and as far as I can see, new API is completly different. So my question is: How do i join voice channel and send music through? Do...
Kamil Rutkowski
1

votes
1

answer
561

Views

Discord.NET C# MessageReceived getting called too many times

i tried this code which i've copied from the github page of discord.net this one works perfectly fine: using Discord; using Discord.WebSocket; using System; using System.Threading.Tasks; namespace Adivisor { public class Program { private DiscordSocketClient _client; public static void Main(string[]...
Lyner
1

votes
1

answer
710

Views

Discord.NET Users playing the same game

I am trying to create a command that returns the number of guild members that are currently playing a specified game. Example (! is my prefix): !playing League of Legends. If there are 5 members playing League of Legends, output: There are 5 users currently playing League of Legends. I set up the fo...
Alex Diamond
1

votes
1

answer
735

Views

discord bot c# read received direct message

I'm currently trying to create my own bot for my Discord server. I'd like for a user to be able to type the command **event then the bot will direct message that user and ask it some questions for the event, such as title, time, etc. I'm able to get the bot to direct message the user but I can't fin...
RaineShadow
1

votes
2

answer
1.7k

Views

C# Discord Bot Parameter

I have finally successfully updated to discord.NET 1.0 and I'm trying to do a simple echo command, I don't know how to get the message as a string though, any help? [Command('say')] private async Task echo() { string input = message context.Channel.SendMessageAsync(input); }
Xilefen
1

votes
1

answer
950

Views

(Discord.Net) Pass a user to a command

I am currently coding a discord bot in discord.net. The command that I'm having trouble with is one that can display information about a user. If no parameter is given I already have it set up to display info about the current user. [Command('userinfo')] public async Task userinfo(IUser user = ???)...
Tanner H.
1

votes
1

answer
429

Views

c# Discord Bot Won't Take Commands During Command Delay

I've been messing around with Discord bots and I've been trying to make my own, however, I've come across an issue. One of the bots' commands says something, waits a minute, then deletes its message. The issue is not with that command, however with executing other commands. When you execute that com...
DylanC
1

votes
1

answer
101

Views

Save all Users in a certain Voicechat

I started coding a Bot a week ago and I'm trying to make my bot save all Users in Lounge 1 (Code below) in the var. 'v' and write every one of them a message. but 'v' seems to stay empty. And I have an error on the word 'client' (Can't use 'DiscordSocketClient'). var v = client.Guilds.First(x => x.I...
Norolinski
1

votes
1

answer
218

Views

Discord.NET - Get Which Type of Exception was Thrown in Command

I thought it would be easier to throw exceptions if say a person didn't have the right permissions to run a command, or there is a cooldown, or whatever, instead of just handling that every... single... time. So I made my own exceptions, but the problem is, that CommandService.ExecuteAsync().Error o...
Orion31
1

votes
3

answer
210

Views

My Discord Bot won't accept Users as parameters for commands

I'm currently working on a Discord bot to learn how to code one. I thought I had it down, but when I try to use the following command, it does nothing: [Command('ping')] public async Task Ping(IUser user) { await Context.Channel.SendMessageAsync(user.ToString()); } It's part of a public class, and i...
James Connor
1

votes
2

answer
0

Views

How do i convert Discord.IMessage to string, using getMessageAsync((ulong)id)?

I'm trying to use the last message sent in a discord channel as a string in a windows form app, but i cant seem to get the IMessage converted to string. I'm also having trouble getting the last sent message ID. Using GetMessagesAsync(10).First().ID returns 3 digits instead of 18? Using the actual Me...
Johnny Martinsson
1

votes
1

answer
904

Views

Discord.NET - Framework version issue

I am trying to write a bot for the Discord chat program in Visual C#. However, when I try to install Discord.NET from the NuGet package manager, it says I need .NET framework version 4.5, which is the one I have. I tried restarting my computer but it still doesn't work. Thanks, Matt I am using visua...
UltraLuminous
1

votes
2

answer
2.4k

Views

C# bot doesn't connect to voice channels (Discord.Net)

As described in the title, i can't seem to get my bot to join a voice channel in my discord. The code for the command: _commands.CreateCommand('join') .Description('Makes the bot join the first or default voice channel.') .Do(async (e) => { await e.Channel.SendIsTyping(); var voiceChannel = _client....
CaramelPanda
1

votes
1

answer
875

Views

C# Discord.NET Error joining voice channel

Trying to set up a discord bot to join a server and when using a try catch statement I get the following output in console: Any ideas on how to fix? I'm assuming I have to go to https://opus-codec.org/downloads/ and download the opus codec? - Thanks
Thomas Upson
1

votes
1

answer
3.6k

Views

How do I repeat a discord command every 24hrs in c# using Discord.net v0.9.6?

How do I set a command to automatically repeat every 24 hrs? private void RegisterMemeCommand() { commands.CreateCommand('meme') .Do(async (e) => { int randomMemeIndex = rand.Next(FullmetalMemes.Length); string memeToPost = FullmetalMemes[randomMemeIndex]; await e.Channe...
ST33LIO
1

votes
1

answer
2.3k

Views

Discord.Net Set bot's nickname

The title says it all, I want to set the nickname of my Discord bot. I've tried to Google this but I can't find anything.
Artline__
1

votes
1

answer
793

Views

How to assign a role with Discord.Net 1.0

So im trying to assign a role called 'verified' when a user types '!verifyme'. This is what I have so far : if (Context.Channel.Name == 'role-assignment') { var user = Context.User; IRole role; await (user as IGuildUser).AddRoleAsync(role); } If anyone knows how to do this, that would be great!
Unknown
1

votes
1

answer
265

Views

client.GetChannel(%channelID%) return null

Im creting discord bot via discord.Net v 1.0.2 And I want to get specific channel from my server Im trying to get that channel via Client.GetChannel(%channelID%) (Client is property of type DiscordSocketClient in my bot class) but that method return me only null and I just cant figure out why. I s...
Petr Kotáb
1

votes
2

answer
440

Views

discord.net c# :: user as IGuildUser returns null?

So I've been working on getting my bot to add a role to a user. Here's the bit of code that gets the user info. Just for context args[1] would be a user's ID. var user = _client.GetUser(Convert.ToUInt64(args[1])); I did a check to see if it actually processed that properly by doing Console.WriteLine...
Ethan
1

votes
1

answer
330

Views

Discord.net can't stream audio with NAudio

I want to play an mp3 file in a voice channel. The BOT successfully can connect, but doesn't play anything, and throws an exception. Code public async Task SendAudioAsync(IGuild guild, IMessageChannel channel, string path) { try { if (!File.Exists(path)) { await channel.SendMessageAsync('File does...
Noel Nemeth
0

votes
0

answer
4

Views

Cannot convert from Discord.ActivityType to Discord.IActivity C# Discord.Net

This is the command that i will use when setting the activity but im not quite sure how to set it. [Command('watch')] [RequireOwner] public async Task SetBotWatching([Remainder] string video) { await XyntaxBot.Client.SetActivityAsync(ActivityType.Watching); await ReplyAsync('Set Activity'); }
Ice
1

votes
2

answer
61

Views

How to use a Discord emoji in a C# if statement

I'm making a shop command for my bot, with the chestnut, ring, tangerine, doughnut and pick emojis in it as a test run. When I try to input the :chestnut: emoji as the item to purchase, it will save it as 'item', but it doesn't seem to be the same as ':chestnut:' in the if statement [Command('buy')]...
Jack Nutting
-1

votes
0

answer
14

Views

Recording replies in discord PMs

I am currently working on making an application bot in discord, and made a quick test to try to find a way to detect a reply in a PM channel between a user and my bot. After fiddling around with varying google searches and such, my best attempt was this: [Command('apply')] public async Task ApplyAsy...
Praise Allah
1

votes
1

answer
0

Views

Kicking a user in Discord.Net

I made this code to kick a user from the guild of a discord server The bot console doesn't give me any errors, but this code doesnt work properly when I try to kick a user. What I mean by this is that it doesn't kick the user, and it doesnt output anything in the channel. I also checked the bots per...
R Koekkoek

View additional questions