Questions tagged [discord.net]

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
55

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
0

votes
0

answer
39

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
2

votes
2

answer
2.4k

Views

Discord.Net 1.0 How to use ModifyAsync/How to modify contents of a message

I'm trying to edit a message that my bot sent, but I can't seem to find any answers by myself. For context, the old message is a "waiting" message until the API I'm using retrieves the data I want. The new message is what the data that was received. This is my current solution: var msg = await Reply...
xubiod
2

votes
2

answer
6.5k

Views

Discord.net bot Embed Message

I am trying to implement embedded messages for my bot. I know that I need to fill an Embed Object with the specific informations. But how can I send it to the Channel? When I use e.Channel.SendMessage(string); it can't send an Embed object, it will just send strings.
2

votes
0

answer
33

Views

Get game being streamed from user's activity on Discord

I'm writing a discord bot in .net, and I need to get the name of the game being streamed by a user. In discord.py, this is possible with https://discordpy.readthedocs.io/en/rewrite/api.html?highlight=guild#discord.Streaming.details. I'd like to do this in discord.net, but 'Activity', along with Acti...
zirr
1

votes
2

answer
4.5k

Views

Discord: how to catch direct message from user to bot?

I am creating own bot for Discrod server. So far I have managed to give it commands like "!roll" into the chat and bot catches it replies "you rolled 6" to the chat as well. client.UsingCommands(input => { input.PrefixChar = '!' }); command.CreateCommand("roll").Do(async (e) => { await channel.Send...
Andrew
3

votes
1

answer
185

Views

C# Discord.NET: Why this ban module prevents anybody from interacting with my bot?

I am creating a Discord bot using the Discord.NET API. I have been implementing commands and modules to my bot for a while now, and I am attempting to add a ban command to my bot. I made the command so you have to have a role named "Bot Admin". Here is the code that I am using that seems to be causi...
hpenney2
3

votes
2

answer
2.7k

Views

Discord.Net — How to make Bot Ping users with “@”

I'm working on coding a bot that will retrieve an image based on search parameters. When the bot returns the message after the command, I want the bot to alert the user that sent the command with a ping. (the notification of a message using the "@" symbol in discord). Here's what I've got so far: aw...
2

votes
2

answer
3.8k

Views

Discord Bot (C#) Problems Joining Voice Channel

I have a problem with my bot joining voice channel. Code: using Discord; using Discord.Commands; using Discord.Audio; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DodoBot { class MyBot { DiscordClient discord; CommandSe...
Domen Jesenovec
2

votes
1

answer
174

Views

Messages does not get deleted?

Service.CreateCommand("delete") .Do(async (e) => { var MessageToDelete = await e.Channel.DownloadMessages(150); await e.Channel.DeleteMessages(MessageToDelete); }); I am trying to make my bot delete 150 messages when I do the command. But when I test the command, it doesn't work and the bot does not...
Jack
2

votes
2

answer
1.6k

Views

Discord.NET: Message.Edit method doesn't work

the method to edit a message won't work and I have no idea why. Here is my command: cService.CreateCommand("edit") .Do(async (e) => { await e.Message.Edit("edited!"); }); And here is the error I get: [Error] [MessageQueue] Failed to edit message Server/xxxxxxxxxxxxxxxxx Discord.Net.HttpException: Th...
2

votes
2

answer
521

Views

Discord.net not working on linux

I'm trying to get a discord bot coded in discord.net running on a linux VPS, I'm running via mono but I keep getting this error Unhandled Exception: System.Exception: Connection lost at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () in :0 at Discord.TaskManager.ThrowException () i...
xdMatthewbx
2

votes
1

answer
528

Views

Why is GetChannel on c# returning a null value? (discord bot)

Can anyone help me on this section of code? Before I say anything else, the "FillerId" isn't actually there in the actual code, it's replaced with the correct channel id of the discord text channel. The error I'm getting with this code is that every time I run this function, it returns an error sayi...
Cat76
2

votes
1

answer
826

Views

Change nickname on bot discordbot c#

So, I'm trying to change the nickname on the bot to the username of the command sender (?) So here is what I got going now but it changes the name to the id of the user? commands.CreateCommand("tts") .Parameter("userMsg", ParameterType.Unparsed) .Do(async (e) => { var server = _client.GetServer(*ser...
Lunix46
2

votes
1

answer
1.2k

Views

Given a connected and ready DiscordSocketClient and a Discord Channel Id, How does one send a message to that channel?

I am trying to set up automated messages. When I am setting up my client I use: client.Ready += OnClientReady; From there I start my Scheduler class: private Task OnClientReady() { var scheduler = new Scheduler(client); scheduler.Start(); return Task.CompletedTask; } Which looks like this: public cl...
Primalpat
2

votes
1

answer
268

Views

Bot can't connect to guilds

I'm trying to code a C# Discord Bot and it's just working fine so far. But since today it can't connect to any guilds. I'm 100% sure, I'm using the correct token and I've also authorized the bot to my own discord server, but it always throws this error: [ Error] Gateway: Error handling Dispatch (G...
Xilath
2

votes
1

answer
199

Views

ModifyAsync Not Working

I'm attempting to edit an embedded message after it is posted. I was attempting to use this example from the documentation but it just does not work. https://discord.foxbot.me/docs/api/Discord.MessageProperties.html var message = await ReplyAsync("abc"); await message.ModifyAsync(x => { x.Content =...
3

votes
1

answer
4k

Views

Discord C# User Join messages

I'm using Discord.Net in C#, making a bot. My bot works fantastic so far, but I want it to automatically assign users a specific role when they join a specific server. I've never actually learned any C#, only a bit of C++ so I know the basic Grammar. How would I go about this? I'm assuming I would u...
Zomon333
1

votes
1

answer
507

Views

The Discord.net UserUpdated event doesn't trigger

Using Discord.Net 1.0.1 I would like to use the UserUpdated event to detect when users change their status, but it seems that this even doesn't trigger regardless of what changes the user makes (like changing status, nickname, avatar, etc.) Sample code: this._client = new DiscordSocketClient(config:...
IneedHelp
1

votes
3

answer
7k

Views

Discord.NET How do I grant an user a role?

So I've been coding my discord bot and wanted to add a function to give an user a specific role like you are a player in a game and you type in a "cheat code" it grants you the cheater role. How can I do this? Thanks for helping.
1

votes
2

answer
3.5k

Views

Discord.NET Adding Reactions to a SocketMessage

I am using Discord.NET version 1.0.2 to clear things up I have a MessageReceived Task in my Discord Bot application: private async Task MessageReceived(SocketMessage message) This task, as can already be deducted, runs every time a message is received in Discord to this bot. I am trying to figure ou...
JarFile
1

votes
3

answer
510

Views

Discord.NET - Bot immediately disconnects after joining voice channel

I have all of the libraries (libopus.dll and libsodium.dll), I have FFMPEG and an audio file in my execution path, but still the bot immediately disconnects after joining the channel. Why is this happening and how do I fix it? EDIT: I use this sample for audio: https://gist.github.com/Joe4evr/773d3c...
M. Hofmann
2

votes
3

answer
519

Views

Is it possible to check if a channel exists?

I'm making a Discord bot and there's a channel in my server allocated to our rules and I want this bot to automatically send a message in that channel. Is it possible to check if the channel exists? Thanks.
Brandon
2

votes
2

answer
91

Views

Timer not starting unless function hasn't been called for certain amount of time

When the command .checked is not done for 15 minutes, I would like a timer to spam a message every minute. Right now I have it set to some ridiculously fast amount for testing purposes. Check() is called when .checked is done. I tried doing something like this: public static void Check() { Minecraft...
Praise Allah
3

votes
1

answer
549

Views

Discord.NET randomly disconnects and throws me an “Unknown opcode 9”

Why is that? What causes that error? I have a simple code that connects to the database and returns data to the discord user. And it's literally random (I tested it when no one used it at all). I've tried searching about it but most of the people complaining on existing bot and never actually resolv...
user2852371
7

votes
1

answer
878

Views

Continuous Message Sending in C#

I'm new to C#, and I am programming my first big project, a Discord bot. The idea is that the bot scans through comments, waiting for the word Cthulhu, and once someone says Cthulhu, the bot sends a message. However, in it's current state, it never stops sending messages. I suspect there's something...
Amature Programmer
2

votes
3

answer
6.2k

Views

Discord.net 1.0 - How to get Messages to delete?

so I am having problems with my command. It doesn't seem to show any problems, but when I go to use the command i get this back from my bot. "ERROR: The input text has too few parameters." I don't know if I should be using IUserMessage, or SocketMessage, i've tried both and usually get the same er...
Zachary Turner
2

votes
1

answer
595

Views

Discord.NET Guild.DefaultChannel does not work

I am coding a discord bot, and I want it to send a message to a server default channel whenever the bot joins a new server. Here is my code client.JoinedGuild += async guild => { var channel = guild.DefaultChannel; await channel.SendMessageAsync("test"); }; The error occurs on channel.SendMessageAsy...
Timity
3

votes
1

answer
441

Views

How to copy and say user's input?

I am making a discord bot and currently trying to make the bot repeat what the user says. cService.CreateCommand("say") .Parameter("user", ParameterType.Unparsed) .Do(async (e) => { Message[] CopiedMessage = await e.Channel.DownloadMessages(1); await e.Channel.SendMessage(CopiedMessage); //Error, on...
Jack