TypeError: message.reply is not a function

StanLachie

This is my first time using a command handler and I've been having some trouble adding a command it's not 100% finished so if the code doesn't make sense that's why. When I run the command I get the error listed below, I have no idea what's causing this and I'm really not good with this sort of stuff, any information/tips will help.

ERROR:

TypeError: message.reply is not a function
at Object.execute (C:\Users\lachi\Documents\src\Staniel Native\commands\rps.js:15:21)
at Client.<anonymous> (C:\Users\lachi\Documents\src\Staniel Native\index.js:47:32)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\lachi\Documents\src\Staniel Native\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\lachi\Documents\src\Staniel Native\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\lachi\Documents\src\Staniel Native\node_modules\discord.j    at WebSocketShard.onPacket (C:\Users\lachi\Documents\src\Staniel Native\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\lachi\Documents\src\Staniel Native\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\lachi\Documents\src\Staniel Native\node_modules\ws\lib\event-target.js:132:16)

index.js:

//Requirements//
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
client.commands = new Discord.Collection();
const Command_Files = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
require('dotenv').config()
//Bot Settings//
const Prefix = 's!';
const Bot_Name = 'Staniel';
const Bot_Activity = 'over the server!';
const Bot_Activity_Type = {type: 'WATCHING'}; //PLAYING|STREAMING|LISTENING|WATCHING|CUSTOM_STATUS|COMPETING//
//API Keys ETC//
const Discord_Token = process.env.DISCORD_TOKEN;
const YouTube_API = process.env.YOUTUBE_API;
const Twitch_API = process.env.TWITCH_API;
//Server IDs//
const Server_ID = client.guilds.cache.get('854000618367746049');
const Member_Count_Channel = '854375625552560168';
const YouTube_Sub_Count_Channel = '854424982460694529';
const Twitch_Follower_Count_Channel = null;



//On Start//
client.on('ready', () => {
    console.log(`${Bot_Name} is now online!`);
});



//Command Handler//
for (const file of Command_Files) {
    const command = require(`./commands/${file}`);
    client.commands.set(command.name, command);
};

client.on('message', message => {
    if (!message.content.startsWith(Prefix) || message.author.bot) return;

    const args = message.content.slice(Prefix.length).trim().split(/ +/);
    const command = args.shift().toLowerCase();

    if (!client.commands.has(command)) return;

    try {
        client.commands.get(command).execute(Prefix, client, message, args);
    } catch (error) {
        console.error(error);
        message.reply('Error executing that command!');
    }
});



//Run Bot//
client.login(Discord_Token)

rps.js:

module.exports = {
    name: 'rps',
    description: 'A simple RPS Minigame!',
    execute(Prefix, message, args) {
        //Customize Bot//
        No_Choice_Reply = `Correct Usage: ${Prefix}rps [rock|paper|scissors]`;
        Game_Tie_Reply = "";
        //DONT TOUCH//
        const Accepted_Replies = ['rock', 'paper', 'scissors'];
        const Bot_Algorithm = Math.floor((Math.random() * Accepted_Replies.length));
        const Bot_Choice = Accepted_Replies[Bot_Algorithm];
        const User_Choice = args[0];

        if(!User_Choice) message.reply("Test");
    },
};

Thanks, Lachie.

Jack Towns

The issue is how you pass to your commands, you are passing "Prefix, client, message, args" but then you have it like this in the command "Prefix, message, args" so you are trying to do client.reply which is not valid.

// Message Event
client.commands.get(command).execute(Prefix, client, message, args);

// Command
// What you have:
execute(Prefix, message, args) {

// What you need:
execute(Prefix, client, message, args) {

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TypeError: reply is not a function

Reply to a message with a webhook

Clickatel reply to a particular message

Discord.js reply to message then wait for reply

discord.js | Reply to Message (Actual Reply with Reply Decoration)

Error message "Uncaught TypeError: undefined is not a function" (DataTable)

TypeError: message.member.roles.some is not a function

TypeError: message.guild.channels.cache is not a function

Reply to messages using message ID

Vertx EventBus Reply a 'Specific' Message

Freeradius: No reply message for Failed Authentications

Django Channels not sending reply message

Serverless + Firebase: API is not reply message

Reply Message post processing in AsyncRabbitTemplate

Automatic reply with function Getsignature

Reply in ephemeral message to a user's message

Reply message received but the receiving thread has already received a reply

I am getting this error message: TypeError: 'function' object is not iterable

TypeError: message.client.commands.get(...).execute is not a function

Discord.JS TypeError: message.author.hasPermission is not a function

TypeError: message.guild.channels.find is not a function discord.js

Reply with string to function on JSON success

Shortcut key for "reply all" function

Twitter: direct message with quick reply is missing buttons

MySQL Advanced ORDER BY Clause for message reply system

Get last Message Reply From Conversation

Including original message in VSTO Outlook addin reply

AngularJS: obtain message reply before continue an action

how can i add reply message in conversejs

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive