#development

1 messages · Page 902 of 1

pale vessel
#

it costs nothing

#

so, why not

#

i don't even know if you can define it like that (arr[7] =)

sudden geyser
#

you can, it's just wack

turbid bough
#

being explicit on array index is kinda bad when you want to edit the embed later on

pale vessel
#

interesting

#

i wouldn't use that method anyway

sudden geyser
#

There are methods like splice which can add an item at a specific index of an array.

digital ibex
#

i dont want to edit it tho lol

pale vessel
#

then use .push

turbid bough
#

dont tell me you never gonna edit the code later on?

digital ibex
#

no i'm not, why do i need to

turbid bough
#

when you need to

digital ibex
#

i don't need to

pale vessel
#

i honestly don't understand what's going on

sudden geyser
#

Well, do you want the Permissions field at the end of the fields list or not?

turbid bough
#

you dont need to now, but later

digital ibex
#

ok, i'll just figure it out myself lol

turbid bough
#

lol ok so you wont fix it?

pale vessel
#

good luck with that

earnest phoenix
#

ping

pale vessel
#

it's such an easy fix and you asked for help

#

¯_(ツ)_/¯

turbid bough
#

"i need fix"
"here is fix"
"i dont want this fix"

digital ibex
#

🗿

#

ok

pale vessel
#

i guess he's going to use array[6] =

turbid bough
#

oh no

digital ibex
#

nothing wrong with it lol

pale vessel
#

i guess

turbid bough
#

well, imagine if you were going to add an another field, then you would have to add that count

#

btw, why are you just using 6

#

why not array[array.count]?

pale vessel
#

ah yes, .Count()

turbid bough
#

i meant .length

pale vessel
#

i don't see how using .push would affect anything

turbid bough
#

it destroys his embed

sudden geyser
#

Think the conversation is over, but you should genuinely be using .push. The method exists for this reason.

pale vessel
#

how?

sudden geyser
#

how what

pale vessel
#

it destroys his embed

turbid bough
#

.push pushes everything away in the embed and just adds that one field /s

pale vessel
#

oh

#

i see

earnest phoenix
#

I still need help getting my custom prefix to execute commands

neat tinsel
#

Anyone know how I would fetch a member within a guild when sharding?

I can't seem to get it working as all the ways I try return

"let member = guild.members.get(i);
^
TypeError: Cannot read property 'get' of undefined"

when trying to get the member

#

(discordjs)

quartz kindle
#

when sharding, your guilds will be spit among shards

#

for example, at 2000 guilds and 2 shards, you will have approx 1000 guilds in one shard, and approx 1000 guilds in another shard (they are not split evenly)

#

so if you get a command from a channel in a guild in shard one, you cannot see guilds that are not in shard 1

neat tinsel
#

It's not for a command

#

I've got a thing in the ready event that checks a file every so often and then gets the guild ID from the file which then I need to get a certain member from the guild

quartz kindle
#

same thing applies

#

you get a guild id from the file, in one shard, but the guild is in the other shard

neat tinsel
#

so I cant broadcast something among all shards?

quartz kindle
#

yes you can

neat tinsel
#

WHich is what I need help with doing

quartz kindle
#

thats why broadcastEval exists

neat tinsel
#

me doing this.guilds.cache.get isnt working for me.

quartz kindle
#

exactly, you need to use broadcastEval

earnest phoenix
#

sorry

neat tinsel
#

In which I have it in.

#

As stated

quartz kindle
neat tinsel
#

Again, I have it in a broadcastEval.

quartz kindle
#

you didnt show your broadcastEval code

earnest phoenix
#

-botinfo 422087909634736160

gilded plankBOT
#
Bot info
ID

422087909634736160

Username

Discord Server List

Discriminator

8005

Short Description

The official Discord bot for the Discord Server List!

Library

discord.js

Prefix

N/A

Total Upvotes

1642

Monthly Upvotes

4

Server Count

No server count

Owner(s)

@fossil oxide dblAdmin dblMod
@languid dragon dblCertified
@bitter sundial dblAdmin

hasty lotus
#

hey, i've got a warning command that writes te warning of a user in json file, the command looks like this :

if(!warns[message.guild.id]) {
    warns[message.guild.id] = {}
  }

  if(!warns[message.guild.id][wUser.id]) {
    warns[message.guild.id][wUser.id] = 0
  }

  warns[message.guild.id][wUser.id] = Math.round(warns[message.guild.id][wUser.id] + 1)

  fs.writeFile("../warnings.json", JSON.stringify(warns), (err) => {
    if (err) console.log(err)
  });``` but when i restart the bot every warns are reset. Would anyone know how i could fix it ?
quartz kindle
#

how do you load the warnings file?

neat tinsel
#

this.client.shard.broadcastEval('this.guilds.cache.get(' + server + ')').then(results => console.log(results)).catch('Err: ' + console.error);

is the code I have for it.

quartz kindle
#

@neat tinsel you cannot retrive complex data over broadcastEval

#

you need to find the correct server, find the correct member, and execute what you want to execute, all inside the broadcastEval

#

you can only retrive simple data from it, like primitives

hasty lotus
#

@quartz kindle a require

#

const warn = require("../warnings.json")

narrow kettle
#

(c), any idea why im getting an error?

#include <stdio.h>

#define CHAR_SIZE 30
#define animals 2
typedef struct animal animal;

struct animal
{
    char type[CHAR_SIZE];
    char name[CHAR_SIZE];
    int age;
};

void scan(char* type, char* name, int* age);

int main(void)
{
    animal animal1 = {"", "", 0};
    scan(animal1.type, animal1.name, animal1.age);

    getchar();
    getchar();
    return 0;
}

void scan(char* type, char* name, int* age)
{
    printf("Please Enter Your Animal Type: ");
    fgets(*type, CHAR_SIZE, stdin);
    strtok(*type, "\n");
    printf("%s", *type);

    printf("Please Enter Your Animal Name: ");
    fgets(*name, CHAR_SIZE, stdin);
    strtok(*name, "\n");
    printf("%s", *name);

    printf("Please Enter Your Animal Age: ");
    scanf("%d", age);
    printf("%d",*age);
}
mossy vine
#

well what is the error

hasty lotus
#

uh no sry

wicked pivot
#

how to add a lot of emote quickly without having 100 lines of code? v11

quartz kindle
#

what

narrow kettle
#

this is the error, pretty sure its from the scan line(scan not scanf)

sudden geyser
#

a loop

hasty lotus
#

so @quartz kindle do you know why the json file is not saved ?

quartz kindle
#

@hasty lotus there are a lot of ways a json file can get corrupt and/or reset, i'd need to see your full code

hasty lotus
#

can we go dm ?

wicked pivot
#

I usually do await msg.react("..")
but if for example I want to add a 10th it is long enough to write and especially not very optimized

sudden geyser
#

just keep an array/list of your emojis and run a loop adding it (but with a rate limit)

mossy vine
#

d.js mostly handles rate limiting internally

#
for (const e of ['emoji', 'another emoji', 'anotha one']) {
  await msg.react(e)
}```
#

that should work

earnest phoenix
#

my bot now triggers on every message

#

one of my bot is bugged in the event messageUpdate

#

:c

#

my bot send 15msgs

quartz kindle
#

show code

restive furnace
#

@earnest phoenix ^

earnest phoenix
#

ok

#
  client.on("messageUpdate", async (oldMessage, newMessage) => {
       if(oldMessage.content != newMessage.content){ let count = await logs.obtener(oldMessage.guild.id);
  //Obtenemos el nombre del canal donde se edito el mensaje
  let nameChannel = newMessage.channel.name;
  // Obtenemos el nombre del usuario que edito el mensaje
        if (oldMessage.author.bot) return;
     await snipedit.establecer(newMessage.channel.id, {
        "author": newMessage.author.username,
        "antes": oldMessage.content,
        "despues": newMessage.content 
    })
    
  let member = newMessage.member.displayName;
  const embed = new Discord.RichEmbed()
    .setTitle("**MENSAJE EDITADO**")
    .setColor(0xff0000)
    .setThumbnail(newMessage.author.displayAvatarURL)
    .addField('Antes', oldMessage.content)
    .addField('Despues', newMessage.content)
    .addField('ID del mensaje', newMessage.id)
    .addField('Link del mensaje',`[Link](${`https://discordapp.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.id}`})`)
    .addField('Nombre del autor', newMessage.author.username)
    .addField('ID del autor', newMessage.author.id)
    .addField('Mencion del autor', newMessage.author)
    .addField('Nombre del canal', oldMessage.channel.name)
    .addField('ID del canal', oldMessage.channel.id)
    .addField('Mencion del canal', oldMessage.channel)
    .setTimestamp()
    .setFooter(newMessage.guild.name, newMessage.guild.iconURL);
  // enviamos un mensaje de información de la actualización de un emoji en un canal X
  client.channels.get(count).send(embed)};
});
royal portal
#

Hi so I have a thing that finds the channel in a server like '#memes-and-media' as a variable so I do ${channel} and it will show the channel '#memes-and-media' but if there's no channel named that, it says undefined. How would I make it so if that channel doesn't exist you get an error message saying that.

pale vessel
#

check if the channel exists

summer torrent
#
 RangeError: Maximum call stack size exceeded```
I get this error when I run this code:
```js
const twitter = require("twitter")

class Stream{
    constructor(client) {
        super(client)
        this.client = client
    }
    async run() {
        this.client.guildData.find({ feeds: { $exists: true, $not: { $size: 0 } } }, function (err, feeds) {
            if (err) throw new Error(err)
            const data = new Array()
            for (const feed of feeds) {
                data.push(feed)
            }
            console.log(data)
        })
    }
}

module.exports = Stream;```

@summer torrent

ripe lantern
#

as soon as my bot goes offline luca is like "OmG yOuR bOt Is OfF"

earnest phoenix
pale vessel
#

@summer torrent no trace?

digital ibex
#

how would i create a warn command? I've got a db

earnest phoenix
#

what would a db be needed for if its a warn command

digital ibex
#

you need it to store the warnings and stuff

earnest phoenix
#

oh like store a warning count?

digital ibex
#

i like !warn @officiallylost hi and then it'll warn me, then i do !modlogs @officiallylost or smthing and it'll show the reason, the moderator and the time etc

#

thats y u need a db

#

even if u dont want a modlogs command

#

p sure

earnest phoenix
#

cant you have all that sent to a channel?

digital ibex
#

what

restive furnace
#

you could just sent em to mod-log channels or smh and then when u do it yeah... its waaaay too complicated

#

msg.reactions == exists = false

#

well explained help: msg.reactions doesn't exists. and forEach loop cannot be ran on null/undefined item.

summer torrent
#

@pale vessel wdym

earnest phoenix
#

one of my bot is bugged in the event messageUpdate
:c
my bot send 15msgs

  client.on("messageUpdate", async (oldMessage, newMessage) => {
       if(oldMessage.content != newMessage.content){ let count = await logs.obtener(oldMessage.guild.id);
  //Obtenemos el nombre del canal donde se edito el mensaje
  let nameChannel = newMessage.channel.name;
  // Obtenemos el nombre del usuario que edito el mensaje
        if (oldMessage.author.bot) return;
     await snipedit.establecer(newMessage.channel.id, {
        "author": newMessage.author.username,
        "antes": oldMessage.content,
        "despues": newMessage.content 
    })
    
  let member = newMessage.member.displayName;
  const embed = new Discord.RichEmbed()
    .setTitle("**MENSAJE EDITADO**")
    .setColor(0xff0000)
    .setThumbnail(newMessage.author.displayAvatarURL)
    .addField('Antes', oldMessage.content)
    .addField('Despues', newMessage.content)
    .addField('ID del mensaje', newMessage.id)
    .addField('Link del mensaje',`[Link](${`https://discordapp.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.id}`})`)
    .addField('Nombre del autor', newMessage.author.username)
    .addField('ID del autor', newMessage.author.id)
    .addField('Mencion del autor', newMessage.author)
    .addField('Nombre del canal', oldMessage.channel.name)
    .addField('ID del canal', oldMessage.channel.id)
    .addField('Mencion del canal', oldMessage.channel)
    .setTimestamp()
    .setFooter(newMessage.guild.name, newMessage.guild.iconURL);
  // enviamos un mensaje de información de la actualización de un emoji en un canal X
  client.channels.get(count).send(embed)};
});
pale vessel
#

stack trace

summer torrent
pale vessel
#

try looking into those files and see what's wrong

sudden geyser
#

What is guildData?

earnest phoenix
#

any help????????????????

sudden geyser
#

Lil marcrock can you show more of your code

sudden geyser
#

as in the file

digital ibex
#

also, instead of doing the [link](httos:..)

earnest phoenix
#

ok

digital ibex
#

u can do [link](newMessage.url)

#

and u sure u not nesting events?

earnest phoenix
#
const snipedit = new db.crearDB("snipeedit");
if(command === 'snipeback'){
if (!snipedit.tiene(message.channel.id)) { //Primero se verifica si el canal tiene algún mensaje borrado guardado en la DB o no.
    message.channel.send("No hay mensaje recien editados en este canal.")
} else { //En caso contrario que si hay un mensaje borrado va mandar el snipe
    var snipauthor = await snipedit.obtener(`${message.channel.id}.author`) //obtenemos el autor
    var snipantes = await snipedit.obtener(`${message.channel.id}.antes`)
    var snipdespues = await snipedit.obtener(`${message.channel.id}.despues`)//obtenemos el mensaje
  let embed = new Discord.RichEmbed()
  .setTitle('Sniped')
  .addField(snipauthor, `Antes: ${snipantes}\n Despues: ${snipdespues}`)
  .setColor(0xff0000)
  .setThumbnail('https://media.tenor.com/images/9d727051bcfc50c615121bac07be6e9a/tenor.gif')
  message.channel.send({ embed })
}
}
event:  https://discordapp.com/channels/264445053596991498/272764566411149314/705827043689890184
#

@sudden geyser

sudden geyser
#

I can't read a lot of what the code does because it's in a different language but does the number of times the messages get sent increase over time, or does it stay at 15

#

if it's gradually increasing you may be nesting events

earnest phoenix
#

so, what is the problem?

sudden geyser
#

What version of Discord.js are you using @woven sundial

#

fetchMessages in v11 returns a promise resolving into a collection of messages. It's not meant to fetch a single message. That's what fetchMessage is for.

earnest phoenix
#

i do this and work
js //if (oldMessage.author.bot) return;

#

i // the if

sudden geyser
#

Not only that, fetchMessages does not include the list of reactions as it has to be fetched manually.

earnest phoenix
#

and work

#

wtf

sudden geyser
#

remove the s

earnest phoenix
#

i // the if
@earnest phoenix nvm that

#

the but is bugged

#

how i can reload a event?

sudden geyser
#

you save the file and restart your app or you remove the event (removeListener) and add it back

#

@woven sundial do you happen to know what part of your code is triggering the error?

earnest phoenix
#

i put this in the event onready
js snipe.purgeall() snipedit.purgeall()and work, lol

sudden geyser
#

That wasn't directed at you. That was to Lil Marco.

I've been skimming your code as it's hard to read, but does this look right?
const editableMessageID = messagePosted[msgID].psm
channel.fetchMessages(editableMessageID).then((message) => {

It's confusing to read as you don't define it anywhere except the bottom of your code. You also say you're using v11.5.1 but you have MessageEmbed at the bottom of your code.

rare mist
#

Im making a snipe command, what would be the best amount of chached messages? 1000?

broken ruin
#

Allow who has ADMINISTRATOR permission to send embed message from my bot will cause thing to my bot ?

#

If they shared something illegal for example

earnest phoenix
#

Shit the event is buggedddsssdss

edgy heron
#

internal server page error

#

when submitting my server

#

now 503 error

#

wow

iron scroll
broken ruin
#

Take screenshot for your code in BSB.js that do import to excute function @iron scroll

iron scroll
knotty steeple
#

u have way more of ur code to fix lmao

#

you have a trailing comma

#

you are trying to use template literals in a normal string

mossy vine
#

sam ur just gonna ignore the issues and go for the unnecessary trailing comma that doesnt even cause an error

knotty steeple
#

also somehow u arent passint message properly

#

what does your message event code look like

#

@mossy vine triggering

#

also u have an unused variable mmLol

surreal notch
#

I wanted to make cooldown command per user please help me in dm

knotty steeple
#

no

#

whats ur problem

#

have u attempted it?

surreal notch
#

@knotty steeple yes

#

attempted it

knotty steeple
#

and what happened

surreal notch
#

No responding

earnest phoenix
#

Amy help?

#

Any*

surreal notch
#

I have resete everything now need help how to do it again

#

reseted*

knotty steeple
#

and whats ur code

surreal notch
#

@knotty steeple can talk in dm?

knotty steeple
#

no

surreal notch
#

Ok

earnest phoenix
#

Sammy

surreal notch
#
const cd = require("./cooldown.json");
const Discord = require("discord.js");
const client = new Discord.Client();
const prefix = "p!";

//LOGIN
client.login("TOKEN");

client.on("message", message => {   
  //RETURN IF USER IS A BOT
  if (message.author.bot) return;
  
  //GETTING CURRENT MILLISECONDS
  let date = new Date().getMilliseconds(); 
  //CHECKING IF USER CAN USER THIS COMMAND
  let canUse;
  if (cd[String(message.author.id)] !== undefined) canUse = (cd[String(message.author.id)] >= 21600000);
  else canUse = true;
  if (message.content.toLowerCase() === `${prefix}credits` && canUse && String(message.author.id) !== "460690666964385803" /*YOU*/) { 
    if (!canUse) {
      message.channel.send("You can only use this command one time in 6 Hours");
      return;
    };
    var numbers = [
      "You have recieved 5 credits for Pokecord Bot\n\nYour reddem code is  ||NwEf||\n\nDM ULTRON#4070 to recieve your gift with reddem code",
      "You have recieved 10 credits for Pokecord Bot\n\nYour reddem code is  ||FtwK||\n\nDM ULTRON#4070 to recieve your gift with reddem code",
      "Better Luck Next time try again in 6 hours",
      "Better Luck Next time try again in 6 hours",
      "Better Luck Next time try again in 6 hours",
      "You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is  ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code"
    ];
    var answer = numbers[Math.floor(Math.random() * numbers.length)];
    var embed = new Discord.MessageEmbed()
      .setColor("#FF4500")
      .setTitle("Pokécord Credits")
      .setDescription(answer);
    message.channel.send(embed);
    //ADDING THE USER TO THE FILE
    cd[String(message.author.id)] = date;
client.on("ready", () => {
  console.log("Bot was logged in"); // Output a message to the logs.
});```
#

Here is code

earnest phoenix
#
if(command === 'snipeback'){
if (!snipedit.tiene(message.channel.id)) { //Primero se verifica si el canal tiene algún mensaje borrado guardado en la DB o no.
    message.channel.send("No hay mensaje recien editados en este canal.")
} else { //En caso contrario que si hay un mensaje borrado va mandar el snipe
    var snipauthor = await snipedit.obtener(`${message.channel.id}.author`) //obtenemos el autor
    var snipantes = await snipedit.obtener(`${message.channel.id}.antes`)
    var snipdespues = await snipedit.obtener(`${message.channel.id}.despues`)//obtenemos el mensaje
  let embed = new Discord.RichEmbed()
  .setTitle('Sniped')
  .addField(snipauthor, `Antes: ${snipantes}\n Despues: ${snipdespues}`)
  .setColor(0xff0000)
  .setThumbnail('https://media.tenor.com/images/9d727051bcfc50c615121bac07be6e9a/tenor.gif')
  message.channel.send({ embed })
}
}
event:  https://discordapp.com/channels/264445053596991498/272764566411149314/705827043689890184
valid frigate
#

whats the problem

surreal notch
#

How to define talkedrecently

#

@valid frigate

#

Ok i got it

#
  //RETURN IF USER IS A BOT
  if (message.author.bot) return;
if(message.content.toLowerCase() === `${prefix}credits`) {
    var numbers = ["You have recieved 5 credits for Pokecord Bot\n\nYour reddem code is ||NwEf||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 10 credits for Pokecord Bot\n\nYour reddem code is  ||FtwK||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this",  "Better Luck Next time try again in 6 hours", "Better Luck Next time try again in 6 hours","Better Luck Next time try again in 6 hours","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is  ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is  TraW\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this"
    ];
    var answer = numbers[Math.floor(Math.random()*numbers.length)];
    var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Pokecord Credits**").setDescription(answer)
    message.channel.send(embed)
if (talkedRecently.has(message.author.id)) {
            message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
    } else {

           // the user can type the command ... your command code goes here :)

        // Adds the user to the set so that they can't talk for a minute
        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after a minute
          talkedRecently.delete(message.author.id);
        }, 60000);
    }
    }
})```
#

I have used these codes for cooldown

#

But it is showing like this

turbid bough
#

well, thats cause you are sending 2 messages

#

your message.channel.send(embed) is right before the if statment you use to check if the user has spoken or not

#

that should be after the else{

surreal notch
#

ok let me try

#

@turbid bough but now cooldown is not working

turbid bough
#

are you sure?

#

if you restart the bot, then the cooldown wont happen if you don't the command twice

surreal notch
#

Yup it worked

#

@turbid bough but how to make it of 6hrs

turbid bough
#

in the second setinterval parameter

surreal notch
#

How correct?

turbid bough
#

yes

surreal notch
#

Ok

turbid bough
#

though it's cooldown only works when the bot is online

#

all the time

surreal notch
#

Okk

#

How to make bot 24/7 up

rare mist
#

Heroku

turbid bough
#

don't shut it off

#

thats limited

surreal notch
#

but it is not possible for meXD

pale vessel
#

heroku isn't 24/7

#

it restarts your app every 24 hours + random 215 minutes

surreal notch
#

i m on glitch

rare mist
#

it is, u just to add a credit card and thats all u dont have to spend money

earnest phoenix
#

Can anyone help me with this? I want to make a BOT of music which also has more commands, memes, ping, all that. So, I want to make "VIP" commands which are activated with a "! Claim" code "" And I want the bot to put it in the VIPS list, the code is activated by the bot automatically, and, if I need more codes I put "! code" numbercodes "" and it sends them to the MD. I dont know how to code the "!claim" Command.

pale vessel
#

no

rare mist
#

no

pale vessel
#

free dyno cycles

#

cycle means that it restart every 24 hours no matter what

rare mist
#

Mine restarts every 24 hs

#

Well i dont mind thst

turbid bough
#

exactly

pale vessel
#

216 mins, my bad

turbid bough
#

proven yourself wrong lol

surreal notch
#

btw i have coded it like that it gets ping in every 5mins

rare mist
#

I dont mind the restarts i use the heroku database to save stuff

turbid bough
#

yeah, but he does not

#

soo

rare mist
#

rip i guess :V

turbid bough
#

easy, just host a database too

surreal notch
#

I want that i could use that command anytime but others need to wait 6 hrs

#

@turbid bough

turbid bough
#

just compare the author id with your id

surreal notch
#

@turbid bough how?

turbid bough
surreal notch
#

Like this?

#

but how to compare

#

No

turbid bough
#

nah

surreal notch
#

(message.author.id) !== "460690666964385803"

#

Like this?

#

Ok so where to paste it?

turbid bough
#

mhm

#

first if statement

#

with an or

surreal notch
#

if (message.content.toLowerCase() === `${prefix}credits` && canUse && (message.author.id) !== "460690666964385803"

#

Like this?

turbid bough
#

no

surreal notch
#

then?

#

edit this and send back

pale vessel
#

why String() ?

surreal notch
#

if (message.content.toLowerCase() === `${prefix}credits` && canUse && message.author.id !== "460690666964385803"

#

Now?

pale vessel
#

you don't need to surround it with ()

turbid bough
#

i meant on the last if statement*

surreal notch
#

Now correct

#

see above

pale vessel
#

not quite

#

close the statement

surreal notch
#

then

#

how

turbid bough
#

that will only make it so you cant execute it

surreal notch
#

else canUse = true;

turbid bough
#

yeah but you used &&

surreal notch
#

else &&canUse = true;

#

?

#

lol

turbid bough
#

no

surreal notch
#

you type

#

how to write it

turbid bough
#

here is how i would do it

#
if(message.content.toLowerCase() === `${prefix}credits`) {
    var numbers = [""];
    var answer = numbers[Math.floor(Math.random()*numbers.length)];
    var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Pokecord Credits**").setDescription(answer)
    message.channel.send(embed)
    
    if (talkedRecently.has(message.author.id)) {
        message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
        return;
    }else if(message.author.id != 460690666964385803){
        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after a minute
          talkedRecently.delete(message.author.id);
        }, 60000);
    }
    
    message.channel.send(embed)
}```
surreal notch
#

ok

turbid bough
#

ah wait nvm

#

wrong

#

lol

surreal notch
#

LoL

turbid bough
#
if (talkedRecently.has(message.author.id)) {
    message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
    return;
}else if(message.author.id != 460690666964385803){
    talkedRecently.add(message.author.id);
    setTimeout(() => {
        // Removes the user from the set after a minute
        talkedRecently.delete(message.author.id);
    }, 60000);
}```
#

that will make it so you wont have any timeout

surreal notch
#

Okk

#

if i want to add more ids?

#

then use ,

turbid bough
#

use an array

#

then it would be more like

sudden geyser
#

It would be much easier to make a rate limit system by making commands modular // command handler.

turbid bough
#

if(!usersBypass.has(message.author.id))

surreal notch
#

@turbid bough but

#
}else if(message.author.id != 460690666964385803){
        // Adds the user to the set so that they can't talk for a minute

        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after 6 hours
          talkedRecently.delete(message.author.id);
        },     21600000);
    }
    }
})```
#

i have done thi

#

this

#

and someone is typing anything it occurs

turbid bough
#

message.channel.send(embed)

#

wrong place

sudden geyser
#

the ID of a user is always going to be a string

surreal notch
#

@turbid bough then where it should be

turbid bough
#

i just sent you the code

surreal notch
#

@turbid bough should i paste your codes after message.channel.send(embed)

turbid bough
#

no

#

before

surreal notch
#

Ok

astral yoke
#

hes learning

sudden geyser
#

Strict comparison is usually considered over loose comparison (===). When you have a number that large in JS and try to compare it, some of the ending digits become rounded.

sudden geyser
#

Like 460690666964385803 became 460690666964385800

turbid bough
#

oh right, i did notice that sometimes it would do that

surreal notch
#

LoL

#
        // Adds the user to the set so that they can't talk for a minute
        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after 6 hours
          talkedRecently.delete(message.author.id);
        },     21600000);
    }
    }
})```
#

Where i have to put my id in these codes

#

i am not clear

turbid bough
pale vessel
astral yoke
surreal notch
#

yup

turbid bough
#

then read it again

surreal notch
#

wait

#

lemme try again

astral yoke
surreal notch
#

but error comes

#
        // Adds the user to the set so that they can't talk for a minute
        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after 6 hours
          talkedRecently.delete(message.author.id);
        },     21600000);
    }
    }
})```
#

tell me here where i have to put it

turbid bough
#

why is that message.channel.send(embed) still there?

surreal notch
#

coz these have no error

turbid bough
#

did you even read the message

astral yoke
surreal notch
#

how much time do you edit

turbid bough
#

idk, you say you have error but i dont see it anywhere you send it

#

i only see the embed and the timeout adding

astral yoke
#

tell us the error

surreal notch
turbid bough
#

👀

surreal notch
#
    
    if (talkedRecently.has(message.author.id)) {
        message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
        return;
    }else if(message.author.id != 460690666964385803){
        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after a minute
          talkedRecently.delete(message.author.id);
        }, 60000);
    }
    
    message.channel.send(embed)
}```
#

Codes!

#

@turbid bough ?? whats the mistake

turbid bough
#

idk, might be an error from another part of the file?

surreal notch
#

nope from there only

#

i have only cmd

turbid bough
#

can you send the whole file?

surreal notch
#

wait

turbid bough
#

javascript is so stupid

surreal notch
#

@turbid bough

heavy anchor
#

no u

surreal notch
#

lol

turbid bough
#

where is line 71?

surreal notch
#

there is not line 71

#

here the error

#

@turbid bough did you get it

turbid bough
#

ah nvm

surreal notch
#

Ohh

turbid bough
#

you are missing two }

#

at the end of the onmessage function

surreal notch
#

where is onmessage function

#

line?

turbid bough
#

9

#

and a )

surreal notch
#

Ah

#

where i supposed to put }

turbid bough
#

on line 35

dusty onyx
#

heyo, how can i change my bots presence so it switches between two games every 30 seconds or so?

earnest phoenix
#
  .then(console.log)
  .catch(console.error);```

What should i put in place of then ?
turbid bough
#

?

earnest phoenix
#

is the code right ?

surreal notch
#

@earnest phoenix

#
  console.log("Bot was logged in"); // Output a message to the logs.
});```
#

Maybe this

earnest phoenix
#

@surreal notch ?

#

i want it to create a logchannel

surreal notch
#

what you want to do?

earnest phoenix
#

for warns/bans/kicks/mutes

turbid bough
#

then after an if statement wont work

surreal notch
#

Ohh

earnest phoenix
#

@turbid bough and how should i do the code?

turbid bough
#

you remove then ?

sudden geyser
#

its true
yeah

earnest phoenix
#

@turbid bough yes

hard relic
#

hi, hoping someone can help me here but I am trying to list a promise for csgo stats but it gets cut off. I am using Windows powershell 7 for this. How can I view the entire list?

nvm - got it, parse into json and then list array of names

pale vessel
#

require("fs").writeFileSync("./result.json", jsonData);

clear wraith
#

I always get that error in the logs after i run certain command.

#

Does anyone know why?

#

It says this in the logs:

#

I don't know if i need to change something.... or if its ok.

quartz kindle
#

wherever you're doing commandFile.run(), you're doing it on a command that has no .run() function

clear wraith
#
    if (!commandfile) return;
    commandfile.run(client, message, args);
  }
};
#

@quartz kindle ^

#

So do i add () to the end of commandfile.run?

quartz kindle
#

no

#

that code is correct

#

the problem is that the command you're using has no run function

clear wraith
#

mhmm

#

Ok

topaz fjord
#

@quartz kindle tim

#

i need ur big brain real quick

#

cause idk

#

should I have functions for each section

#

e.g. getGeneralSection(), getXSection()

#

or

#

getSection(sectionName)

quartz kindle
#

personal preference?

prisma locust
#

My boat log error

At timeout.client.setTimeout (/rbd/pnpm-volume/437b153a-b0c4-4ced-947e-2129d4329dfb/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/ClientManager.js:40:57)
  at Timeout.setTimeout [as _onTimeout] (/rbd/pnpm-volume/437b153a-b0c4-4ced-947e-2129d4329dfb/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/Client.js:436:7)
 at ontimeout (timers.js:498:11)
  at tryOnTimeout (timers.js:323:5)  at Timer.listOnTimeout (timers.js:290:5)
(node:3202) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:3202) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
Pls help me
split hazel
#

Are you using glitch? @prisma locust

prisma locust
#

yes @split hazel

split hazel
#

Discord bans some glitch ip's for abuse. While your bot might've not necessarily abused the API, others may have on that ip which caused the ban

#

Glitch has a thread for this I believe

magic jackal
#

Hey guys I have some server questions.

#

I am attempting to migrate hosts, currently I pay for the Digital Ocean $15 2 vCore 2gb of RAM plan.

I would like to move to a stronger system, we are running into lag issues with this one and I kinda wanna pick a new one due to the demand the bot is using. What host should I aim for or should I go straight dedicated?

split hazel
#

How many guilds? And what's your average memory usage

topaz fjord
#

what lib mmLol

split hazel
#

wanted to add that

magic jackal
#

DiscordJS / DiscordJDA / 1500 Guilds / 80k Users / avg RAM usage is like 1GB

quartz kindle
#

why both jda and js?

magic jackal
#

A couple different bots but they are small so it doesnt matter much

quartz kindle
#

ah

#

are you using intents yet?

magic jackal
#

Not quite yet, soon™️

#

@split hazel any input? :)

quartz kindle
#

well im using galaxygate and im satisfied with it

#

but my bot its extremely optimized

magic jackal
#

I'll take a look

split hazel
#

tim speaks for me rollonthefloor

topaz fjord
#

@quartz kindle they're kinda sold out lmao

magic jackal
#

oh ok.

split hazel
#

i wanna start using intents but the lib is outdated on my side, and too many breaking changes to fix

quartz kindle
#

lmao

topaz fjord
#

they have a stock role tho so you'll get pinged when they're back

#

(if you join and ask for it)

split hazel
#

obviously if it becomes mandatory (which i think it will) then i'll have to put in effort

#

over 50 files so its not gonna be fun

quartz kindle
#

rip

split hazel
#

i'll probably use bash to help me replace some things

#

most things anyway

topaz fjord
#

I just use intellij refactor

magic jackal
#

What plan do you guys use?

topaz fjord
#

for GG?

quartz kindle
#

i use the $3 one

magic jackal
#

Yea

topaz fjord
#

I use the $10 one

magic jackal
#

how many guilds / users do you server?

quartz kindle
#

about 3000 guilds for me

topaz fjord
#

around 2.5k for mine

split hazel
#

around 18k for mine (almost 19)

magic jackal
#

@earnest phoenix ^^^

split hazel
#

memory usage isn't very kind

quartz kindle
#

memory usage isnt a problem for me :^)

#

sitting comfortably at ~170mb ram

earnest phoenix
#

you guys can get more than verified

split hazel
#

yes with your cool modified lib kittyShy

topaz fjord
#

I expected my JDA bot to take a lot of ram

#

it doesn't

split hazel
#

i might migrate to use yours if i get the time

magic jackal
#

Yeah mine is pretty quick, I just think its something to do with being shared on DO

split hazel
#

or i'll make my own memory efficient lib based on yours kittyNoms

magic jackal
#

🍴

quartz kindle
#

if you wait a month or two, you can try using my next lib

split hazel
#

👀 fancy

quartz kindle
#

i will need testers and contributors

magic jackal
#

Me, I'd be down haha

split hazel
#

why not sounds epic

clear wraith
quartz kindle
#

:D

#

@clear wraith you mean with new lines?

topaz fjord
#

use \n

#

that's how

clear wraith
#

Yes

quartz kindle
#

^

split hazel
#

if you're using .map join it with \n

topaz fjord
#

if it's an array of command you can join by doing array.join('\n')

quartz kindle
#

for example: "abc\nxyz" becomes
abc
xyz

split hazel
#

yup

clear wraith
#

so like... n\candy, n\cuddle

#

ohhh

topaz fjord
#

no

#

\n

#

not n\

magic jackal
#

\n

clear wraith
#

Like that?

quartz kindle
#

no need for that many ` but it should work

#

also no need for spaces

clear wraith
#

can I put the `` on the outside of that?

quartz kindle
#

you can do "candy,\ncuddle,\netc..."

royal portal
#

I'm not sure how to make it so my bot can respond to commands with spaces

quartz kindle
#

you can as well

clear wraith
#

ok

#

Thanks

royal portal
#

because if I use if(command === "help 2") { it doesnt work

#

only without space

#

anyone know the solution?

quartz kindle
#

how do you define command?

clear wraith
quartz kindle
#

you dont need two `

#

one is enough

#

on each side

clear wraith
#

Ok

royal portal
#

let prefix = "-";
if (message.content.indexOf(prefix) !== 0) return;

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

#

and then the command part

quartz kindle
#

you split the message into words

#

so help would be one word, 2 would be another word

topaz fjord
#

2 would be counted as args[0]

quartz kindle
#

command is only the first word

#

all other words are in your args

royal portal
#

so args[2].shift() ?

quartz kindle
#

so you need to do some if nesting

#

no

#

just this

#
if(command === "help"){
  if(args[0] === "1") {
  
  } else if(args[0] === "2") {
  
  }
}```
#

etc

#

or use a switch case

clear wraith
#

Above candy

quartz kindle
#

remove the \n from the beginning

#

you're adding a \n before candy

clear wraith
#

Yeah, Fixed. Thanks!

royal portal
#

not working

#

if(command === "help 2"){
if(args[0] === "1") {
message.channel.send("hello")

} else if(args[0] === "2") {
message.channel.send("hello2")

}
}
});

quartz kindle
#

you have one space too much in your split

#

/ +/ not / + /

royal portal
#

oh

#

so then would the code work or do I change something

quartz kindle
#

also, the command is help

#

not help 2

#

command is help, 2 is args[0]

royal portal
#

I mean like I need spaces in my commands

#

because I can do it normally but doesnt work with spaces

quartz kindle
#

because you're not using them correctly

#

first fix your split

royal portal
#

done

quartz kindle
#

now change help 2 to help

#

command === "help"

royal portal
#

done

quartz kindle
#

now it should work

pale vessel
#

also, consider using switches

royal portal
#

@quartz kindle still doesnt

quartz kindle
#

show full code

earnest phoenix
#

my problem is that I have a custom prefix command, The custom prefix works but I'm unable to change it. It gives me execute as undefined, here's the code for said command```const Discord = require('discord.js');
const Keyv = require('keyv');
const prefixes = new Keyv('I am kinda dumb');
const config = require('../config');
const globalPrefix = config.globalPrefix;
module.exports = {
name: 'prefix',
description: 'changes server-wide prefix',
execute: async (message, args) => {

    if (args.length) {
        await prefixes.set(message.guild.id, args[0]);
        return message.channel.send(`Successfully set prefix to \`${args[0]}\`:sc3:`);
    }

    return message.channel.send(`Prefix is \`${await prefixes.get(message.guild.id) || globalPrefix}\``);
}

}```

quartz kindle
#

which part doesnt work?

royal portal
#

if (command === "help") {
if(args[0] === "2") {
message.channel.send("hello2")

} else if(args[0] === "3") {
message.channel.send("hello3")
}
}
});

#

I changed the split too

quartz kindle
#

when you give it a new prefix, does it set it successfully? or does it throw the error?

#

@royal portal that part is correct, show more

earnest phoenix
#

the part if (args.length)

royal portal
#

so if I do help 2 it should work?

quartz kindle
#

it should

#

@earnest phoenix what happens then you try to set a prefix?

royal portal
#

but if its a command so only members with that role can use then would the message.member.roles.cache.some be after the if(args[0] === "2") { or before it?

earnest phoenix
#

@quartz kindle gives back cannot read property 'execute' of undefined

quartz kindle
#

both when you set it and when you view it?

#

ie: when you run it without args

earnest phoenix
#

viewing it works, setting it gives error

quartz kindle
#

your problem is likely elsewhere, not there

#

in the code that calls the execute function

earnest phoenix
#

would you like to see the main file?

quartz kindle
#

@royal portal it would be after yes, first you need to figure out which command the user wants, then you check for permissions and what not

#

yes

earnest phoenix
#
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    bot.commands.set(command.name, command);
}
bot.on('debug', console.log);
bot.once('ready', () => {
    console.log('Bot Started With No Errors');
    bot.user.setPresence({
        activity: {
            name: 'Crying Without Knowing Why | chelp to Start'
        },
        status: 'idle'
    })

}) 

    bot.on('message', async message => {
        if (message.author.bot) return;
        
        const args = message.content.slice(globalPrefix.length).split(/\+/);
        const commandName = args.shift().toLowerCase();
        
        const command = bot.commands.get(commandName) ||
            bot.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));


        if (message.content.startsWith(globalPrefix)) {
            prefix = globalPrefix;
        } else {
            
       
            const guildPrefix = await prefixes.get(message.guild.id);
            if (message.content.startsWith(guildPrefix)) prefix = guildPrefix;
            
        }
        try {
            command.execute(message, args);
        } catch (error) {
            console.error(error);
            message.channel.send('there was an error trying to execute that command!');
            if (typeof execute !== 'undefined') {}
            if (!message.content.startsWith(guildPrefix)) return;
        }
    })


bot.login(token);```
quartz kindle
#

@earnest phoenix your split is also wrong

earnest phoenix
#

hm

#

remove the backslash?

quartz kindle
#

replace it with a space

#

or add an s to it

earnest phoenix
#

wym add an s?

quartz kindle
#

/ +/ splits on regular spaces
/\s+/ splits on all kinds of spaces

#

the + makes it treat consecutive spaces as a single space

earnest phoenix
#

that actually worked

#

thank you

royal portal
#

@quartz kindle I still can't figure it out

#

doesn't give an error

quartz kindle
#

show full code

royal portal
#

k

#

hold on

hasty lotus
#

hey would anyone know an open source starboard with djs 11 or 12 that i could use ?

#

or just take example on

#

^^

#

@royal portal like you pp :p

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = "!"

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', message => {

  let prefix = "!";
if (message.content.indexOf(prefix) !== 0) return;

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

if (command === "help") {
if (!message.member.roles.cache.some(role => role.name === 'allowed')) return;

if(args[0] === "two") {
message.channel.send("helptwo")

} else if(args[0] === "three") {
message.channel.send("helpthree")
}
  }
});

client.login('token');
hasty lotus
#

what is the pblm with this code ?

royal portal
#

with what code

hasty lotus
#

yep

royal portal
#

?

hasty lotus
#

what is the pb

#

what is the error

royal portal
#

theres no error

#

I just want a space in my command

smoky spire
hasty lotus
#

uh thx

#

^^

royal portal
#

@quartz kindle I sent the code

quartz kindle
#

@royal portal you didnt fix your split

royal portal
#

its / + / g

#

oh

#

I had it on / +/ g

#

changed it

#

is that all

quartz kindle
#

yes

royal portal
#

so if i say

#

help two it would work?

quartz kindle
#

yes

royal portal
#

hm ok

#

thanks @quartz kindle

#

it works

earnest phoenix
#

Umm can i ask a question in here?

royal portal
#

sure

earnest phoenix
#

How can I create a bot?

royal portal
#

well first of all you can pick a library like

#

discord.js

#

or py

earnest phoenix
#

Ok

#

Im there

#

Do I have to install the app?

#

Because if so, imma try it not now

quartz kindle
#

you need basic knowledge of programming

#

start by learning the basics of a programming language

earnest phoenix
#

Im good at programming

quartz kindle
#

bots can be done with many programming languages

#

do you have experience with any particular language?

earnest phoenix
#

Python?

quartz kindle
#

sure

earnest phoenix
#

A little bit

quartz kindle
#

its a discord library for python

earnest phoenix
#

Ok

#

Yes im there

#

Nah im not able to install it Imma go on Computer later

#

Thx

grizzled raven
#

tim be my teacher

#

guardian

#

because intents

topaz fjord
#

intents are easy

grizzled raven
#

nah ik

#

but theres literally like one thing

quartz kindle
#

lmao

queen needle
#
if(message.content.startsWith(prefix + 'poll')){
 if(message.author.bot) return;
  
  

  if(!args[0]) return message.reply("please include a question for the poll")
  
  message.channel.send(
    new Discord.RichEmbed()

    .setTitle(`${message.author.username}'s poll`)
.setColor("#FF0000")
.setDescription("poll")
.addField("question", args[0])

    ).then(message.react("👍"),  message.react("👎"))
  

}
#

It reacts to the command not to the embed

topaz fjord
#

because message is the message sent by the user

queen needle
#

How could I get it to react to the embed?

topaz fjord
#

since .send returns a promise of the sent message, you can do ```js
.then(msg => {
// Whatever you want to do with msg.
})

#

make sure to do await msg.react()

#

so they get added in a specific order

queen needle
#

Why await?

topaz fjord
#

if not it'll get added in whatever order

queen needle
#

Oh okay

#

Thank you :)

topaz fjord
#

np

hasty lotus
#

hey, i'm making a reset server command, that deletes every channels and every roles, and i would like to do a kind of verification, so for the moment the code is like that :

msg.reply("Doeing this will erase every channels and every roles of your server. Type /resetconfirm to confirm")```
Would you know how i could do this ?
topaz fjord
#

d.js?

quartz kindle
#

channel.awaitMessages()

topaz fjord
#

^

hasty lotus
#

yes but after the await ?

topaz fjord
#

they give an example

hasty lotus
#

ok thx

earnest phoenix
#

Umm i think Python is too hard for me

#

Any easier ways???

quartz kindle
#

the easier way is always whichever language you're the most comfortable with

topaz fjord
#

are you jumping into coding or learning it before hand

#

you should be doing the latter

#

and then start coding

earnest phoenix
#

Im not the best in enhlish sry

quartz kindle
#

if you already know a little python, stick with python, unless you actually want to learn a different language from scratch

queen needle
#
 if(message.author.bot) return;
  
  

  if(!args[0]) return message.reply("please include a question for the poll")
  
  message.channel.send(
    new Discord.RichEmbed()

    .setTitle(`${message.author.username}'s poll`)
.setColor("#FF0000")
.setDescription("Poll")
.addField("question", args[0])

    ).then(msg => { 
await msg.react("👍"),  msg.react("👎")
})
  

}
```    await only able to be used I. A async function?
hasty lotus
#

yep

#

@queen needle

earnest phoenix
#

Ifk anything about python

topaz fjord
#

you can do

queen needle
#

How would I fix that?

earnest phoenix
#

Idk*

#

[WS => Manager] Manager was destroyed. Called by:
Error: MANAGER_DESTROYED?

hasty lotus
#

in you message event

quartz kindle
#

@earnest phoenix do you know any other language besides python?

topaz fjord
#
.then(async msg => {
  await shit;
})
#

@queen needle

#

put async before the msg

earnest phoenix
#

Umm i am good in html

topaz fjord
#

and it should allow you

hasty lotus
#
client.on("message", async message => {}```
#

@queen needle

topaz fjord
#

you can do that too

#

either one works

earnest phoenix
#

uh, I think I destroyed my ws manager

quartz kindle
#

@earnest phoenix do you know basic javascript? javascript is user a lot together with html

earnest phoenix
#

No idk javaskript but imma look on google

queen needle
#

Thank

earnest phoenix
#

I only heard of it

#

well uh, i destroyed my websocket manager

quartz kindle
#

how did you accomplish that? lmao

earnest phoenix
#

constantly changing the already good code

#

in my mind it was like, yea this code is good, but lets make it better

quartz kindle
#

well, thats a good mindset for a programmer to have, it will help you learn faster

earnest phoenix
#

but to someone who has a better understand of javascript would think my thought process is yea this code is good, lets make it not work anymore : D

quartz kindle
#

yes but you learn by making mistakes

#

better be like that than using a lot of bad code just because "it works"

earnest phoenix
#

Error: MANAGER_DESTROYED

quartz kindle
#

but i still dont know how you destroyed it

#

did you call any .destroy() function?

earnest phoenix
#

gonna check all my code right away

#

none in my main file

#

Ok Javascript looks definezly easier

#

Thx @quartz kindle

digital ibex
#

py is way simpler

earnest phoenix
#

my token is invalid

digital ibex
#

my opinion at least

grizzled raven
#

ok so

earnest phoenix
grizzled raven
#

if i dont provide the guild presences in intents, will i still have access to guild members as normal?

split hazel
#

yes, you need presences if your bot relies on user's statuses

autumn quarry
#

How do I make a bot say something different at a different time of day? (Discord.js)

grizzled raven
#

no i mean

#

i dont care about presences

#

if i dont provide the guild presences in intents, meaning i dont recieve presence packets, will i still have access to guild members as normal?

earnest phoenix
#

Okay, I have this issue where whenever I play music using the play command everything works until I make the bot leave using the leave command which works but when after I run leave I try running play but it only sends the embed and not join vc and play music. leave.js: https://sourceb.in/bbbb69758f, play.js: https://srcb.in/88771e5df8.

#

are you using v12

#

or v11

#

yes

#

v12

split hazel
#

if i dont provide the guild presences in intents, meaning i dont recieve presence packets, will i still have access to guild members as normal?
@grizzled raven I said yes

grizzled raven
#

nah but you said if my bot relies on user statuses, which wasnt my question

#

my bot doesnt rely on them

earnest phoenix
#

you need to have the server members privileged intent if you want to be able to download all members of the guild

#

otherwise the only users you receive are the ones in GUILD_CREATE

harsh lotus
#

hello does anyone know how to make my bot ignore a channel?

earnest phoenix
#

compare the the message channel's id against the channel id you want to ignore

harsh lotus
#

Ok

queen needle
#

Does anyone know any good images or videos for discord.js to show me how to grab images from apis

summer torrent
#

use axios or node-fetch

queen needle
#

Videos or articles*

summer torrent
queen needle
#

Thsnkvyou

earnest phoenix
#

better ^ ( has bad typescript support )

amber fractal
#

or you can use the built in http/s package

pale vessel
#

ew

grizzled raven
#

yeah see thats what i initally though

#

t

#

but

#

this

#

TIP
GUILD_PRESENCES is required in order to receive the initial GuildMember data. If you do not supply it your member caches will be empty and not updates, even if you do provide GUILD_MEMBERS! Before you disable intents think about what your bot does and how not receiving the listed events might prevent it from doing this. Version 12 of discord.js does not yet fully support any combination of intents without loosing seemingly unrelated data.

#

that was just something to make me confused xdd

#

actually wait that wasnt really answered

#

if i dont subscribe to the guild presences intent, will i still have access to guild members as normal?

earnest phoenix
#

well uhh, my prefix command won't execute and of my commands, but I can change my prefix. here's my code: ```const Discord = require('discord.js');
const Keyv = require('keyv');
const prefixes = new Keyv('im dumb don't mind this, you saw nothing');
const config = require('../config');
const globalPrefix = config.globalPrefix;
module.exports = {
name: 'prefix',
description: 'changes server-wide prefix',
execute: async (message, args) => {
const member = message.member;
if (!message.member.hasPermission('MANAGE_GUILD')) {

        return message.channel.send("You can't use this command, You don't have the permission :sc1:")
    }
    if (args.length) {
        await prefixes.set(message.guild.id, args[0]);
        return message.channel.send(`Prefix Is Now \`${args[0]}\` :sc3:`);
    }

    return message.channel.send(`Prefix is \`${await prefixes.get(message.guild.id) || globalPrefix}\``);
}

}```

harsh lotus
#

Could someone give me an example of how to make my bot delete a message with a message inside it without being at the beginning or end?

prime cliff
#

Erm are you suppose to be leaking your mongo key and url stuff... @earnest phoenix

earnest phoenix
#

uuh

#

no

pale vessel
#

nice

earnest phoenix
#

you saw nothing

#

please don't store anything in db

pale vessel
#

better change the credentials

earnest phoenix
#

how I do dat

west spoke
earnest phoenix
#

lol

#

I figured it out

#

now just gotta get my key and leak it again

west spoke
#

mhm

earnest phoenix
#

le free

regal saddle
#

Heroku? Thonk

earnest phoenix
#

yes

#
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    bot.commands.set(command.name, command);
}
bot.on('debug', console.log);
bot.once('ready', () => {
    console.log('Bot Started With No Errors');
    bot.user.setPresence({
        activity: {
            name: 'Crying Without Knowing Why | chelp to Start'
        },
        status: 'idle'
    })

}) 

    bot.on('message', async message => {
        if (message.author.bot) return;
        
        const args = message.content.slice(globalPrefix.length).split(/\+/);
        const commandName = args.shift().toLowerCase();
        
        const command = bot.commands.get(commandName) ||
            bot.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));


        if (message.content.startsWith(globalPrefix)) {
            prefix = globalPrefix;
        } else {
            
       
            const guildPrefix = await prefixes.get(message.guild.id);
            if (message.content.startsWith(guildPrefix)) prefix = guildPrefix;
            
        }
        try {
            command.execute(message, args);
        } catch (error) {
            console.error(error);
            message.channel.send('there was an error trying to execute that command!');
            if (typeof execute !== 'undefined') {}
            if (!message.content.startsWith(guildPrefix)) return;
        }
    })


bot.login(token);```'
#

my custom prefix command

#
    at Client.<anonymous> (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\bot.js:48:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)   ```
west spoke
#

herOMEGALULku

#

command isn't defined

earnest phoenix
#

only thing I really like about heroku is that it updates with yout github commits

west spoke
#

can yous read

#

so does literally any vps

#

smh

grizzled raven
#

if i fetch

#

if i fetch a message with message.fetch(), does the message automatically update or do i redefine it?

#
async (message) => {
  if (message.partial) await message.fetch()
// or...
  if (message.partial) message = await message.fetch()
}
sick cloud
#

try the first

grizzled raven
#

is that like a try it and see or are you certain

#

cause like

#

actually well they could just patch

#

yeah nvm

sick cloud
#

i'm not sure generally lol

amber fractal
sick cloud
#

each lib does it diff

amber fractal
#

looks like the second one (in d.js anyways)

grizzled raven
#

but like there is a patch function which updates the message with new data

#

soo

sick cloud
#

message = await fetch sounds like the right way

grizzled raven
#

it does

#

although first way looks cooler lmao

#

i'll just be safe

#

and go with the second one

earnest phoenix
#

want to be extra cool? make a global function called f that returns the result of fetch

grizzled raven
#

no thanks

#

wait

#

also no offence cry, dont cry mmLol

#

well i wouldnt do r.users.cache = await r.users.fetch(), would i lmao

#

but eh

#

speaking of, if i fetch a reaction, what gets fetched with it? like do i fetch the message seperatly too and the

#

the

#

nevermind

earnest phoenix
#

discord doesn't return the message object when fetching the reaction

#

don't know how d.js handles it

grizzled raven
#

nah im stupid, yeah i fetch the message seperatly

#

im actually leaning towards thinking we dont need to reassign when fetching

#

let me dig deep

queen needle
#

Is. There anyway I could send a message to a user like ^send @userrr hi and it send a DM to that person that was mentioned

earnest phoenix
#

the mention won't do anything if you're already sending the dm by the way

#

anyways

#

what's your lib

queen needle
#

Discord.js

#

Well I would want to send the DM to the mentioned person

#

In case I need to

earnest phoenix
#

keep in mind that this method will fail if the user either
a) doesn't share a guild with your bot
b) has dms disabled

queen needle
#

Well I would implement a method that checks if their DMS are open of not say they aren't right?

earnest phoenix
#

you can't check that but sending them a message

queen needle
#

Oh

grizzled raven
#

would there be a point where fetching a reaction fails?

earnest phoenix
#

it's been removed

grizzled raven
#

yeah ik but

#

let me rephrase that

earnest phoenix
#

it's been removed, the message has been removed or the bot lost perms to read message history iirc

grizzled raven
#

ok if you fetch a reaction in the reaction remove event, its not fully removed until the last person removes the reaction, right?

earnest phoenix
#

correct

grizzled raven
#

so fetching the reaction always works, until the last person removes the reaction

earnest phoenix
#

should, yeah

#

or the other cases i mentioned above

grizzled raven
#

meaning that there is always a slight chance that fetching the reaction isnt possible lmao

#

guess i should jst

#

yeah i'll just ignore it

earnest phoenix
#

there's also times when discord is having a stroke and the fetch will spit out a 500

grizzled raven
#

wait i should actually log the error code instead of the path

#

or both but eh

#

one time i decided to log the ratelimits like any other error

#

yeah bad idea

earnest phoenix
#

i only log ratelimits when i cross a global one e.g IDENTIFY payloads

grizzled raven
#

if something is partial, in the d.js docs will the properties that dont return a ?<thing> always be there?

earnest phoenix
#

yes

grizzled raven
#

say author is ?Author but deleted seems certain

#

okay

earnest phoenix
#

? means nullable

grizzled raven
#

yeah ik just wanted to make sure

earnest phoenix
#

so how would I make my bot not ignore my custom prefix but ignore literally every other message

#

because my bot got muted for not not ignoring every message

#

check if the message content starts with your prefix

#

if (!message.content.startsWith(globalPrefix, guildPrefix, prefixes)) return;
^ thats the command I use to ignore everything thats not my prefix

amber fractal
#

that's not how startsWith works

earnest phoenix
#

well it seems to work, how would u suggest I start it

amber fractal
#

read the docs I sent you'll see your problem with your parameters

grizzled raven
#

wait if a message is partial then wouldnt the deleted property always be false

prime cliff
#

@earnest phoenix pro tip whatever lang you use make sure the startswith is not case sensitive because some mobile users have the first letter being uppercase so if someone wanted a custom prefix for pls and Pls to match

earnest phoenix
#

wait if a message is partial then wouldnt the deleted property always be false
@grizzled raven uh...no?

grizzled raven
#

nah i mean

#

because deleted is a property set by discord.js when creating the message

#

eh whatever tbh

#

xd

earnest phoenix
#

oh i misread that

#

i thought you said reaction for whatever reason

#

also no

#

partial entities are entities which aren't in the cache and discord doesn't provide all data for it in events

obtuse wind
#

question: is there a way for guild#invites to for each invite and log it to console

earnest phoenix
#

filter by what

obtuse wind
#

sorry I meant get the guild invites by forEach then log it to consoles

earnest phoenix
#

but filter by what

obtuse wind
#

no i meant get the guld invites by using forEach not filter omg my brain is dead af

earnest phoenix
#

oh

#

lol

#

of course

obtuse wind
#

im dumb lmao

earnest phoenix
obtuse wind
#

what I'm trying to ask is will the forEach function work on invites

earnest phoenix
#

use each on a collection

obtuse wind
#

ight ill do that thx

#

Okay another question: is there a way to map an invite link?

grizzled raven
#

wait what they changed it?

#

collection.each used to be collection.tap

#

oh well

obtuse wind
#

I'm still on v11 so i think its each still

grizzled raven
#

how often does the debug event get fired?

earnest phoenix
#

show code

sudden geyser
#

you showed the error but you didn't show the snippet one line above the screenshot.

earnest phoenix
sudden geyser
#

Check all your command files and make sure there's a help object export.

earnest phoenix
#

^

#

so in my commands folder, go through 120 commands and make sure there is help

sudden geyser
#

if you don't want to do it manually

#

just log the command name while running your command loader

#

then the last one it displays is likely the one you're missing

earnest phoenix
grizzled raven
#

thats the same thing

earnest phoenix
#

@sudden geyser and that would be,,?

sudden geyser
#

what do you mean

earnest phoenix
#

im clueless on how to fix

sudden geyser
#

You debug it. If you don't want to check each file one by one or using some sort of search regex, you can instead log the name of the command in your command loader. The last command name displayed that then triggers the error is likely the file that's missing a help export.

earnest phoenix
#

im not sure how to debug the whole folder

#

@sudden geyser

sudden geyser
#

as in a console.log in your code. the basics

earnest phoenix
#

how would I make my bot ignore everything execept my globalPrefix and custom prefix, here's my main file code:

    bot.on('message', async message => {
        if (message.author.bot) return;
        
        const args = message.content.slice(globalPrefix.length).split(/\s+/);
        const commandName = args.shift().toLowerCase();

        const command = bot.commands.get(commandName) ||
            bot.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));


        if (message.content.startsWith(globalPrefix)) {
            prefix = globalPrefix;
        } else {

            const guildPrefix = await prefixes.get(message.guild.id);
            if (message.content.startsWith(guildPrefix)) prefix = guildPrefix;
          
            if (!message.content.startsWith(globalPrefix, prefix)) return;
        }
        try {
            command.execute(message, args);
        } catch (error) {
            console.error(error);
            message.channel.send('there was an error trying to execute that command!');
            if (typeof execute !== 'undefined') {}
        }
    })```
#

and here's the custom prefix code:

        const member = message.member;
        if (!message.member.hasPermission('MANAGE_GUILD')) {

            return message.channel.send("You can't use this command, You don't have the permission :sc1:")
        }
        if (args.length) {
            await prefixes.set(message.guild.id, args[0]);
            return message.channel.send(`Prefix Is Now \`${args[0]}\` :sc3:`);
        }

        return message.channel.send(`Prefix is \`${await prefixes.get(message.guild.id) || globalPrefix}\``);
    }
}```
outer niche
#

Does anybody know the embed color code for twitch

marble juniper
#

#6441a5

outer niche
#

That's hex not in embed

earnest phoenix
#

what

outer niche
#

There's a difference between a hex and an embed color code

earnest phoenix
#

ok and

fleet chasm
#

i mean you can still use hex

restive furnace
#

0x6441a5

#

just replace # with 0x...

earnest phoenix
#

you're aware hex is just a number system

#

right?

outer niche
#

Embed color codes only have numbers though

restive furnace
#

well u can convert them into "embed color codes" by replacing # with 0x.

sick cloud
#

afaik this should be the right order to allow dynamic routing on express, right?

#

ones with more params being higher

summer torrent
#

is there any way to find similar versions of string?

earnest phoenix
#

look up the levenshtein distance algorithm

surreal notch
#

If I type anything this comes

earnest phoenix
#

@surreal notch you have to make the bot only listen for its prefix

#

something like if (!message.content.startsWith('yourprefix', 0)) return;

#

with 'yourprefix' being your prefix

#

as in ! . > or whatever you used

#

@surreal notch

surreal notch
#

No

earnest phoenix
#

what's your prefix

surreal notch
#
const Discord = require("discord.js");
const client = new Discord.Client();
const prefix = "p!";

//LOGIN
client.login("Token");

client.on("message", message => {
  //RETURN IF USER IS A BOT
  if (message.author.bot) return;

if (talkedRecently.has(message.author.id)) {
            message.channel.send("__**You can use this command one time in 6 Hours**__");

    } else {
 message.channel.send(embed)
           // the user can type the command ... your command code goes here :)
if(message.content.toLowerCase() === `${prefix}credits`) {
    var numbers = ["You have recieved 5 credits for Pokecord Bot\n\nYour reddem code is ||NwEf||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 10 credits for Pokecord Bot\n\nYour reddem code is  ||FtwK||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this",  "Better Luck Next time", "Better Luck Next time","Better Luck Next time","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is  ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is  TraW\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is  ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this"
    ];
    var answer = numbers[Math.floor(Math.random()*numbers.length)];
    var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Pokecord Credits**").setDescription(answer)
    message.channel.send(embed)
        // Adds the user to the set so that they can't talk for a minute
        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after 6 hours
          talkedRecently.delete(message.author.id);
        },     21600000);
    }
    }
})
#

See

earnest phoenix
#

so you see const prefix

surreal notch
#

Yes

earnest phoenix
#

you would make that take that and add it to the if statement I sent you

surreal notch
#

But it is already written

#

See codes

earnest phoenix
#

where 'yourprefix' is but without the quotes

surreal notch
#

??

earnest phoenix
#

like this if (!message.content.startsWith(prefix, 0)) return;

surreal notch
#

@earnest phoenix

earnest phoenix
#

ya?

green vale
#

Lib: DJS

How can I check if a message was edited?

earnest phoenix
#

@surreal notch add this to your code

#

if (!message.content.startsWith(prefix, 0)) return;

surreal notch
#

Where

#

??

earnest phoenix
#

near the top

#

after bot.on('message', message

surreal notch
#

@earnest phoenixyeah

#

Fixed

#

Thankuuu

earnest phoenix
#

yw

green vale
#

How can I check if a message was edited?

#

There's editedAt, editedTimestamp, and edits, but there's no edited property--this is in DJS

surreal notch
#

@earnest phoenixlisten

earnest phoenix
#

?

surreal notch
#

I want like that I can use that anytime time but others have cooldown

#

I have done cooldown for everyone

#

Now I have to wait 6 hrs

earnest phoenix
#

so basically you'd want to have permissions and permissionOverrides

surreal notch
#

Yes

#

Maybe

green vale
#

?? uhh

earnest phoenix
#

oh uh danny what do you mean by check if a message was edited

green vale
#

Like I want to check if the message passed* in the event was edited--I use a command handler and I'm implementing this on the command level just for extra info so

surreal notch
#

@earnest phoenixwill it work?

green vale
#

Add quotes to that

#

"my id"