Is it possible to have one Discord bot DM another bot?

I'm building out an automated test bot that is meant to test the commands of my main bot. Everything is working fine except that my test bot doesn't seem to be able to receive DMs from the main bot.

I'm currently using discord.js

message.author.send('test dm from one bot to another')

and getting the error:

DiscordAPIError: Cannot send messages to this user

Is there a setting for the bot, or a possible workaround so that I can test my bot's DM functionality?

Both bots can receive DMs from users just fine.

  • Discord.NET Kick Command

    So I have a bot I'm working on for a computer science project, and my kick command isn't working. I've tried commenting out the update SQL and the ReplyAsync lines but it just won't kick the user. Am I using the wrong datatype for the user?

    public class Kick : ModuleBase<SocketCommandContext>
        {
            OleDbConnection con;
            OleDbDataAdapter da;
    
            [Command("kick")]
            [RequireUserPermission(GuildPermission.KickMembers)]
            [RequireBotPermission(GuildPermission.KickMembers)]
            public async Task KickUser(IGuildUser user, string reason = "No reason provided")
            {
                con = new OleDbConnection();
                con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=BotDB.accdb";
                da = new OleDbDataAdapter();
    
                con.Open();
                da.InsertCommand = new OleDbCommand($"UPDATE UserData SET NumKick = NumKick + 1 WHERE UserID = '{Convert.ToString(user.Id)}'");
                da.InsertCommand.ExecuteNonQuery();
                con.Close();
    
                await ReplyAsync($"{user.Nickname} was kicked from the server for '{reason}'");
                await user.KickAsync(reason);
            }
        }
    
  • Discord.NET isImage

    how can i check if the message is a picture? I have tried to check if the IReadOnlyList is 0 but this dosn't work.

    My Code:

    namespace Bot.Utils
        {
            class UtilClasses
            {
                public static bool isImage(SocketMessage message)
                {
                    bool isImage = false;
                    string Message = message.Content.ToString();
    
    
                        if (isImage)
                        {
                        isImage = false;
                        return isImage;
                        }
                    else
                        {
                        isImage = false;
                        return isImage;
                    }   
                }
            }
        }
    
  • Discord.py How do I delete a singular message in the rewrite

    I want to delete a singular message when triggered but I cannot figure it out. I got purge working with await ctx.channel.purge but that's not what I want since that requires an amount

    The old version was written like await self.bot.delete_message(ctx.message) but that now brings the error object has no attribute 'bot'

    Reading the documentation all I could find was Message.delete but that brings the error: NameError: name 'Message' is not defined

    I am sure this is a simple solution but I cannot work it out. Thanks in advance

    My current code is:

    @commands.command(pass_context=True)
    async def say(self, ctx, *args):
       '''Make Bot repeat your messages'''
        mesg = ' '.join(args)
        await Message.delete(ctx.message)
        await ctx.send(mesg)`
    
  • TypeError: Cannot read property 'channels' of undefined

    I'm making a discord.js welcome bot but this snippet of code is screwing with it.

    bot.on("guildMemberAdd", member => {
    	
    	bot.guild.channels.get('522087927623319573').send("welcome: ${member.user}")
    });
    But, it keeps returning with this:

    TypeError: Cannot read property 'channels' of undefined

    Does anyone know how to fix this?

  • TypeError: Cannot read property 'id' of null
    exports.delGuild = function(guild){
      db.run("DELETE FROM guilds WHERE id = ?", guild.id, (err, result) => {
        if (err) return console.log(err.message);
        console.log(`guild ${guild.id} removed from database`);
      });
    }
    

    I don't know why that happens just sometimes, but the program crashes.

  • Having issues finding a command handler

    So I am trying to find a way to make a command handler for this code:

    client.on('message', message => {
      if (!message.guild) return;
      if (message.content.startsWith(!handler))
      message.channel.send('Command')
    });
    

    Can someone help?