#development

1 messages · Page 874 of 1

golden condor
#

Now it doesn't log anything

finite bough
#

wait

golden condor
#

Yesit does

#

Nvm

finite bough
#

i would suggest using a different method

golden condor
#

like?

#

I just used the sample code they gave

finite bough
#
const mongoose = require("mongoose");

mongoose
  .connect(
    `uri`,
    {
      useNewUrlParser: true,
      useUnifiedTopology: true
    }
  )
  .then(() => console.log("MongoDB Connected..."))
  .catch(err => console.log(err));
golden condor
#

Should I use mongoose instead?

finite bough
#

yes

quasi forge
golden condor
#

ok

quasi forge
#

@finite bough I wouldn't recommend an orm TBH.

golden condor
#

is mongoose better?

finite bough
#

@quasi forge i tried that

#

for me that works better

summer torrent
#

mongoose is a MongoDB object modeling tool

golden condor
#

ok

finite bough
#

mhm

golden condor
#

So

#

Should I use mongodb or mongoose

quasi forge
#

@golden condor orms always result in loss of performance, although it's pretty low for some orms like sequelize, for mongoose, the loss is pretty high.

summer torrent
#

doesn't matter

finite bough
#

^

golden condor
#

i am tryna use this tutorial

summer torrent
#

mongoose is easy-to-learn

quasi forge
#

@golden condor it is always a matter of personal choice and what you want to do.

golden condor
#

from w3schools

quasi forge
#

DON'T

golden condor
#

Why

quasi forge
#

Please don't use w3schools lol

finite bough
#

why did u go from mongoose official guide to w3school

#

LOL

golden condor
#

why?

quasi forge
#

Just a recommendation, don't use w3schools cuz it's all mostly outdated

golden condor
#

Should I use this instead

quasi forge
#

Yes

finite bough
#

yes

quasi forge
#

The official documentation

summer torrent
golden condor
#

ok

summer torrent
#

some examples

golden condor
#

mongoose or mongodb ??

summer torrent
#

doesn't matter
@summer torrent

golden condor
#

ok

finite bough
#

xd

golden condor
#

Are they the same?

summer torrent
#

no

finite bough
#

no

quasi forge
#

Not quite

golden condor
#

in a practical sense

finite bough
#

they some some differences

quasi forge
#

No

golden condor
#

o

summer torrent
#

mongoose is a object modeling tool for mongo

golden condor
#

what differs them?

finite bough
#

models

golden condor
#

Which is faster and which is easier?

summer torrent
#

data schemas+

finite bough
#

mongoose i think

quasi forge
#

Mongoose is easier, mongodb is faster

summer torrent
#

^

quasi forge
#

Although I would still recommend mongodb cuz it's still fairly easy

golden condor
#

Ok

finite bough
#

i remember getting a better lat with mongoose tho

golden condor
summer torrent
#

I am using mongoose. It is so easy

golden condor
#

They have some good tutorials

finite bough
#

same NM

quasi forge
#

I use both

golden condor
#

I am really confused on which to us

finite bough
#

actually i am using better-sqlite 3 and mongoose both

high bough
#

Someone tell me how this happened?

module.exports = {
  name: "eval", //command name
  async execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
    ///Command Starts Here
    function clean(text) {
      if (typeof text === "string")
        return text
          .replace(/`/g, "`" + String.fromCharCode(8203))
          .replace(/@/g, "@" + String.fromCharCode(8203));
      else return text;
    }
    if (message.author.id !== config.ownerID) message.channel.send(NL3Embed);
    else {
    try {
      const code = args.join(" ");
      let evaled = eval(args.join(" "));
      if (typeof evaled !== "string") evaled = require("util").inspect(evaled);
      const embed = new Discord.MessageEmbed()
      .setAuthor(`${message.author.username}`, `${message.author.avatarURL()}`)
      .setTitle("Eval")
      .setTimestamp()
      .setColor([173, 216, 230])
      .addField("**Input**",  '```' + args.join(" ") + '```')
      .addField("**Result**", '```' + clean(evaled) + '```')
      .setFooter(`${message.author.username} evaled`, `${message.author.avatarURL()}`);
      message.channel.send(embed);
    } catch (err) {
      message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
    }
  }
  }
};
```Someone show me what I missed?
golden condor
#

so what should I do

quasi forge
#

@golden condor it's your choice

golden condor
#

AAAAAAAAAAAAAAA

#

I don't know

#

which to pick

#

which one has more support

summer torrent
#

@high bough add return

golden condor
#

and which one is more used

high bough
#

i used else already

#

It works fine

quasi forge
#

Both have the same support, and mongoose uses mongodb

high bough
#

But just this guy uses it everyhting broke i think

#

@summer torrent

finite bough
#

a single entity cannot break stuff

golden condor
#

which would you recommend

finite bough
#

i use mongoose

#

easier

high bough
#

My Eval command blocks anything other than me, but for some reason, it broke?

summer torrent
finite bough
#

any errors?

high bough
#

But i used else, wouldn't that be the same as returning

#

?

golden condor
#

I am not asking what you use

#

I am asking which I should use

finite bough
#

yes kay but using return is a better practice

#

makes ur code more organized

quasi forge
#

For the usage statistics

finite bough
#

that shouldnt matter

quasi forge
#

They asked about it

finite bough
#

coz not everyone is making a discord bot

golden condor
#

ok

quasi forge
#

Yes, lol

finite bough
#

or are they ? xD

quasi forge
#

Who knows

golden condor
#

I am stuck now in what to use

green kestrel
#

not everyone is making <-- corrected it for you

#

1% creator, 99% consumer

quasi forge
#

@golden condor as I said, go through both of their docs, whichever one you like better, use it

finite bough
#

big brain

quasi forge
#

Yes

green kestrel
golden condor
#

ok

#

I am just really confused by how to use it

quasi forge
#

Which is why I say, go through both their documentation

#

Whichever one you can understand how to use, use it.

golden condor
#

mongoose seems easier

#

How do I connect to it

quasi forge
#

The documentation

modest maple
#

mongoose != the database itself

high bough
#
module.exports = {
  name: "eval", //command name
  async execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
    ///Command Starts Here
    function clean(text) {
      if (typeof text === "string")
        return text
          .replace(/`/g, "`" + String.fromCharCode(8203))
          .replace(/@/g, "@" + String.fromCharCode(8203));
      else return text;
    }
    if (message.author.id !== config.ownerID) return message.channel.send(NL3Embed);
    else {
    try {
      const code = args.join(" ");
      let evaled = eval(args.join(" "));
      if (typeof evaled !== "string") evaled = require("util").inspect(evaled);
      const embed = new Discord.MessageEmbed()
      .setAuthor(`${message.author.username}`, `${message.author.avatarURL()}`)
      .setTitle("Eval")
      .setTimestamp()
      .setColor([173, 216, 230])
      .addField("**Input**",  '```' + args.join(" ") + '```')
      .addField("**Result**", '```' + clean(evaled) + '```')
      .setFooter(`${message.author.username} evaled`, `${message.author.avatarURL()}`);
      message.channel.send(embed);
    } catch (err) {
      message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
    }
  }
  }
};
```I will say goodbye to my bot
It's going to the trash soon enough
golden condor
#

The documentation
@quasi forge It comes out with errors

quasi forge
#

What are the errors?

modest maple
#

have you actually got a mongo server running...

golden condor
#

Yes

#

I connected to it before

#

with mongodb

#
(node:9470) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [corynth-shard-00-02-7lanh.gcp.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to corynth-shard-00-02-7lanh.gcp.mongodb.net:27017 closed```
modest maple
#

MongoNetworkError: failed to connect to server

quasi forge
#

^

finite bough
#

question

golden condor
quasi forge
#

I feel that's a invalid connection URI thing

finite bough
#

did u white list ur ip?

golden condor
#

I didn't think I needed to since it worked earlier

finite bough
#

ur bot's ip that is

quasi forge
#

You can also whitelist all IPs tho

finite bough
#

yea

quasi forge
#

That should be safe if you keep your credentials secure enough

golden condor
#

also

#

how much storage is there

finite bough
#

on atlas

#

around 500mb

golden condor
#

what

quasi forge
#

500 MB is free

summer torrent
#

512 MB

finite bough
#

on atlas tho

#

on localhost

#

its unlimited i think

summer torrent
#

use localhost

golden condor
#

I wanna do localhost

quasi forge
#

Not quite unlimited but whatever your device storage is lol.

golden condor
#

How do I set it up on linux

#

I've got like 35GB on mibe

summer torrent
#

mongodb://localhost:27017

#

local host uri

golden condor
#

Do I have to set it up?

quasi forge
#

Just go to the mongodb website to see how to install and set up a local server

finite bough
#

^

quasi forge
#

It's pretty easy and well explained

summer torrent
#

Do I have to set it up?
@golden condor yes

golden condor
#

Right

#

I'll install the ubuntu package then thanks

spark solstice
#

뭐라고요?? ㅋ

#

ㅇㅅㅇ

golden condor
#

What

#

@summer torrent thx

#

I'm sorry I'm being a real pain

#

Is it the community edition I need?

finite bough
#

@🎗세월호 추모 (손재원)#6811 english please.

golden condor
#

left

#

lmao

finite bough
golden condor
#

@finite bough do I need community edition

finite bough
#

u need what

golden condor
#

of the mongodb localhost driver

summer torrent
#

yes

golden condor
#

ok

finite bough
#

never tried local host so dunno

quasi forge
#

Community = free
Enterprise = paid

tight plinth
#

I use eris 0.11.2

golden condor
#

Mongoose works

finite bough
#

:>

golden condor
#

But is it

#

mongoose.on('connection') ?

finite bough
#

.connect

nocturne grove
#

What is the best way to ignore the channelUpdate event if the update is made by the client user?
Should I work with audit logs or can I change something in the discord.js modules?

golden condor
#
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var MyModel = mongoose.model('Test', new mongoose.Schema({ name: String }))
MyModel.findOne(function(error, result) { /* ... */ });
console.log(MyModel)
setTimeout(function() {
  mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);``` How do I use schemas?
finite bough
#

@nocturne grove fetching the executor from audit logs and checking

golden condor
#

I am using the test code in the docs

finite bough
#

uhhhhhhhhhhh

#

const anyname = mongoose.model("model name", Schema);

nocturne grove
#

@nocturne grove fetching the executor from audit logs and checking
@finite bough ok thanks

golden condor
#

const anyname = mongoose.model("model name", Schema);
@finite bough what about inserting data

finite bough
#
 anyname.findOne(
    {
      primarykey: primar_key_data
    }, (err, res) => {
      if (err) console.log(err);
res.name = args[1]

 res.save().catch(err => console.log(err))
golden condor
#
var guilds = mongoose.model('Test', new mongoose.Schema({ id: String, prefix: String }))
finite bough
#

thats how u make a schema

#

yes

golden condor
#

That is my guild schema

#

do i need the mongoose.model?

finite bough
#

this is how i do it

#

please ignore var

golden condor
#

what about finding the guild by it's id

#

or a user

finite bough
#

primary key

#

here guild is the primary key

#

so

anyname.findOne(
    {
      server: message.guild.id
    },
golden condor
#

so

#

id

#

how do I set the data

#

Like change the prefix

nocturne grove
#

does anyone know why Discord website says If they (a member) have a nickname there will also be a be a ! after the @. if it's not true? My bot has no nickname (in all guilds) and a mention still shows a !.

finite bough
#

when u are logging a mention

nocturne grove
#

even if I manually type <@id> console.log(message.content) gives a !

finite bough
#

u get get something like

#

<@!id>

#

try it

#

console log a mention

nocturne grove
#

yes I know

#

but they say: If they (a member) have a nickname there will also be a be a ! after the @.
So that means if they have no nickname, you won't have an !. But I still have a ! in the mention.

finite bough
#

@golden condor

res.prefix = ugai
res.save().catch(err => console.log(err))
golden condor
#

how do I change the data that has already been put in

finite bough
#

like that

golden condor
#

what is res in this scenario, the guild?

finite bough
#

can u send me the link menno

nocturne grove
#

sure

finite bough
nocturne grove
gentle arch
#

How many times approved bot??

#

my friend threw a request 2 hours ago and his bot is already in new

golden condor
#

@finite bough how do I do that function

#
Guilds.findOne({id: '661923253488713729'}, function(error, result) { console.log(result) });```
#

It returns null

finite bough
#

coz

#

u havent made a id yet

#

if(!result)

golden condor
#
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
var guild = new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: true, suggestionChan: "666736935947206686"})
Guilds.findOne({id: '661923253488713729'}, function(error, result) { console.log(result) });
console.log(guild.suggestions)
setTimeout(function() {
  mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);```
#

I tried this

#
Guilds.findOne({id: '661923253488713729'}, function(error, result) { if(!result) return new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: false, suggestionChan: null }) 
console.log(result) });```
#
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
var guild = new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: true, suggestionChan: "666736935947206686"})
Guilds.findOne({id: '661923253488713729'}, function(error, result) { if(!result) return new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: false, suggestionChan: null }) 
console.log(result) });
console.log(guild.suggestions)
setTimeout(function() {
  mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);``` This is my code @finite bough
finite bough
#

u love to make a mess out of js dont u

#

delete

golden condor
#

Ok

earnest phoenix
#

True

finite bough
#

thats not how u make a schema

golden condor
#
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
Guilds.findOne({id: '661923253488713729'}, function(error, result) { 
console.log(result) });
setTimeout(function() {
  mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);```
#

this is so confusing

earnest phoenix
#

Do not use vars they suck

finite bough
#

also

robust moth
golden condor
#

So just this

#
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
setTimeout(function() {
  mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);```
finite bough
#

now

earnest phoenix
#

@finite bough do you love javascript?

finite bough
earnest phoenix
#

Uhm sorry,

finite bough
#

its ok

summer acorn
#

@earnest phoenix code is personal preference. If you don't have something helpful/useful to say about the matter in here, please don't say anything.

finite bough
#

facts tho^

earnest phoenix
#

My bad.

modest maple
#

i mean not really,

earnest phoenix
#

Tho it's really useful tip

modest maple
#

Var is generally regarded as something you should not use in those regards

#

he wasnt being negative, he was just saying what is good practice todo

#

tho it might of been more helpful to follow up with saying what they could / should use instead he wasnt in the wrong for telling a user a possible issue in their code or warn the user for using a process that might not be in the user's best interest to use akkoShrug

tight plinth
finite bough
#

tried reinstalling ?

tight plinth
#

I tried

#

ffmpeg & ffmpeg-static

#

but nothing

finite bough
#

eris?

tight plinth
#

yes

#

wt

#

lul

#

idk whats the problem

finite bough
#

now u know why i never even touched eris xD

tight plinth
#

oof

restive night
#

I got this when running my bot FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memoryhow to fix this?

summer torrent
#

what is your ram size

restive night
#

@summer torrent 4GB. I use discord.js. Do you know how to optimize the use of RAM when you first run the bot? sorry for mention

flat pelican
#

Uhhhh.

#

It shouldn’t take 4GB for a new bot using d.js. Are you sure that nothing else is eatting ram?

earnest phoenix
#

when run your bot add --trace-warnings --max_old_space_size=4200 behind

#

like node bot.js --trace-warnings --max_old_space_size=4200

#

@restive night there might be memory leak issue

golden condor
#

Issues with mongo

#
const {queue} = require("../queue.js")
const Discord = require("discord.js")
const {ownerid} = require('../config.json')
const { Guilds } = require('../db/db.js')
const escapeRegex = function(str){ str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}
exports.run = async (client, message) => {
  if (message.author.bot) return;
  if (message.channel.type == "dm") return;
  if (!message.channel) return;
  const db = require('quick.db')
  let prefixx;
  Guilds.findOne({
      id: message.guild.id
      },
      async function (err, res) {
            if (err) console.log(err);
          
     if(!res){
prefixx = "c-"

               const newDoc = new Guilds({
                id: message.guild.id,
                prefix: "c-",
                suggestions: false,
                suggestionchan: null
              })
              newDoc.save().catch(err => console.log(err));
          } else if(!res.prefix) prefixx = "c-"
          else prefixx = res.prefix
   });
  let mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`);
  const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`);```
#

Says prefixx is undefined

nocturne grove
#

Is this a reliable way to check if my client updated a channel name?

client.on('channelUpdate', async (oldChannel, newChannel) => {
    const guild = oldChannel.guild;
    const auditLogs = await guild.fetchAuditLogs({ user: !guild.me.id, type: 'CHANNEL_UPDATE' });
    console.log(auditLogs.entries);
    const updatedByClient = auditLogs.entries.first().changes.some((change) => {
        return change.old == oldChannel.name && change.new == newChannel.name;
    });
    console.log(updatedByClient);
});```
I feel like something is missing with time
earnest phoenix
#

@golden condor at which line?

#

last?

golden condor
#

yes

earnest phoenix
#

try this

const Discord = require('discord.js')
const { queue } = require('../queue.js')
const { ownerid } = require('../config.json')
const { Guilds } = require('../db/db.js')

const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
exports.run = async (client, message) => {
    if (message.author.bot || message.channel.type === 'dm' || !message.channel) return
    // const db = require('quick.db') I don't know why it's here?!!
    let prefixx = 'c-'
    Guilds.findOne({ id: message.guild.id }, async (err, res) => {
        if (err) console.log(err)
        if (res && res.prefix) prefixx = res.prefix
        if (!res) {
            const newDoc = new Guilds({
                id: message.guild.id,
                prefix: 'c-',
                suggestions: false,
                suggestionchan: null,
            })
            newDoc.save().catch(err => console.log(err))
        }
    })
    const mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`)
    const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`)
}

nocturne grove
#

I changed my code a bit. Would this work for ignoring channel name updates by the client?

client.on('channelUpdate', async (oldChannel, newChannel) => {
    const guild = oldChannel.guild;
    const auditLogs = await guild.fetchAuditLogs({ user: guild.me.id, type: 'CHANNEL_UPDATE' });
    const updatedByClient = auditLogs.entries.first().changes.some((change) => {
        return change.old == oldChannel.name && change.new == newChannel.name && Date.now() - auditLogs.entries.first().createdTimestamp < 5000;
    });
    console.log(updatedByClient);
});```
plucky heart
#

I used this emoji \😄 and console shows (node:8825) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Emoji

coarse topaz
#

Hey @plucky heart! Try using a Discord one similar to the emoji you want to use 🙂

mossy vine
#

@plucky heart how are you using it

coarse topaz
#

😄 this one could help you

plucky heart
#

message.react(' \😄 ');

mossy vine
#

try removing the spaces

plucky heart
#

I deleted and still the same

coarse topaz
#

I think he only copied from google and pasted it in his code

#

Hey @plucky heart! Try using a Discord one similar to the emoji you want to use 🙂
bruh

mossy vine
#

message.react('😄');

#

oh whopos

#

thanks discord

#

ur bad

slender thistle
#

\😄

mossy vine
#

try that

coarse topaz
#

that's what i am referring to

#

Did you get it? ^^

worthy kindle
#

When someone whitelists you and you accept what does it do?

trim nexus
#

what whitelist are you referring to

worthy kindle
#

Like for a application or bot

quartz kindle
#

what specific whitelist are you refering to?

#

the term whitelisting in general means that someone is allowed to do something

#

to whitelist someone is to grant them permission to do something

worthy kindle
#

But how do I acces the bot?

#

That my fried whitelisted me in

quartz kindle
#

i dont know what you're talking about

#

you have to ask him

worthy kindle
#

What?

#

He whitelisted me on a application on discord i think and a accepted

still merlin
#

Is my code correct its been ages since I've made a bot and my code just doesn't look right

quartz kindle
#

on the discord developer page?

#

@still merlin what doesnt look right?

#

nothing wrong there

still merlin
#

Ok thanks

golden condor
#

so many errors with mongodb

worthy kindle
#

Yes on the discord developer page

still merlin
#

I kept getting errors so I re-wrote it and I was just unsure if my code was right

golden condor
#
0|index  | TypeError: Cannot read property 'replace' of undefined
0|index  |     at escapeRegex (/home/cxllm/Bots/Corynth/events/message.js:5:32)
0|index  |     at Object.exports.run (/home/cxllm/Bots/Corynth/events/message.js:28:62)
0|index  |     at Client.<anonymous> (/home/cxllm/Bots/Corynth/index.js:23:7)
0|index  |     at Client.emit (events.js:311:20)
0|index  |     at MessageCreateAction.handle (/home/cxllm/Bots/Corynth/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
0|index  |     at Object.module.exports [as MESSAGE_CREATE] (/home/cxllm/Bots/Corynth/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)```
#
const {queue} = require("../queue.js")
const Discord = require("discord.js")
const {ownerid} = require('../config.json')
const { Guilds } = require('../db/db.js')
const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
exports.run = async (client, message) => {
  if (message.author.bot) return;
  if (message.channel.type == "dm") return;
  if (!message.channel) return;
  const db = require('quick.db')
  let prefixx;
  Guilds.findOne({ id: message.guild.id }, async (err, res) => {
      if (err) console.log(err)
      console.log(res)
      if (res.prefixx) prefixx = `${res.prefix}`
      else if (!res) {
        prefixx = "c!"
          const newDoc = new Guilds({
              id: message.guild.id,
              prefix: 'c!',
              suggestions: false,
              suggestionchan: null,
          })
          newDoc.save().catch(err => console.log(err))
      }
      })
  let mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`);
  const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`);```
worthy kindle
#

@quartz kindle Yes on the discord developer page

quartz kindle
worthy kindle
#

Yes

quartz kindle
#

i dont know if that has any effect on bots, its primarily for games and other applications

golden condor
#
0|index  | {
0|index  |   _id: 5e983d9863b24e55b79d09d3,
0|index  |   id: '697838346256515082',
0|index  |   prefix: 'c-',
0|index  |   suggestions: false,
0|index  |   __v: 0
0|index  | }``` res logs as this
quartz kindle
#

but check in your own developer portal and see if you have access to anything you didnt before

worthy kindle
#

But how do i acces the application?

quartz kindle
#

it should appear in your developer portal

#

in the applications list

worthy kindle
#

i dont see it

quartz kindle
#

then idk

#

@golden condor Guilds.findOne is an async function

#

its results dont exist outside of its callback

golden condor
#

so

still merlin
#

Does my code

bot.login(token);

need to be at the end of my code or can it be anywhere

golden condor
#

await

quartz kindle
#

it uses callbacks, not promises

golden condor
#

the function?

quartz kindle
#

so you cant directly await it

golden condor
#

i am going nuts tryna solve how this works

quartz kindle
#

@still merlin it can be anywhere as long as its after bot and after token

#

@golden condor js code(dosomething, result => { // result exists here }) // result does not exist here

golden condor
#

what

#

Yeah

still merlin
#

Ok thank you so much!

golden condor
#

that's why I use

#

let prefix

#

if(res) prefix = res.prefix

earnest phoenix
#

how i can edit msg using id ?

quartz kindle
#

because async functions are executed in parallel, your code does not wait for it

golden condor
#

so what should I do

quartz kindle
#

you define let prefixx but the prefix is not defined in time, your code immediately tries to use it in prefixRegex without waiting for Guilds.findOne

golden condor
#

aaaahh

cinder patio
#

You can promisify it or put the rest of the code inside the callback

quartz kindle
#

^

golden condor
#

Makes sense

#

I will make the entire code inside the callback then

quartz kindle
#

yes that is the easier thing to do

golden condor
#

yes

#

That worked

#

Thx

#

❤️ you guys

regal saddle
#

Tim is always helpful change my mind pepeblanket

golden condor
#

he always is

obsidian sky
#

Guys how do i get dm's from a bot and then check if the user has sent dm's earlier if he hasn't then create a channel with his userid in Tickets category and then send his message that was sent in that new created channel... This code currently kind of works but the user has to send two messages, in the first message his channel is created and in the second one his channel is moved to the Tickets category and then his second message is sent there... i couldn't figure out a better way to do that.. can someone help me with that.... Thanks for reading my really long message btw...😅

Can someone help with this...

quartz kindle
#

instead of an if/else you just do an if with an async function

#

instead of this js bot.on("message", message => { if(!channel) { create channel } else { send } }) you do this ```js
bot.on("message", async message => {
if(!channel) {
await create channel
}
send
})

obsidian sky
#

but if there is no channel then how can i create channel and send his message in it at the same time?

quartz kindle
#

by using async await syntax

#

so your code properly waits for operations to finish before proceeding

obsidian sky
#

ohh, ok yes that would work... thanks...

earnest phoenix
#
printDate(pdate){
        
        let monthNames = [
            "Jan", "Feb", "Mar",
            "Apr", "May", "Jun", "Jul",
            "Aug", "Sep", "Oct",
            "Nov", "Dec"
        ];
        let weekNames = [
            "Sat", "Sun", "Mon",
            "Tue", "Wed", "Thu", "Fri"
        ];
    
      
        let day = pdate.getDate(),
        monthIndex = pdate.getMonth(),
        dayIndex = pdate.getDay()
        year = pdate.getFullYear(),
        hour = pdate.getHours(),
        minute = pdate.getMinutes();

        
        return weekNames[dayIndex]+','+monthNames[monthIndex]+" "+day+","+year+" "+hour+":"+minute;
    }

how do i get am or pm

#

i am using (ms) btw

quartz kindle
#

getHours() returns the hour in 24h format, not in 12h

#

there is no am/pm

slender thistle
#

if hours >= 12 pm
if hours < 12 am

obsidian sky
#

if hours < 12 am
otherwise hours-12 pm

quartz kindle
#

you can use locale functions to output the date in whatever region settings you machine is in and then extract from it, or do math like the answers above ^

earnest phoenix
#

ok thx

still merlin
#

I'm getting a error in my code.

bot.on('ready', {) } 
#

its unfinished code but I keep getting errors when I type it in

earnest phoenix
#

hello how i can delete message using id of the message in js

wide ridge
#

@still merlin bot.on(`ready`, () => { //code here });

still merlin
#

tysm

earnest phoenix
#

@wide ridge

bot.on('ready', () => { 
                //code here 
               });

#
Client.on('ready', () => {
console.log(`Client [${Client.user.username}] online!`)
});
```@still merlin
obsidian sky
#
  {
    console.log('Bot is now up and running');
  })```
earnest phoenix
#

how i can delete message using id of the message in js

wide ridge
#

@earnest phoenix try channel.fetchMessage(lastmsgID).then(msg => msg.delete());

#

or just google

earnest phoenix
#

okey

wide ridge
#

anyone else receiving a LOT of (node:3265) UnhandledPromiseRejectionWarning: AbortError: The user aborted a request. messages? Seems like discord is going wonky again

still merlin
#

I haven't received any as I just started a new bot

cerulean pebble
#

hmm

#

is it possible to get their server invite link ?=))

slender thistle
#

Don't

#

Joining servers randomly through your bot without any form of consent is against Discord ToS aka privacy breach

cerulean pebble
#

Don't
@slender thistle i know but i ask can it possible ?

slender thistle
#

It is

cerulean pebble
#

lol i never do that

#
  • will
#

anyone else receiving a LOT of (node:3265) UnhandledPromiseRejectionWarning: AbortError: The user aborted a request. messages? Seems like discord is going wonky again
@wide ridge not a big problem

lyric mountain
#

I have something similar, it's used in the request assist command

#

a good mod will not give manage_invites perm to any bot

#

except invite manager bots

slender thistle
#

"a good mod"

cerulean pebble
#

lol

slender thistle
#

not an average owner

lyric mountain
#

you know a server owner/admin is good when they actually read bot permissions before adding them

amber fractal
#

I don't add other's bots mmulu

#

I use my privates ones

cerulean pebble
#

lol

lyric mountain
#

well, if you say so...

still merlin
#

How do I make my bot have a mention as a prefix
Example: My bot is called Dime so when I tag Dime with the command he'll do it normally

I already have some code but it seems to not work (the numbers are his ID)

var PREFIX = "@late stream ";
quartz kindle
#

discord changed mentions to <@!number>

still merlin
earnest phoenix
#

I'm sure this is not the right way

still merlin
#

Oh ok thanks Tim

quartz kindle
#

the correct way is to check for both <@id> and <@!id>

#

because discord keeps changing those for no reason

slender thistle
#

Actually isn't it always !id now?

still merlin
#

I did @id and it worked as a test

slender thistle
#

Oh right they can change those anytime

quartz kindle
#

i think its all <@!> now but you never know

still merlin
#

ok

crimson vapor
#

<@ID> works as well

lyric mountain
#

but sometimes it becomes <@!ID>

slender thistle
#

it gets converted to <@!id>

crimson vapor
#

oh

still merlin
#

It works thanks!

pale vessel
#

on mobile it didn't convert, last time i tried

earnest phoenix
#

If I'm making discord bot what basic things I should include? Like logging every command. Health command. Stats command?

pale vessel
#

making a regex pattern is a good idea

#

<@!?id> something like that

#

@earnest phoenix anything you/people find useful

#

unlike covid bots

earnest phoenix
#

Like?

#

I'm not about bots core functionality, but extra functions bot must have.

#

Like ban users feature.

#

rate limiting

#

I'm making bot first time so I don't know what possible challenges I will face in future.

crimson vapor
#

the command to change the slow mode delay on a channel was fun

#

hard tho

#

just finding out where

#

its easy if you use the docs tbh

earnest phoenix
#

Leave implementation to me, just tell me features

crimson vapor
#

ok

lyric mountain
#

lol ratelimiting is not as easy as it looks

#

you gotta handle ratelimits per user

crimson vapor
#

or you can be lazy and do it by channel

earnest phoenix
#

I'm sure it shouldn't take more than 45 minutes.

lyric mountain
#

lol it'll take

#

in my case I used a timed cache, which removes entries based on their age

earnest phoenix
#

😆

crimson vapor
#

I didnt impliment mine yet

#

but I need to do it in a way where it says the time left

lyric mountain
#

another thing that's nice to have, but hard af to implement efficiently is antispam

earnest phoenix
#

antispam?

#

but I need to do it in a way where it says the time left
@crimson vapor You meant cool down?

crimson vapor
#

so you dont have users spam a channel with a command and you get ratelimited

lyric mountain
#

yeah, like, trigger a event when an user send N messages in a short time

earnest phoenix
#

I've made antispam

#

Both are easy

#

But only works when someone uses my bot

lyric mountain
#

no, it's not

crimson vapor
#

I meant channel slowmode

#

make your bot modular

lyric mountain
#

I've made two types of antispam: one that triggers on repeated messages and other that triggers on quick messages

earnest phoenix
#

depends

still merlin
#

I'm getting a issue with my bot.
I typed out a command

bot.on("message", (message) => {
  let args = message.content.substring(PREFIX.length).split(" ");

  switch (args[0]) {
    case "ping":
      message.channel.sendMsg("pong!");
      break;
  }
});

and for some reason my bot still decides to do this:

earnest phoenix
#

I don't like to implement such a feature until it's really necessary.

lyric mountain
#

it'll never be necessary

crimson vapor
#

no

#

make features before you need them

lyric mountain
#

it's just a moderation tool

#

noone will need it until you add it

earnest phoenix
#

That's also true. I'm not lazy but I don't like to make overhead.

lyric mountain
#

then you'll not make doggowave

earnest phoenix
#

@still merlin im pretty sure sendMsg isn't a thing (or its deprecated), and the content doesn't match the argument you passed in meaning you have another handler somewhere

#

i hope you restarted your bot when you made changes

#

lol

lyric mountain
#

in bot development there's no "overhead", you can develop any feature at any time

#

that's called "new feature"

earnest phoenix
#

Where're you from bro?

crimson vapor
#

make your bot framework into a different folder so all you are doing is creating a new bot and adding commands to it

#

once I am bored enough, I will be moving everything to a folder like that

lyric mountain
#

Where're you from bro?
not relevant rlly now

earnest phoenix
#

My bad.

lyric mountain
#

don't worry

still merlin
#

@earnest phoenix I don't know exactly what that means im bad a coding

earnest phoenix
#

How about bot which provides temporary email service?

#

fun

lyric mountain
#

how would that work?

earnest phoenix
#

Sorry I didn't get it

lyric mountain
#

what would be the use-case of that email system?

earnest phoenix
#

ever heard of 10minutemail?

#

Like let say you want to create 100s of accounts

crimson vapor
#

against tos

earnest phoenix
#

Not discord

lyric mountain
#

friggin ninjas

earnest phoenix
#

let say you want to create account on some website but don't want to give your main email

lyric mountain
#

automatically creating any kind of account is against pretty much ANY tos

earnest phoenix
#

so many things people do here are against the tos but discord's t&s team sucks so much they don't care even about actual issues

#

Automatically?

heavy marsh
#

OK I have got a question?
I am trying to make a command for example <Prefix>syc-roles on discord.js v11.4.2

I want the user to get the roles that he/she has on the main server and give the same roles on the staff server.

How can this be done?

earnest phoenix
#

no one said anything about account creation lol

prime cliff
#

Yea why would you want to create them automatically that's bad no matter what way you put it

earnest phoenix
#

just providing temporary emails like 10minutemail, but in discord

lyric mountain
#

let say you want to create account on some website but don't want to give your main email
@earnest phoenix seems pretty much account creation to me

earnest phoenix
#

it isn't though

#

all you need is an SMTP server and you're good to go

#

Let say I want to download something from x website but they requires account on their website

#

physically no account creation is happening

lyric mountain
#

ah, that

earnest phoenix
#

I have already created that bot

lyric mountain
#

actually, that's a dope idea for a bot

earnest phoenix
#

There nothing near in this discord bot community. It's unique

#

But my main focus in on providing api

#

You might not like me but there're many scrappers for them this will be heaven.

modest maple
#

nah i'll webscrape anything i need if there isnt an api for it

#

lol

earnest phoenix
#

Dude you're OP

lyric mountain
#

"if you don't want to make an api for your website at least put ids in your tags"
---------- first rule of bro devs

modest maple
#

nah

#

id's r alright

earnest phoenix
#

@earnest phoenix would you mind if I add you?

heavy marsh
#

bro or pro

lyric mountain
#

bro

heavy marsh
#

ahh

lyric mountain
#

not all pro devs are bros

modest maple
#

but you can always go through any amount of html and get the thing you want at some point

earnest phoenix
#

@modest maple you got me wrong.

heavy marsh
#

So any one has an idea for me?

lyric mountain
#

yeah, but with ids it's a lot easier

earnest phoenix
#

I'm talking about temporary mail api.

#

Or websocket. On which you can subscribe and I can broadcast new emails.

modest maple
#

if its a temp email surley broadcasting to them is irrelevant

#

because they're getting destroyed anyway

earnest phoenix
#

@heavy marsh use map() on https://discord.js.org/#/docs/main/11.4.2/class/GuildMember?scrollTo=roles in guild A to map the collection to roles in guild B. something like map(r => guildB.roles.find(x => x.name === r.name))

you'll then have a collection of the roles in guild B and you can simply use https://discord.js.org/#/docs/main/11.4.2/class/GuildMember?scrollTo=addRoles and pass the mapped collection

lyric mountain
#

guess I'll buy a domain and make something similar, if you don't mind

#

it's a really dope idea

earnest phoenix
#

Sure thing go ahead.

lyric mountain
#

at least for my devs

earnest phoenix
#

Or we can do it together.

lyric mountain
#

I work with java

#

guess it'd be different lol

modest maple
#

just makes my life harder when dealing with spam bots sad

earnest phoenix
#

Bwahaha

#

@lyric mountain do you work?

lyric mountain
#

yes, but not with java

earnest phoenix
#

Just joined server today and it's amazing to meet new peoples really interested in coding.

lyric mountain
#

what I mean is that I programmed my bot in java

#

what? java is cool

#

styles

modest maple
lyric mountain
#

not style

#

Why is this not working?

#

ah, it's style

#

anyway

#

where's this tag located?

#

depending on where you placed it it might work or not

pale vessel
#

bot-img is an id

lyric mountain
#

put in the end of your long desc

pale vessel
#

so #bot-img

#

. is for classes

#

@earnest phoenix

#

what do you mean?

lyric mountain
#

Why is this not working?
again, if it doesn't work then it's not right

pale vessel
#

you put .bot-img

#

it's #bot-img

lyric mountain
#

yes

pale vessel
#

please kill me sorry

lyric mountain
#

remove the dot

pale vessel
#

maybe it's a typo

#

dw

#

dw

#

there

#

well

earnest phoenix
#

Hello. I think a function in my code is outdated (not up to date with version 12, which is what I’m using) and it isn’t picking it up because of that. Could anyone help me?

pale vessel
#

maybe. send what you're having problems with

earnest phoenix
#

Yeah, I was waiting for someone to respond until I sent an image because I didn’t want to clutter the chat

#

Is the image quality okay?

obsidian sky
#

@quartz kindle Thanks, this worked

bot.on('message',async message=>
{
  if(message.channel.type!=='text') 
      {
          if(message.content.startsWith(config.prefix)) return;
          supportchannelname=message.author.id;
          foundchannel=bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname);
          if(foundchannel===undefined)
          {
            await bot.channels.cache.get(config.defaultlog).send(`Created new ticket channel for ${message.author.tag}`);
            await bot.guilds.cache.get(config.serverid).channels.create(supportchannelname, { topic: 'Ticket channel for'+message.author.tag});
            bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).setParent('700024079348007029');
            bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).send(`${message.author.tag} : ${message.content}`);
          }
          else
          {
            bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).setParent('700024079348007029')
            bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).send(`${message.author.tag} : ${message.content}`);
          }
          
      }
})
earnest phoenix
#

don't send images of your code because its unreadable

pale vessel
#

i see it already

obsidian sky
#

just send a screenshot or upload it somewhere

golden condor
#

does mongodb work in the same way as mongoose?

earnest phoenix
#

I’ll try and copy and paste it rn

golden condor
#

Will mongoose code work with mongodb

amber fractal
#

There are slight differences

earnest phoenix
#

I just sent the image so I could get the terminal error in there

cinder patio
earnest phoenix
#

case 'mute':
var person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]));
if (!person) return message.reply("I CANT FIND THE USER " + person)

        let mainrole = message.guild.roles.find(role => role.name === "New Member");
        let role = message.guild.roles.find(role => role.name === "Muted");
#

i think the error is in the bottom two lines

pale vessel
#

shhh

#

read that article

earnest phoenix
#

I’m reading it rn

#

Thank you. I’ll keep that article bookmarked so if I run into an issue like this again I’ll be able to fix it on my own

golden condor
#

Mongoose is really laggy please help

amber fractal
#

you can use html in the long description

earnest phoenix
#

tldr use the <style> tag to override css on the existing page

#

you can find what to override by digging through the website html via inspect element

shadow spruce
#

who can help me for C# api

earnest phoenix
#

what where when

#

we need context with your question

restive furnace
golden condor
#
let mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`);
  const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`);
  if (!prefixRegex.test(message.content)) return;
  const [, prefix] = message.content.match(prefixRegex);
  if (!message.content.startsWith(prefix)) return;
  let args = message.content.slice(prefix.length).trim().split(/ +/);
  let cmd = args.shift().toLowerCase();
  let command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));``` Not sure why I can do c!          help and it still works with this code
#
if (command) {
    if(command.category === "Owner" && message.author.id != ownerid) return;
    command.run(client, message, args, queue).then( () => {
      const Embed = new Discord.MessageEmbed()
      .setTitle("Command Run")
      .setDescription(`The command **${command.category}/${command.name}** was run by **${message.author.username}** in **${message.guild.name}**`)
      .setColor(0x00aaff)
      const cnl = client.channels.cache.get("697061184708280350")
    cnl.send(Embed)}).catch(e => {
      message.channel.send("Unfortunately, there was an error executing that command and I will inform the developer so he can fix it.")
   client.users.cache.get(ownerid).send(`There has been an error executing ${command.name}\n\`\`\`js\n${e}\`\`\``)
      })
    } else return;``` the next part
gritty bolt
#

does anyone know how to get the content of a message collected by a messageCollecter in discord.js?

amber fractal
#

@golden condor you check if the start of the message is the prefix (which it is) then you slice the prefix length, so you're left with help then you trim which turns it into help then you split which makes it [help]

golden condor
#

oh

#

then i should get rid of .trim()

amber fractal
#

Yes, but you can still remove whitespace from the end if you want with trimEnd()

golden condor
#

whitespace?

gritty bolt
#

does anyone know how to get the content of a message collected by a messageCollecter in discord.js?
@gritty bolt
to add onto my question above, I have collector.on('collect', m => { and I'm trying to get the content by doing m.content

golden condor
#

Say if I wanted the prefix as pp but also wanted but also wanted it to respond to pp @amber fractal how would I do that

amber fractal
#

you'd have to check for a single space, whereas trim simply gets rid of all whitespace (spaces, blank characters, etc)

earnest phoenix
#

I am not sure if this is completely development related, but has anyone got recommendations for hosing a python bot for free?

gritty bolt
#

AWS EC2 first year is good

earnest phoenix
#

I don’t think glitch supports python

slender thistle
#

Glitch is node.js

golden condor
#

you could, and this is a big could, use repl.it

earnest phoenix
#

Currently I am using google but I will have to keep the bot down 10 hours a month to keep it free

gritty bolt
#

how many hours does google give you for free?

golden condor
#

@earnest phoenix you mean google cloud?

earnest phoenix
#

Yes

golden condor
#

What are the specs, do you know?

#

You can use heroku, if you put in your card details (without paying) you get 1000 hours a month which is enough to cover the entire monht

balmy knoll
#

Hi, in discord.js, how can i add a cooldown to a command?

earnest phoenix
#

By making a new set and adding the user's id into it and deleting the user's id from the set after the amount of time you want @balmy knoll

sudden geyser
#

There are several ways you could do it:

  • Use an array/set/single-item type of list for how long the cooldown is supposed to be. Remove the user after the time period has passed (e.g. 3 seconds). If the user is still in the cooldown when they run the command, deny them permission with an optional message saying they're being rate limited.

  • Use a map/collection and do the same thing. For example:

let ratelimit = 3; // 3 seconds
let blocked = new Set();

onCommand(() => { // Let's imagine this is run when the command is run.
  blocked.add(userID);
  setTimeout(() => blocked.delete(userID), time);
})

// Figure out how to check the user for if they're currently ratelimited.```
earnest phoenix
sudden geyser
#

Not really spoonfeeding. It's an example.

balmy knoll
#

@earnest phoenix @sudden geyser Thanks

earnest phoenix
#

Np

#

@golden condor You get 720 hours per month for a 1 shared cpu and 600mb of ram

golden condor
#

@earnest phoenix try heroku like I said

#

You can use heroku, if you put in your card details (without paying) you get 1000 hours a month which is enough to cover the entire monht

#

@earnest phoenix ^

earnest phoenix
#

Ok, I will. Thanks for the help

obsidian sky
#

anyone knows how to send dm's via bot with numeric userid in discord.js

#

Is that even possible?

modest maple
#

yes

#

get user

#

from id

#

send user

#

💥

earnest phoenix
#

But then how will I keep my bot going to sleep using python?

#

Give him some coffee, kidding. AFAIK I don't think bot will go to sleep.

#
if(collected.first().content == randomnumber) return message.channel.send(yesembed).then(coins.add(`${message.guild.id}.${message.author.id}`, parseInt(betdouble)))```
#

Why is this not working?

#

Btw betdouble = bet*2
and bet is args[0]

lyric mountain
#

context please

earnest phoenix
#

its supposed to add coins

lyric mountain
#

what's collected? what about the yesembed?

placid vault
#

how i can check if member is not member.bot:

lyric mountain
#

show the whole code block

placid vault
#

me?

lyric mountain
#

how i can check if member is not member.bot:
@placid vault member.isbot I guess?

earnest phoenix
#

@lyric mountain

#
const filter = m => m.author.id === message.author.id
  message.channel.send(noguess)
  message.channel.awaitMessages(filter, {
     maxMatches: 1,
     time: 10000 }).then(collected => {  ```
#

this is the filter

#
if(collected.first().content == randomnumber) return message.channel.send(yesembed).then(coins.add(`${message.guild.id}.${message.author.id}`, parseInt(betdouble)))
lyric mountain
#

...still out of context

earnest phoenix
#

this is supposed to add the coins if im right

lyric mountain
#

where are you getting the collected variable?

#

what about the randomnumber and yesembed?

earnest phoenix
#

it sounds like you want the whole code?

#

im just asking why my coins adding is not working

#

the embed is being sent tho

lyric mountain
#

I can't help you without knowing the whole code logic

#

that's like asking "what's wrong with my car" by showing a photo of it

earnest phoenix
#

well im showing the code and just saying that .then is not working
but the embed is being sent and everything is correct

lyric mountain
#

what's betdouble?

#

is it a integer value in a string?

earnest phoenix
#

bet double is = bet*2
and bet is args[0] (a number)

lyric mountain
#

what does your log say?

#

is there an error?

earnest phoenix
#

that betdouble is 2000 (which is correct)

#

but it wont add

#

somthing with .then

#

can i use somthing else on it ?

#

instead of .then

lyric mountain
#

what error are you getting?

#

.then itself isn't the issue

earnest phoenix
#

no error

#

just wont add

#

but it will send the embed

lyric mountain
#

are you saving coins after that?

earnest phoenix
#

wdym

lyric mountain
#

is it a variable or a database entry?

#

like, do you define it in the code or save it to a database?

earnest phoenix
#

quick.db is saving my coins

#

quick.db is saving my coins

lyric mountain
#

and are you persisting the coins object after you're adding to it?

earnest phoenix
#

can you replace the word persisting ?

#

i dont know the meaning

#

...

lyric mountain
#

persisting = saving to database

earnest phoenix
#

yeah its auto saving in the db

#

the system is all ok but the part when .then will just not work

lyric mountain
#

I'm out of ideas then

#

there's probably no other way to run that code after the embed is sent

#

do you really have to run it ONLY after sending the embed?

earnest phoenix
#

no

#

i can first do it then send the embed

#

if thats what u mean

#

it takes a miliseconds there is no difference

lyric mountain
#

try doing it then

earnest phoenix
#

i tried
i still dont have coins

lyric mountain
#

then it's most likely an issue regarding the database

earnest phoenix
#
coins.subtract(`${message.guild.id}.${message.author.id}`, parseInt(bet))```
i have this part where its removing your money after you bet
#

but if you win, it doubles the money and adding

lyric mountain
#

double check the adding method

earnest phoenix
#

i use it with other commands

lyric mountain
#

see if you're not forgetting anything

earnest phoenix
#

idk

#
let betdouble = bet*2```
#

is this the correct way ?

#

oh wait actually

#

maybe i need to do Number(bet)*2

pale vessel
#

meth

lyric mountain
#

as I said, there's not much I can do without seeing the entire code

pale vessel
#

use parseInt()

earnest phoenix
#

idk what to say

wise quartz
#

What's the hex/unicode for this emoji? #️⃣

#

I am trying to add it as a reaction but it ain't workin...?

lyric mountain
#

put a \ behind it

wise quartz
#

I found on google that its "\U00000023"

#

Didn't worm

#

Work*

lyric mountain
#

no it doesn't

wise quartz
#

?

lyric mountain
#

because it's 4 chars, not 8

#

like \u1234

wise quartz
#

\u0023 also didn't woek

#

Work*

#

I tried so kany

lyric mountain
#

as I said, put a \ behind that emote

wise quartz
#

Many*

lyric mountain
#

and you'll get the unicode

wise quartz
#

So :hash: ?

#

Oh nvm

lyric mountain
#

#️⃣

wise quartz
#

On discord?

lyric mountain
#

put.a.\.behind.it

wise quartz
#

Thats showing a square??

lyric mountain
#

in discord

#

yes

wise quartz
#

:hash:

lyric mountain
#

like \:hash:

#

and it'll output

wise quartz
#

:hash:

lyric mountain
#

#️⃣

wise quartz
#

I am doing it

#

Not working

lyric mountain
#

oh god

wise quartz
#

I am a phone user

#

...

#

Can you screenshot ur results?

lyric mountain
#

like \:hash:
copy this

#

although I wonder how can't u see the emote

wise quartz
#

It*

lyric mountain
#

since discord uses standard google emojis

wise quartz
#

Phone users r different dude like for example to see an emoji id we do :-:emoji:

pale vessel
#

unicode actually

wise quartz
#

For pc users its different

#

Yeah they use twitter emojis

lyric mountain
#

also for android users, which is the same as pc one

pale vessel
#

that's just the theme

wise quartz
#

Ye

lyric mountain
#

in his case no

#

it's showing a # before it

#

so it's a missing emoji

pale vessel
#

because unicode

#

mobile fonts could have limited support

lyric mountain
#

anyway, copy this #️⃣

wise quartz
#

#️⃣

#

Lol

#

Ok lemme try it

#

Ok worked thanks

lyric mountain
#

where it's U+1234 you can replace with \u1234

pallid marsh
#

hey um if any1 here into sharding someone can tell me why is my bot responds twice when i use sharding?

#

discord.js

earnest phoenix
#
(node:14145) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 guildMemberRemove listeners added. Use emitter.setMaxListeners() to increase limit
#

anyone know about this thing?

lyric mountain
#

you have a memo leak somewhere

earnest phoenix
#

is this why the thing didnt work before?

lyric mountain
#

are you creating event listeners inside commands?

earnest phoenix
#

im not sure

lyric mountain
#

where are you checking for message deletion?

earnest phoenix
#

on events

lyric mountain
#

but which ones?

#

because you're listening to it 11 times

earnest phoenix
#

it says guildMemberRemove

#

wdym message deletion?

lyric mountain
#

ah, forget about it

#

so, where are you checking for members that leave the server?

#

see if you're not creating it inside a loop or something like that

earnest phoenix
#

i have one command where i do

#

idk about loop, its on a command that if someone leaves it will change the channel name

lyric mountain
#

why do you have a command that creates a onGuildMemberRemove event?

earnest phoenix
#

membercount

#

with channels

lyric mountain
#

you shouldn't need to create guild listeners more than once

earnest phoenix
#

so should i delete it or?

lyric mountain
#

just create one and use member/guild IDs to handle it

earnest phoenix
#

and btw, can it be the reason why the coin think didnt work before?

lyric mountain
#

probably no

earnest phoenix
#

oof

lyric mountain
#

that would be the cause for your bot using 500+ MB of extra ram

earnest phoenix
#

can i send my command so you can help with the coins>

#

somthing similar happend to me before, so i got it out of the event and it started working
but i need this in the event so...

lyric mountain
#

that's a lot of variables

earnest phoenix
#

bruh

lyric mountain
#

instead of creating one embed for each case you could create one embed builder and modify it for each one

#

embeds have a .clear() function to wipe them

earnest phoenix
#

ok but what is the problem?

lyric mountain
#

still reading

#

@earnest phoenix does the coins.add() work somewhere else in your code?

earnest phoenix
#

yeah

#

on addcoins command

#

ik why

#

it wont work

#

listen

#

inside the function of the collect

#

it wont add/remove

#

if i do it outside it will work

#

have no idea how to do it without it being in the function

lyric mountain
#

is the yesembed showing at all?

earnest phoenix
#

yeah

#

again

#

the coins.add wont work inside the collect function

#

if i do it OUTSIDE it will

tired nimbus
#

I have a lot of values like: case1 , case2, case3 . how can I reference them by number? If you don't understand, basically I want this: (botc.raid + Number(args[2])) to be together when you reference by the number

earnest phoenix
#

i have do this

  return console.log("Pas le compteur !")
  } else {
  if(!message.guild.me.hasPermission("MANAGE_CHANNELS")) return message.channel.send("**:warning: I don't have the `MANAGE_CHANNELS` permissions for change the name of counters (english to french).**")
  variable_categorie.setName(`⭐ Stats du serveur`)
  }```

but console say me Missing Access 
How can i do
summer torrent
#

maybe your bot don't have permission for view that channel.

earnest phoenix
#

my bot has permission for view that channel

#

on

#

which

#

method

#

give us the full stacktrace

modest maple
#

can we have that edited with claps at the end of each of those

#

much more enjoyable

late hill
#

How would I check the global ratelimit on sending messages?
I know I can use a simple message post and check the headers and then I'll get this, but this is just the per channel (or per server?) limit isn't it?

mossy vine
#

per channel iirc

late hill
#

Struggles of using a library that handles ratelimits for you, not knowing when you're actually hitting them

golden condor
#
/root/PB-master/Commands/about.js:5
 async(bot, msg, args) => {
      ^

SyntaxError: Unexpected token (
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at files.forEach.file (/root/PB-master/bot.js:28:19)``` Keep getting an error for some reason and I have no idea what the issue here is
slender thistle
#

dicord.py uses logging module and logs the ratelimits

#

at least when you hit one

golden condor
#

Mongoose is really lagging out and I don't know why

late hill
#

ok

#

so apparently you can't check the global limit without actually hitting it

earnest phoenix
#

yeah

#

since they aren't specific per route

#

a bucket doesn't exist for global ratelimits

modest maple
#

fun facts: dont try to find out the global ratelimit

#

and you shouldnt even need to know the global rate limit

#

because its high enough for it only to come into affect if you're doing ye old mass DM

late hill
#

You think they're high enough so that it'll be "impossible" to legitimately hit even for bots that get thousands of new players a day.
And quite a few of those actually sticking around and actively playing.
Especially during a special event of some sort Meguthink

#

I'm at about 10 to 20 commands a second (so basically 10 to 20 messages a second) for one of my bots

#

I see occasional "breaks" in-between the replies which i feel like those aren't my server messing up but simply a ratelimit of some sort.
It doesn't seem to be the per-channel one anymore that I'd usually get.

#

Maybe it's per server if that has it's own limit as well

#

don't know

valid frigate
#

when you look at a bot like pokecord which im pretty sure people abuse the fuck out of it on the daily, discord sees that it's in >n amount of servers and either gives it a ratelimit increase or tries to get in contact with the bot developer

amber fractal
#

rate limits are per server, but there is a global limit

valid frigate
#

so if you're really hitting 10 to 20 messages a second globally then its probably not something to be worried about unless it's in a specific server

#

do you know where it's coming from or nah

late hill
#

they're definitely per-channel too as 2 people in one channel can hit the limit while having those people split up will be fine

modest maple
#

ratelimit is around 500 requests/sec

golden condor
#

@modest maple shiemi told me to ask you about making mongodb/mongoose faster

valid frigate
#

thats weird

late hill
#

I mean, I notice it mainly in my support server which is obviously the most active place for commands

valid frigate
#

i dont think discord will get suspicious if you hit the message ratelimit per channel often

#

maybe

late hill
#

I made 10 command channels so people could actually play without chat flying by

valid frigate
#

unless the 1 hour ban is a still thing for the api

modest maple
#

like tbf

#

you'll be fine

#

ratelimit highhhhhhhh

late hill
#

Maybe it's purely an issue in my server and I should just not have command channels anymore?

modest maple
#

and if ur mega concerned set up some elaborate webhok thing of somthing

#

lol

late hill
#

Or like use a slowmode in them

valid frigate
#

yeah you're probably fine for the most part honestly, if you do get api banned then talk to discord about it

golden condor
#

Mongoose is really laggy please help

valid frigate
#

you should implement cooldowns

#

well assuming you already have them

amber fractal
#

@golden condor Local or remote?

valid frigate
#

maybe just don't send a cooldown message at all and ignore silently until the cooldown is over for a frequently used command

golden condor
#

local

valid frigate
#

it doesn't really have to be that lone either, maybe one second per command

amber fractal
#

What response times are you getting?

valid frigate
#

so people can't go ctrl + c, ctrl + v

golden condor
#

It has made my bot very slow

valid frigate
#

how you handle that is up to you entirely but don't be concerned about your bot hitting channel ratelimit too much atm

amber fractal
#

what are the specs of the computer you run it on?

golden condor
#

3gb of ram

#

25gb of storage

#

8 core cpu

amber fractal
#

what about bandwidth and internet speed

golden condor
#

it;s ethernet

#

so not sure

amber fractal
#

do you self host?

#

hosts normally say the speed they provide

golden condor
#

it's on a dedi

#

my friend's dedi

#

why is mongoose so laggy tho

amber fractal
#

can you do free -h and tell me the output?

golden condor
#

ok

amber fractal
#

I'm not sure then, could be a cpu issue, especially if it's local. I use mongo and have no problems like that

golden condor
#

In a server with no prefix

#

it's fine

#

do you use mongoose or mongodb @amber fractal

#

This is my code for handling prefixes

#
Guilds.findOne({ id: message.guild.id }, async (err, res) => {
      if (err) console.log(err)
      let prefixx;
      if(res) prefixx = res.prefix
      else prefixx = "c!"
  if (!res) {
        prefixx = "c!"
          const newDoc = new Guilds({
              id: message.guild.id,
              prefix: 'c!',
              suggestions: false,
              suggestionchan: null,
          })
          newDoc.save().catch(err => console.log(err))
      }```
amber fractal
#

I use mongodb, but mongoose just connects to a mongo database

golden condor
#

ik

#

but apparently mongodb is faster

amber fractal
#

It is the official driver for mongo

golden condor
#

yeah

#

How would I get this

#
var guilds = new mongoose.Schema({ 
id: String, 
prefix: String, 
suggestions: Boolean, 
suggestionChan: String 
})``` Onto mongdb
amber fractal
golden condor
#

I hate this aaaaaaa

#

I just wanna use mongo-db

#

For prefixes

#

How do I use a schema in mongo db

amber fractal
#

idk I don't use schemas

golden condor
#

i mean how do I make a collection?

#

and how do I find data be a server id

amber fractal
#

It will create one for you when you insert the first document

golden condor
#

how do I do that

#

I need to create the guilds object with those option in

amber fractal
golden condor
#

Ok

#

what abaout dinfing

amber fractal
#

what?

golden condor
#

finding

amber fractal
#

use the docs and search find

icy crane
#

Does anyone know if Cheerio can produce nsfw content? It doesn't SEEM like it but I haven't tested it a ton

golden condor
#

So

#

How do I make a collection

amber fractal
#

Collections are created automatically on insert, but you need to create the database, I think the easiest way is via cli

#

Not collections

#

mb

golden condor
#

howww

amber fractal
#

I highly recommend you use the docs so you don't need to ask a question for everything

digital ibex
#

hi

#

how can i set a primary for my mongo cluster?