#development

1 messages · Page 997 of 1

lyric mountain
#

That'd not work the way he want

latent tundra
lyric mountain
#

It'd be a check inside a "onReactionAdd" event

earnest phoenix
#

i found what i was looking for

#

but

#

i'm not sure what the constructor is

#

or whatever it's called lmao

latent tundra
#

If you just want the user that's in the DM channel use message.channel.recipient

#

As in the message that the bot sent.

earnest phoenix
#

Umm

#

i want the bot to return if the reaction was added by the bot

latent tundra
#

message.author.id==client.user.id?true:false

earnest phoenix
#

ahhhh alright

#

thx

latent tundra
#

reaction.users.cache.fetch([options])

lyric mountain
#

if (reaction.author.bot) return;

#

Inside a onReactionAdd event

earnest phoenix
#

okay thx

latent tundra
#

@lyric mountain That checks if it is by any bot, not the current bot

lyric mountain
#

He wants to ignore bots

earnest phoenix
#

^

lyric mountain
#

Not specifically his own bot

latent tundra
#

Ah okay

#

so yeah

earnest phoenix
#

thx m8

latent tundra
#

he wants to check if the message is by a bot that has reactions?

#

Or he wants to check if a bot made a reaction?

#

because he gotta loop through a fetch still

lyric mountain
#

He probably want to ignore bot reactions

latent tundra
#

ah

lyric mountain
#

Most likely to be used in reaction buttons

latent tundra
#

to check if the current bot gave the reaction is reaction.me

#

Otherwise you gotta loop through it

#

Right?

#

I don't see anything else than the users cache.

#

That's reaction.users.cache

robust moth
#

\:tickYes: it's not working

hardy vector
#

https://hastebin.com/dadayozina.js
(node:12008) UnhandledPromiseRejectionWarning: TypeError: ReactionModel is not a function
at module.exports.run (C:\Users\kenra\Desktop\Frosty Rewrite\src\commands\Utilities\rradd.js:41:22)

#

help

#

pls

#

i've asked so many times

earnest phoenix
#

@robust moth

misty sigil
robust moth
#

I need to extract custom emojis id

earnest phoenix
#

use the emoji, right click, copy link and that last part, that big number

#

emoji id

#

and 315009125694177281 is the id

robust moth
#

Ok

#

But :look: this is shortcut

earnest phoenix
#
module.exports = (client, message) => {
    if (message.author.bot) return                                                                      // If the author of the message is a bot, it will not react

    if (!message.content.startsWith(client.config.prefix)) return                                              // If the message doesn't start with the prefix in config.json, do not react

    const args = message.content.slice(1).split(" ")                                                    // Separates the message into multiple parts
    const command = args.shift().toLowerCase()                                                          // Remove the command from the message parts and puts it here

    const cmd = client.commands.get(command) || client.commands.get(client.commandAliases.get(command)) // Get the command or an alias

    if (cmd) {
        cmd.run(client, message, args)                                                                  // Runs the command
    }
}``` https://cdn.discordapp.com/attachments/708092603329019964/726209489698684978/unknown.png
#

Can someone help with this?

#

rule 1: dont use glitch

#

Whats glitch?

#

something that looks like what u use rn but it actually isnt im sorry

#

oki

heavy anchor
#

No that’s heroku

earnest phoenix
#

rule 2: module.exports = {run(client,message,args) {/*code*/}} is the correct formula for your command files

#

uh

#

well

#

but dyk how to fix my issue

#

i just told you how

#

you told me a rule

#

OH

#

HOHH

#

HOH

#

HOH

#

you have a wrong format somewhere in your commands

#

so the run function doesnt exist

#

prob in my new command

#

so the code nopes the fuc out

#

ill send

#
exports.info = {
    aliases: ["helpserver"]
}
const Discord = require("discord.js")
const server = new Discord.MessageEmbed()
  .setTitle("Code Box")
  .setDescription("Code box's are displayed like this \n \n ` ```
#

thats my newest code

#

wait what

#

that i mean

#

oop

#

ik

#

it should work like that tho

#
exports.info = {
    aliases: ["helpserver"]
}
const Discord = require("discord.js")
const server = new Discord.MessageEmbed()
  .setTitle("Code Box")
  .setDescription("Code box's are displayed like this \n \n ` ```js \n your code here \n ``` `")
  .setFooter("Thanks!")
  .setColor('#d966ff')

exports.run = (client, message, args) => {
    if (args.length > 0) {
        message.channel.send(server)
        return;
      }
      message.channel.send(server)
}```
#

ill just send a ss

#

No that should be fine

#

what command returns that error

#

well since that error

#

none of my commands work

hardy vector
#

https://hastebin.com/dadayozina.js
(node:12008) UnhandledPromiseRejectionWarning: TypeError: ReactionModel is not a function
at module.exports.run (C:\Users\kenra\Desktop\Frosty Rewrite\src\commands\Utilities\rradd.js:41:22)

#

9th time asking for help

earnest phoenix
#

i would like the file ../../models/ReactionRole please @hardy vector

#

also @earnest phoenix you can try to log what your bot is doing at the moment when the error occurs

#

maybe try logging cmd to identify which one causes the issue or smthing

#

alr

#

first command thats broken

#

OH SHIT

#

LMAO I SAW WHAT I DID

#

now it should work

#

wüt

#

@hardy vector i have one question

#

how are we supposed to help when you wont let us help

#

my code was like this

#
`exports.info = {
    aliases: ["inv"]
}
const Discord = require("discord.js")
const invite = new Discord.MessageEmbed()
  .setTitle("Invite")
  .setDescription("**Invite Token bot to your server!**\n \n[**➡Invite**](https://discord.com/api/oauth2/authorize?client_id=722347892156661770&permissions=8&scope=bot)")
  .setFooter("Thanks!")
  .setColor('#d966ff')

exports.run = (client, message, args) => {
    if (args.length > 0) {
        message.channel.send(invite)
        return;
      }
      message.channel.send(invite)
}````
misty sigil
#

its all quoted

earnest phoenix
#

it is

#

mhm

#

lmao

#

does anyone know how to collect reactions to edit a already sent embed

#


message.author.send(inviteembed);
module.exports.help = {
    name: "invite"
};```
It says **`message` is not defined**
#

Full Code:

#
// at the top of your file
const Discord = require('discord.js');

// inside a command, event listener, etc.
const inviteEmbed = new Discord.MessageEmbed()
    .setColor('#0099ff')
    .setTitle('Invite Me!')
    .setURL(`https://discord.com/api/oauth2/authorize?client_id=721960016168353792&permissions=8&scope=bot`)
    .setAuthor('Moderation Bot', 'https://media.discordapp.net/attachments/722094309834227802/722146956260147321/New_Project_-_2020-06-15T122119.065.png?width=269&height=224', 'https://discord.com/api/oauth2/authorize?client_id=721960016168353792&permissions=8&scope=bot')
    .setDescription('Some description here')
    .setThumbnail('https://i.imgur.com/wSTFkRM.png')
    .addFields(
        { name: 'What is Moderation (101)?', value: 'Moderation 101 is a advanced moderation bot more suffisticated than any other.' },
        { name: '\u200B', value: '\u200B' },
        { name: 'Moderation', value: `Cool moderation bot more advanced than any on discord.`, inline: true },
        { name: 'Fun Commands', value: 'Cool fun commands to use in your server.', inline: true },
    )
    .addField('Thanks for reading!', 'Done forget to add me!', true)
    .setImage('https://media.discordapp.net/attachments/721189811851100171/722139773501964298/unknown.png?width=776&height=200')
    .setTimestamp()
    .setFooter('Show some support by adding me!', 'https://media.discordapp.net/attachments/721189811851100171/722139773501964298/unknown.png?width=776&height=200');


message.author.send(inviteembed);
module.exports.help = {
    name: "invite"
};```
crimson vapor
#

I am confused on what you are trying to accomplish

earnest phoenix
#

A message embed.

#

const inviteEmbed = new Discord.MessageEmbed()

crimson vapor
#

you didnt define message

earnest phoenix
#

.. O_o

indigo folio
#

yeah where tf is the message variable initialized

crimson vapor
#

it is not, which is the error. What is the name of the file you wrote this in?

#

and is it a command? or just a response?

indigo folio
#

it looks like it was just copied from some guide given the comments

crimson vapor
#

I thought it was obvious

timber linden
#

pls

#

im dumb but

#

what do u use node.js command promt for

#

pls

#

i saw u typing

indigo folio
#

bruh chill

timber linden
#

PLS

#

@a,w

#

e

#

pls

#

help

crimson vapor
#

no need to spam

low ether
#

anyone know the cheapest way to host a bot?

crimson vapor
#

many people use glitch

winter basalt
#

glitch banned ping services

low ether
#

I am currently using glitch but the 5 min thing is kinda dumb ^

winter basalt
#

so its not really a choice now

low ether
#

okay

lusty quest
#

there is still Heroku

low ether
#

?

lusty quest
#

Heroku is a free Host

#

free hosts have mostly a downside

winter basalt
#

yeah wouldnt recommend freebies

hardy vector
#

https://hastebin.com/dadayozina.js
(node:12008) UnhandledPromiseRejectionWarning: TypeError: ReactionModel is not a function
at module.exports.run (C:\Users\kenra\Desktop\Frosty Rewrite\src\commands\Utilities\rradd.js:41:22)

lusty quest
#

did you export your ReactionModel? in your Model.js?

earnest phoenix
#

@hardy vector I told you already, if you wont let us help we CANT HELP YOU

hardy vector
#

wot

earnest phoenix
#

I asked you for your reactionrole file thingy

hardy vector
#
module.exports.run = async () => {
  const mongoose = require("mongoose");
  const schema = new mongoose.Schema({
    Guild: String,
    MessageID: String,
    Reaction: String,
    Role: String,
  })
  const model = mongoose.model("ReactionRole", schema)
  module.exports = model
}```?
#

my model?

earnest phoenix
#

do you see whats wrong here

#

do you see it

#

ill point it out

#

2 module exports

#

to the same export path

hardy vector
#

oh

timber linden
#

nerdthatnoonelikes

hardy vector
#

so i can remove module.exports = model??

timber linden
#

how do you know so much about me

hardy vector
#

wot?

timber linden
#

i dont even know how to make my bot online

#

im more of a nerd

hardy vector
#

just run node .

earnest phoenix
#

so i can remove module.exports = model??
bruh no

dusk sphinx
#

How to make the bot online to discord successfully

hardy vector
#

ffs just do node <name of main file>

lusty quest
#

supply a valid key to client.login and run it with node .

dusk sphinx
#

Show me how

earnest phoenix
timber linden
#

ahhaha

#

pls snipe

#

LOL

earnest phoenix
hardy vector
#

^

lusty quest
#
Discord = require("discord.js");
const client = new Discord.Client();

client.login(YOURKEY)
hardy vector
#

@earnest phoenix sry if im not talking straight its 11pm here and i didnt sleep last night

lusty quest
#

this will get your a bot that is online

#

if you start the bot

earnest phoenix
#

enrgish 10/10

hardy vector
#

me?

earnest phoenix
#

no

#

superbrain8

lusty quest
#

its 5am for me

earnest phoenix
#

same

dusk sphinx
#

What's for discord cilent

lusty quest
#

?

earnest phoenix
#

does anyone know how to collect reactions to edit a already sent embed
@02Desired#4365

lusty quest
#

you could use the reactionAdd event

hardy vector
#

@earnest phoenix wait so what do i do tho if i need to access the model in other files

dusk sphinx
#

Which would i fill in

hardy vector
#

without exporting it

lusty quest
#

you export it twice that is the issue

#

const mongoose = require('mongoose');

const guildSchema = mongoose.Schema({
    _id: mongoose.Schema.Types.ObjectId,
    guildID: String,
    prefix: String,
    tradechannelid: String,
    startingbid: Number,
    maxminbid: Number
});

module.exports = mongoose.model('Guild', guildSchema);

``` this is a working model
dusk sphinx
#

Man..tech is hard

lusty quest
#

you give us 0 informations about what your issue is. so we cant help you

dusk sphinx
#

Discord = require("discord.js");
const client = new Discord.Client();

client.login(YOURKEY)
Which of this do i need to fill in

lusty quest
#

put this inside of your mainfile

#

then replace YOURKEY with your Discord bot key

dusk sphinx
#

Token?

lusty quest
#

yes

dusk sphinx
#

Where can i find mainfile

lusty quest
#

did you know anything about javascript?

dusk sphinx
#

No..it is first time

lusty quest
#

learn it first. otherwise it makes no sense

dusk sphinx
#

Node.js?

winter basalt
#

js

dusk sphinx
#

The link

lusty quest
winter basalt
#

uh you can get a book or find something online

#

try eloquent js book

earnest phoenix
#

ngl i learnt node.js from making a discord bot

winter basalt
earnest phoenix
#

my first bot was literal garbage

lusty quest
#

i learned javascript from reading source code on github

winter basalt
#

lame. learnt js by lurking this channel

#

smh

earnest phoenix
#

my bot is fixed, praise jesus

#

jesus is dead

#

that turned dark in a split second

#

my 6 kids in the basement are screaming one sec

hazy sparrow
#

is there a wya to send all three messages in the message aka
a b c

#

and not

#

a

lusty quest
#

use \n for a new line

hazy sparrow
#

b

#

c

#

ok

#

ok

lusty quest
#

or use async code

hazy sparrow
#

i want all of them in 1 message

lusty quest
#

then make await send a
await send b
await send c

#

ok

#

add at the end of your first message \n then copy your second behind it then again \n and then copy the 3rd behind it (its one string not 3)

hazy sparrow
#

got it

#

ill try

#

end of the message or code/line

lusty quest
#

message

hazy sparrow
#

so in the ""

lusty quest
#
message.channel.send(`Message1\n Message2\n Message3`)

hazy sparrow
#

ok got it

#

thanks it worked

#

it says "declaration or starement expected"

lusty quest
#

more infos?

hazy sparrow
#

wait

#

imma have to dm you

earnest phoenix
#

what version of linux does heroku use >

dusk sphinx
#

If i use vps..is it free access without do anything about vps just add command?

lusty quest
#

learn mode javascript until you know what is wrong with your last message @dusk sphinx

earnest phoenix
#

what version of linux does heroku use >
@lusty quest any idea bout this ?

lusty quest
#

i never used Heroku. i dont trust Free hardware

earnest phoenix
#

lol

earnest phoenix
#

i am making a bot called gear, still in work in progress, has some moderation, fun commands and more. Very happy to be in the bot making community 🙂

robust moth
#

How find custom emojis id ? Previously I used \:email:

cerulean lake
#

yo

lusty quest
#

should be the same

cerulean lake
#

is this the place to ask for someone to help me test my bot

lusty quest
#

nvm its something else @robust moth

#

@cerulean lake not really

cerulean lake
#

ol

#

ok

earnest phoenix
#

nice @earnest phoenix, welcome (i cant b speaking i dont even have green)

#

Thanks 🙂

shut wolf
#

can anyone help me in making my first bot cmd ..js

lusty quest
pure lion
#

@robust moth copy the link of the emoji, the string of numbers in the link is the emoji ID

earnest phoenix
#

@robust moth easy way to do it is by copying and pasting the emoji into ``

#

like this: ![AYAYA](https://cdn.discordapp.com/emojis/452950994377113614.webp?size=128 "AYAYA")

#

then the id is the numbers in the string

#

or you can just right click the emoji and click copy id LMAO

jovial sentinel
#

does anyone know why my bot is offline?

#

and how to make it go online

earnest phoenix
#

@jovial sentinel what language is it in

jovial sentinel
#

discord.js

#

javascript

earnest phoenix
#

hm

#

Anyone know how to get a bot (Discord.js) to send a message through a premade webhook?

#

Like fetch or whatever

#

like how NQN does but not python(?)

robust moth
#

like this: :AYAYA:
@earnest phoenix I know .
But previously I used \:emoji: it
It's execute emoji id

jovial sentinel
#

oh wait this probs isn't the right channel for me to ask questions ;P sorry

earnest phoenix
#

its developement, so yeah, it is(?)

#

if its not your bot then no.

jovial sentinel
#

it is mine

earnest phoenix
#

ok.

jovial sentinel
#

but it isn't anything special :P

delicate shore
#

hey

#

what is incorrect here

earnest phoenix
#

you tell us

copper cradle
#

@earnest phoenix you can do a post request to the webhook url, with the correct payload, or you can use d.js's built in webhook manager

delicate shore
#

it is not sending message in channel syaing kicked him

earnest phoenix
#

go debug your code

delicate shore
#

go debug your code
@earnest phoenix it says all fine

copper cradle
#

lmfao

earnest phoenix
#

what

#

that's not what debugging is

copper cradle
#

that's not what debugging means

#

😩

earnest phoenix
#

@copper cradle yes, i know if i had the url made and knew the url how to get one sent... how ever lets say someone (User) is using the bot to send a webhook and doesnt want to set one up but use it...
Making a command like: !say [message] sends a users message with their name and such for example

#

I may have misexplained that^ but would i need some DB maybe to store it?

#

or can i just do like how i fetch channels somehow? O.O

copper cradle
#

you'll need to store that webhook's url then

earnest phoenix
#

ah. ok

delicate shore
#
   if (!msg.member.hasPermission("KICK_MEMBERS"))
      return msg.reply("*_Sorry, you don't have permissions to use this!_* :frowning: ");

    let member = msg.mentions.members.first() || msg.guild.members.get(args[0]);
    if (!member)
      return msg.reply("__Please mention a valid member of this server__");
    if (!member.kickable)
      return msg.reply(
        "*I cannot kick this user! Do they have a higher role? Do I have kick permissions?*"
      );

    // slice(1) removes the first part, which here should be the user mention or ID
    // join(' ') takes all the various parts to make it a single string.
    let reason = args.slice(2).join(" ");
    if (!reason) reason = "No reason provided";

    
    await member
      .kick(reason)
      .catch(error =>
        msg.reply(`**Sorry ${msg.author} I couldn't kick because of : ${error}**`)
      );
    msg.channel.send(
      `**${member.user.tag} has been kicked by ${msg.author.tag} because: ${reason}**`
    );
  }```
#

according to me

#

there is nothing wrong here

copper cradle
#

according to me
I'm no wizzard to instantly know what problem you're having

delicate shore
#

it's not sending message

#

saying i kicked HIM Because of:

earnest phoenix
#

ah not providing a reason?

delicate shore
#

he is not sending the message even

earnest phoenix
#

im dumb at this

delicate shore
#

ok

earnest phoenix
#

but like i think you might have to like save the reason as a variable unless you already did

#

uh...

#

he did:

    let reason = args.slice(2).join(" ");
#

wait

#

oh i cant read oml

delicate shore
#

msg.member.send << is this code correct ? for dming the guy who got banned? or kicked

earnest phoenix
#

prolly cuz im dumb

delicate shore
#

since i defined

#

member

#

let member = msg.mentions.members.first()

earnest phoenix
#

i thing member.send is good enough?

#

if you used that

delicate shore
#

ok

earnest phoenix
#

cos then its msg.msg.mentions.members.first()

delicate shore
#

oh

#

yeah i get it

#

i am a nerd

copper cradle
#

send the message before banning the member

earnest phoenix
#

ye

#

cuz then it wont be able to dm the message

#

i know something for once

copper cradle
#

and make sure to check if the member has their dms open

radiant estuary
#

How can I embed my website in discord? When I send a link, that there is a embed below there

delicate shore
#

send the message before banning the member
@copper cradle kkk

copper cradle
#

@radiant estuary meta-tags

#

O think discord uses og tags

#

lemme get a link to that

radiant estuary
#

Witch?

earnest phoenix
#

witch

delicate shore
#

how to give that

radiant estuary
#

I have some. Dont work

delicate shore
#

guild name

earnest phoenix
#

WHAT SORT OF WITCHERY IS THIS?!

delicate shore
#

like you have been kicked from {member.guild}

#

?

radiant estuary
#

Sry, i am not good in english

delicate shore
#

what is it

copper cradle
radiant estuary
#

Thx

copper cradle
#

np

#

iirc those are the one discord uses

#

tho I'm not entirely sure

delicate shore
#

like you have been kicked from {member.guild}
@delicate shore

radiant estuary
earnest phoenix
#
member.send(`Sup, you been kicked from ${message.guild.name}`).catch(e =>{ console.log(`${error}`)}).then(member
      .kick(reason))```

I may be very wrong
#

i think so

#

wait...

radiant estuary
#

message is the message from the guild. So you can get the guild Name 😉

delicate shore
#

can't i simply do this
member.send("You have been kicked from ${message.guild.name} because of ${reason}")

radiant estuary
#

Yes

earnest phoenix
#

for the message yes...

delicate shore
#

ok

#

and for error

earnest phoenix
#

but catch is so if theres an error

delicate shore
#

i will do that

radiant estuary
#

Have you defined the message other?

#

E.g. msg

delicate shore
#

?

#

what

radiant estuary
#

Then you have to change and replace this

earnest phoenix
#

yea it'd be ${msg.guild.name}

#

for your variable in the above example

radiant estuary
#

What do you use for message? Do you write message, oder e.g. msg?

delicate shore
#

msg

radiant estuary
#

Okay, then msg.guild.name

delicate shore
#

that ik

radiant estuary
#

Ok

delicate shore
#

i will change that

#

thanks

radiant estuary
#

Ok

#

Np

delicate shore
#

error is not defined

#

?

#

oh i use e

#

for error

#

lol

#

member.send("You have been kicked from ${msg.guild.name} because of ${reason}").catch(e =>{ console.log(`${e}`)})

#

is this correct?

tepid canyon
#

in the () after .send put the text in ``

delicate shore
#

ok

tepid canyon
#

Then that should be fine

delicate shore
#

ok

radiant estuary
#

Discord doesn't load my website. Can somebody help me pls

earnest phoenix
#

Hello I would like to create a dashboard for my discord bot. Could you help me?

#

Discord doesn't load my website. Can somebody help me pls
@radiant estuary
elaborate

hazy sparrow
#

how do i make cooldowns

#

like

#

5 secs time between commands

#

if less than that bot wont respond

lusty quest
hazy sparrow
#

ok ty

earnest phoenix
#

you don't know if they're using d.js

hazy sparrow
#

im using discord.js

earnest phoenix
#

oh

hazy sparrow
#

xD

earnest phoenix
#

tldr
create some sort of a list of ids
then on command execution put the user id in the map

in js you can then use setTimeout to remove the user from the map
on every command execution check if the user id is inside of the map, if it is then the user is on cooldown

hazy sparrow
#

kk

earnest phoenix
#

you can optimize this by not queueing a fuckton of timeouts but rather having some sort of a timer/interval running checking for entries every second

hazy sparrow
#

i have too smol brain to understand that

#

but i will try the link

#

and learn more js

delicate shore
#

working on my bot website

glossy elk
delicate shore
glossy elk
#

@delicate shore thats open sourced

#

on github

delicate shore
#

wot?

glossy elk
#

that theme

#

is open source

#

d

delicate shore
#

where?

fresh hatch
#
client.on("message", (message) => {
  if (!message.content.startsWith(prefix) || message.author.bot) return;
  if (!message.member.hasPermission("BAN_MEMBERS")) {
    message.channel.send("You don't have permission to use this command!")
  } else if (message.content.startsWith(`${prefix}ban`)) {
    let member = message.mentions.members.first();
    member.ban()
    message.channel.send(member.displayName + " has been kicked! :door:")
  }
})
#

Can someone help me why does my bot do that?

tight plinth
#

@fresh hatch wdym

fresh hatch
#

the bot responds to every message with "You don't have permission to use this command!"

tight plinth
#

Fix your code

#

Do you know how js works?

fresh hatch
#

yes

#

i just realized now

tight plinth
#

Are you sure?

#

Lol

valid scarab
#

Make a logic draw

#

it will help you

#

Prefix :
Check Ban permission :
else If messagee startsWith prefix and ban :

#

The error is that you verify if the sender has the permission before checkinf if the command nedd the ban permission

#

So the ban will be executed only if the person doesn't have the ban permission because of your else

#
  if (!message.content.startsWith(prefix) || message.author.bot) return;
  if (message.content.startsWith(`${prefix}ban`)) {
    if (!message.member.hasPermission("BAN_MEMBERS")) {
      return message.channel.send("You don't have permission to use this command!");
    }
    let member = message.mentions.members.first();
    member.ban()
    message.channel.send(member.displayName + " has been kicked! :door:")
  }
})```
fiery crest
#

how would I make node-got ignore HTTP errors?

earnest phoenix
#

How do I develop

fiery crest
earnest phoenix
#

No like I already have my bot how do I put it on the site and get the bot developer role

fiery crest
earnest phoenix
#
            con.query(`SELECT * FROM economy WHERE id = ${message.author.id}`, function (err, result, fields) {
                if (err) throw err;
                console.log(result);
              });

output :
bash[ RowDataPacket { id: '545490362568015873', coins: '1000' } ]

How i can the coins

#

get thw coins

fiery crest
#

uh what

#

result.coins

#

is the coins

earnest phoenix
#

@fiery crest nope

fiery crest
#

uh yes

earnest phoenix
#

it says undefiened

fiery crest
#

no clue then

earnest phoenix
#

. . .

#

hallp

#

im trying to make a simple test command

#

i was able to make this for my bot

#
import discord

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('kanatest'):
        await message.channel.send('Hello!')

client.run('token')
#

i have that but what do i do with it

#

its correct and all as far as i know

#

but i dont know how to make it actually do the thing

#

im stuck at that bot-env place

#

where i cant do anything

jovial sentinel
#

so you know how you can make a bot listen for messages? is it possible to have it listen for a certain word no matter the capitalization?

earnest phoenix
#

of course

#

you just check whether the message content contains whatever you want

#

you'll have to either transform the string into all lowercase or use ignorecase comparison before checking the content though

#

the latter is faster

jovial sentinel
#

alright

#

thanks :)

#

i'm kinda new to all this

#

still learning

lusty quest
#

@earnest phoenix you can get it with result.coins

#

(keep in mind javascript encodes the query different and can fail if print it to console)

earnest phoenix
#

so i added python to the path

#

but like what do i do after that

#

the tutorial i got didnt tell me where to go

#

there is no commands.bot anywhere in what they told me

modest maple
#

windows?

earnest phoenix
#

Bro how bot send message with animated emoji?

modest maple
#

<a:some_emoji_name:some_emoji_id>

earnest phoenix
#

because discord made it so they can

modest maple
#

what

earnest phoenix
#

Thx

#

![a_](https://cdn.discordapp.com/emojis/670119005352099870.webp?size=128 "a_")

#

anyways im stick at bot-env

#

idk what to do since they never told me what to do

#

it feels like they skipped two important steps

#

iima sleep anyway

fresh hatch
#
let cpu = Math.round(process.cpuUsage().system)
#

can somebody help me why do i get that cpu usage?

#

bc in task-manager its like 4-7mb

lusty quest
#

iirc /1000

fresh hatch
#

?

lusty quest
#

nvm was wrong

hasty sparrow
#

The process.cpuUsage() method returns the user and system CPU time usage of the current process, in an object with properties user and system, whose values are microsecond values (millionth of a second). These values measure time spent in user and system code respectively, and may end up being greater than actual elapsed time if multiple CPU cores are performing work for this process.

dire stag
#

if (message.content === '!ping') {
// send back "Pong." to the channel the message was sent in
message.channel.send('Pong.');
}

#

this command keeps giving my node index.js errors

hasty sparrow
#

What errors?

dire stag
#

/Users/can/JARbot/index.js:8
if (message.content === ' !ping') {
^

ReferenceError: message is not defined
at Object.<anonymous> (/Users/can/JARbot/index.js:8:2)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47

hasty sparrow
#

Define it then

dire stag
#

how:,

hasty sparrow
#

Hastebin your index file please

dire stag
#

const Discord = require('discord.js');
const client = new Discord.Client();

client.once('ready', () => {
console.log('Ready!');
});

if (message.content === '!ping') {
    
    message.channel.send('Pong.');
}

client.login

digital ibex
#

hi so

#

im a little bit confused about this....

#

i have this: js app.post('/save/:guildId', async (req, res) => { const guild = await guildModel.findOne({ id: req.params.guildId }); console.log(guild.prefix); await guild.updateOne({ prefix: 'a' }); console.log(guild.prefix); }); when i do aping nothing responds, when i do hiping it responds, and i log the prefix, it says a as the prefix

#

does anyone know why thats happening? im trying to make a save button for my dashboard btw

hasty sparrow
dire stag
#

yep exactly what ın used

#

have ı mıssed somethıng:

digital ibex
#

sir

hasty sparrow
#

Yes, you missed the message event

digital ibex
#

you need to read it properly or learn js

#

🤷

dire stag
#

sı ı guess ı wıll ıngnore the lıstnıng for messages part

hasty sparrow
#

Are you updating your bot's prefix?

dire stag
#

because thats what ı used

hasty sparrow
#

No, you are using the ready event

dire stag
#

aıght

hasty sparrow
#

Read the guide and compare it to your code

dire stag
#

ıl pass ıt

#

yep

#

thanks

#

would have wasted alot of tıme on that code

#

why would they put ıt there though

hasty sparrow
#

Their code is correct, yours isn't

long yew
#

what is the command thing

#

that gets the users name

#

?

lusty quest
#

message.author.username?

#

or message.author.tag

long yew
#

ok

#

what one works?

#

or do they both?

lusty quest
#

both work

#

one returns the username the other one the usertag

#

(tag is Username#1234)

long yew
#

ok ty

#

wait

#
.setAuthor('message.author.name')
#

so is that wrong?

lusty quest
#

username

#

not name

long yew
#

oh

#

ok

#

thanks

pure lion
#

How can I check if the content of a string is a number of not?

#

Nvm

long yew
#
let arr = [1, 2, 3, 4, 5, 6, 7, 8]

          function random_pokemon(arr) {
            return arr[Math.floor(Math.random() * arr.length)];
          }


          if (random_pokemon(arr) == 1) {
            message.channel.send(woolooEmbed)
          } else if (random_pokemon(arr) == 2) {
            message.channel.send(nickitEmbed)
          } else if (random_pokemon(arr) == 3) {
            message.channel.send(blipbugEmbed)
          } else if (random_pokemon(arr) == 4) {
            message.channel.send(rookideeEmbed)
          } else if (random_pokemon(arr) == 5) {
            message.channel.send(skwovetEmbed)
          } else if (random_pokemon(arr) == 6) {
            message.channel.send(caterpieEmbed)
          } else if (random_pokemon(arr) == 7) {
            message.channel.send(hoothootEmbed)
          } else if (random_pokemon(arr) == 8) {
            message.channel.send(grubbinEmbed)
          }
      }
    }
  }
})```
with that there is always a chance that nothing spawns
do you know the reason?
also do u know how i can make it a percentage instead?
so like a 10% chance a caterpie spawns and stuff
pure lion
#

Actually something will always happen

viral spade
#

When i use mongodb in nodejs, and have lets say something like db.user.find().sort({last_online_timestamp:-1}).limit(10).pretty();.

Will the query return all documents from a remote database first and do the sorting and limiting locally afterwards?

dire stag
#

Next, copy your token from the client.login('your-token-goes-here') line and paste into the config.json file. Make sure to keep it between the double quotes.

#

wont work

digital ibex
#

link01, yeah

#

lucky pickle, what wont work

viral spade
#

So can i somehow get the behavior i have with simple sql queries, where i can compute all kinds of stuff on the database and transfer only the results?

dire stag
#

when ı copy and paste my clıent token Id to confıg.json

#

even wıth double quotes

digital ibex
#

im not familiar with sql queries

#

lucky pickle, send the code

dire stag
#

hold a sec

#

when ıt says make sure to keep ıt ın double quotes

#

ıt means thıs rıght

#

" "

digital ibex
#

im not sure how u expect anyone to help u

#

all u've said is the thing from the d.js guide, and the token doesn't work and ur using the double quotes

dire stag
#

ıt ınvolves my token so ım tryıng to fınd a way

#

tells me to copy and paste my token to confıg.json file

digital ibex
#

maybe just remove the token..?

dire stag
#

with double quotes

digital ibex
#

you're not helping urself or me fix ur issue

dire stag
#

my guy ıt ıs that sımple

#

do you want me to gıve you my token?

digital ibex
#

no

#

you do realise u can remove the token

dire stag
#

then askıng for the code wont work

digital ibex
#

and replace it with something

dire stag
#

ım tryıng to add the token to confıg.json fıle

digital ibex
#

ok, how do u expect me to help u when u've only told me that the token doesn't work, and ur using double quotes and u cant send ur code because then it won't work,

dire stag
#

so ı can simply do client.login(config.token) to login

#

asks me to copy my token from ındex.js

#

move ıt to confıg.json

#

wıth double quotes

digital ibex
#

obviously using a json file is too advanced for u, just do client.login('token')

dire stag
#

doubt that

digital ibex
#

doubt what?

golden condor
#

smh

dire stag
#

not trying to use client.login

#

ı have already done ıt

golden condor
#

dude

#

You have to use client.login() that is what he is saying

dire stag
#

to use Now you can simply do client.login(config.token) to login?

#

ın the json file dont thınk so

golden condor
#

What does your config.json file look like (remove the token)

golden condor
#

smhsmhsmh

dire stag
#

{
"prefix": "+",
"token": ""

}

golden condor
#

so where have you defined config

#

in your main file

long yew
#

how do i get the most recently called pokemon ID (the number from the array)(log it to a DB)
then when the person writes .catch, the pokemon name that was most recently called is logged into the mons.json

golden condor
#

Hold on, can I ask something, does it work?

#

(not to you @long yew)

#

how do i get the most recently called pokemon ID (the number from the array)(log it to a DB)
then when the person writes .catch, the pokemon name that was most recently called is logged into the mons.json

#

what db do you use

long yew
#

json

#

that i want to log

digital ibex
#

does anyone know if i can limit an endpoint to one user without auth?

golden condor
#

session

digital ibex
#

session?

golden condor
#

Assign a user a token with cookies, and check if they have that token

digital ibex
#

oh ok

golden condor
#

it will save with the session

#

Are you using express?

long yew
#

so can anyone help me?

golden condor
#

Can you explain more

digital ibex
#

yeah

golden condor
#

Ok

digital ibex
golden condor
#

No

#

You don't need that

#

Get cookie-parser

digital ibex
golden condor
#

Yes

#
const DB = require('./client/db.js')
    const express = require('express')
    const app = express()
    const tokens = new DB('tokens')
    const ids = new DB('ids')
    app.set('views', __dirname + '/views');
    require("./client/client.js")(client)
    const Guilds = client.db.Guilds
    app.set('view engine', 'ejs');
    const clientfunc = require('./client/client.js')
    var cookieParser = require('cookie-parser');
    app.use(cookieParser());```i do this
digital ibex
#

oki, thanks :)

golden condor
#

And what you can do

#

Is set the max age of the cookie

digital ibex
#

yeah, it looks pretty simple

golden condor
#

So you can set it for how long you want the user to be rate limited

#

e.g.

#
res.cookie('cookie_name', cookie_value /*Can be an object to contain multiple values*/, { maxAge: 'time in millesconds' /* Has to be a number not a string*/ })```
dire stag
#

tried everythıng wont work

#

{
"prefix": "+",
"token": "my token"
}

"my token"

#

says to paste my token from maın ındex fıle to json wıth double quotes nothıng happens

golden condor
#

dude

#

your actual token

dire stag
#

yes

#

....

#

my actual token

golden condor
#

not literally "my token"

dire stag
#

yes

#

exaclty what ı saıd to the other person

lusty quest
#

how did you request your config in your main file?

delicate shore
#

Is anyone free ?

#

I need someone's help

#

But in DMS

dire stag
#

what do you mean:

pale vessel
#

i'm $5

unique nimbus
#

Deal

earnest phoenix
#

you can ask your question here lol

delicate shore
#

It's realted to VPS

#

Here everyone will bully me :(

lusty quest
#

how did you tell your code to read your config file?

digital ibex
#

im a little confused about thism

app.post('/save/:guildId', async (req, res) => {
    const guild = await guildModel.findOne({ id: req.params.guildId });
    console.log(guild.prefix);
    await guild.updateOne({
        prefix: 'a'
    });
    console.log(guild.prefix);
});``` when i do `aping` nothing responds, but when i do `hiping` my bot responds, it logs the prefix as `a`
dire stag
#

const config = require('./config.json');

unique nimbus
#

Why do you need to ask in DMs Doggo?

digital ibex
#

does anyone know why?

lusty quest
#

what did you have in your client.login() line?

earnest phoenix
#

if you're doing something dumb, yes they will and you have no rights to complain because you're doing something dumb LifePOGGERS

dire stag
#

my token

delicate shore
#

I am purchasing a VPS
But I have no idea how VPS works
Can anyone help me pls 😥

dire stag
#

lıke lıterally my token

lusty quest
#

write down there config.token

dire stag
#

not "my token"

lusty quest
#

then it will load it from the config file

earnest phoenix
#

a vps is just a vm running on a physical server, it virtually doesn't differ from your pc

unique nimbus
#

VPS stands for Virtual Private Server, it is used to run server based items like apache2 for websites etc

long yew
#

how do i get the most recently called pokemon ID (the number from the array)(log it to a DB)
then when the person writes .catch, the pokemon name that was most recently called is logged into the mons.json. if anyone knows please reply or dm me

unique nimbus
#

You would need to SSH into it

lusty quest
#

@delicate shore i can help you

delicate shore
#

a vps is just a vm running on a physical server, it virtually doesn't differ from your pc
@earnest phoenix
How can I host bot on that

dire stag
#

so clıent logın confıg.token?

unique nimbus
#

ssh[name]@[IP]

earnest phoenix
#

upload your files

#

run

lusty quest
#

client.login(config.token)

dire stag
#

yes

unique nimbus
#

I use Filezilla to transfer files

dire stag
#

let me rey

lusty quest
#

i guess he is a linux newbie

delicate shore
#

Which is best VPS ?

#

I don't have Linux

earnest phoenix
#

what

#

what are you asking

delicate shore
#

I use Windows

lusty quest
#

did you really get a Windows VPS?

#

wtf they are overpriced

long yew
#

how do i get the most recently called pokemon ID (the number from the array)(log it to a DB)
then when the person writes .catch, the pokemon name that was most recently called is logged into the mons.json. if anyone knows please reply or dm me
@long yew

delicate shore
#

Oh

unique nimbus
#

You don't need a Windows VPS to run your bot

#

Linux can do it

delicate shore
#

I never learnt to use Linux

lusty quest
#

linux is usually half the price

unique nimbus
#

We can assist

delicate shore
#

So I need to download Linux in my pc

unique nimbus
#

no

lusty quest
#

no

dire stag
#

atill nothing happens

delicate shore
#

By removing all the files of windows ?

unique nimbus
#

The VPS will have Linux installed

lusty quest
#

you need a SSH Client like Putty

unique nimbus
#

or Bash

delicate shore
#

Ok

earnest phoenix
#

a vps isn't something you download

#

tf

dire stag
#

json fıle shows error when ı moe my token there

earnest phoenix
#

it's a server

unique nimbus
#

a VPS is a server hosted by a company

earnest phoenix
#

you buy it from a provider

#

yeah

unique nimbus
#

I wanted to try to setup a VPN

#

but I suck at doing so

#

lmao

lusty quest
#

@dire stag more infos?

earnest phoenix
#

next thing you'll know, boom downloaded more ram

delicate shore
#

I started download putty now ?

dire stag
#

const Discord = require('discord.js');

const config = require('./config.json');

const client = new Discord.Client();

client.once('ready', () => {
console.log('Ready!');
});

client.login(my token);

client.login(config.token)

earnest phoenix
#

putty is an ssh client yeah

dire stag
lusty quest
#

why 2x login=

unique nimbus
#

Technically you could use cmd prompt also to ssh into it

dire stag
#

what ım tryın to do

delicate shore
#

This is for me ?

earnest phoenix
#

that'll help you log into your vps and generate your ssh keys

delicate shore
#

Ok

dire stag
#

you just saıd

unique nimbus
lusty quest
#

only 1 login line

unique nimbus
#

Thats the Link for putty

dire stag
#

ok now ı wıll try to move my token to the json fıle

#

so ı can use Now you can simply do client.login(config.token) to login

lusty quest
#

yes

delicate shore
#

I will come after few hours

dire stag
#

wıth double quotes

delicate shore
#

Once I download putty and purchase VPS

#

Bye

lusty quest
#

like on the website you sended the link in

dire stag
#

nothıng happens

#

"my token"

#

am ı meant to put anythıng ın front:

viral spade
#

When i use mongodb in nodejs, and have lets say something like db.user.find().sort({last_online_timestamp:-1}).limit(10).pretty();

Will the query return all documents from a remote database first and do the sorting and limiting locally afterwards?

Can i somehow get the behavior i have with sql queries, where i can compute all kinds of stuff (aggregations,joins,orders,etc.) on the database and transfer only the results?

lusty quest
#
{
    "prefix": "!",
    "token": "your-token-goes-here"
}
``` if this is your Json
dusk sphinx
#

I tried other way to turn my bot on is worked but need set inf/24/7

lusty quest
#

it should work

dire stag
#

yes ıt ıs

honest perch
#

how do i edit a msg in eris?

dusk sphinx
#

It's buggy

lusty quest
#

then just make sure the path in your Main file for your config is correct then it should work

dusk sphinx
#

A lot of data has been wasted

dire stag
#

const Discord = require('discord.js');

const config = require('./config.json');

const client = new Discord.Client();

client.once('ready', () => {
console.log('Ready!');
});

client.login(config.token)

#

thats my maın ındex.fıle

lusty quest
#

if the path for your config is correct it should work

dire stag
#

that ıs the path

lusty quest
#

start and see what happens

dire stag
#

config.json is showing an error

golden condor
#

what is the error

lusty quest
#

can you make a screenshot?

dusk sphinx
#

I thought it was coma symbol

dire stag
#

ok

pale vessel
#

@honest perch <message>.edit()

dusk sphinx
#

I think should to have copy important require

bitter sundial
#

When i use mongodb in nodejs, and have lets say something like db.user.find().sort({last_online_timestamp:-1}).limit(10).pretty();

Will the query return all documents from a remote database first and do the sorting and limiting locally afterwards?

Can i somehow get the behavior i have with sql queries, where i can compute all kinds of stuff (aggregations,joins,orders,etc.) on the database and transfer only the results?
@viral spade what module are you using? That query looks like mongo shell queries instead of mongo nodejs driver or mongoose.

But for example <Model>.find().sort().limit().exec() on mongoose will perform all those operations on the database

dusk sphinx
#

But not code

#

I got my bot on..half more tail left

dire stag
lusty quest
#

where is the error in the json?

dire stag
#

the "token"

#

just lıke the websıte says

dusk sphinx
#

Token need code of your d.bot

lusty quest
#

did you got the prefix and the token in there?

dire stag
#

yessır

lusty quest
#

did you got a , after the prefix?

golden condor
#

Can you show us what the error is please

lusty quest
#

i guess he dont want to show the json bcs of the token

dire stag
#

the error ıs my token

lusty quest
#

is the token set as a string?

#

eg in " "

dire stag
#

woow

lusty quest
#

why 2 token?

#

the bottom line needs to go

pale vessel
#

how about you just show the error

lusty quest
#

this is probably the error

dusk sphinx
#

Only effect 1 each

dire stag
#

ıt tells me to po

#

ok let me try

dusk sphinx
#

It just like been a mechanic

lusty quest
#

if you have only ```
{
"prefix": "!",
"token": "your-token-goes-here"
}

dire stag
#

lets ee

earnest phoenix
lusty quest
#

no extra line or word

dusk sphinx
#

O..now i remember

lusty quest
#

what is the result without coins?

earnest phoenix
#

wait

dire stag
#

what does ıt meant that ı can use clıent.logın(confıg.token)

earnest phoenix
lusty quest
#

you dont have the token in a file you could accidentaly upload

#

@earnest phoenix try result[0].coins

earnest phoenix
#

ok

#

thx

#

it works

pale vessel
#

just print result

#

welp never mind

lusty quest
#

its already fixed

earnest phoenix
#

How can i reboot all shards with eval?

pale vessel
#

if something isn't defined, check the base object first and go from there

earnest phoenix
#

Anyone?

lusty quest
#

im not large enought to get into sharding

dusk sphinx
#

Using pc is slower than i think

digital ibex
#

@earnest phoenix what library

pale vessel
#

djs

digital ibex
#

client.destroy

earnest phoenix
#

d.js

digital ibex
earnest phoenix
#

I don't mean this.

lusty quest
#

does destroy restarts the client? i thought you need to login again

earnest phoenix
#

nvm

dusk sphinx
#

It's hard to complete without watch yt video

digital ibex
#

you can await it if u wanna log back it

#

await client.destroy; await client.connect

dusk sphinx
#

it just same if relogin

pale vessel
#

function lol

viral spade
#

@viral spade what module are you using? That query looks like mongo shell ..
@bitter sundial

Yes i have not implemented it yet but ofc i intend to use it via the nodejs driver.

So when using <Model>.find().sort().limit().exec(), no data is transmitted until the exec has been executed?

digital ibex
#

im eating rn lol, im trying to type less

dusk sphinx
#

Lol

fresh hatch
#

Can somebody help me get all servers my bot's in member count?
This is the code that i written, but doesn't work:

client.guilds.members.cache.size
pale vessel
#

uh

#

members is not a guilds property

#

you can use .reduce()

dusk sphinx
#

It because the symbol missing..isn't

pale vessel
#

guilds.map(x => x.memberCount).reduce((x, y) => x + y);

#

this is my code

lusty quest
#

^

quartz kindle
#

no need to map, you can reduce directly and essentially double the performance lul

pale vessel
#

had to map it first since reduce itself returned NaN

digital ibex
#

im a bit confused and stuck here, js app.post('/save/:guildId', async (req, res) => { const guild = await guildModel.findOne({ id: req.params.guildId }); console.log(guild.prefix); await guild.updateOne({ prefix: 'a' }); console.log(guild.prefix); });

#

when i do aping nothing responds.. and it logs a as the prefix

#

i do hiping and it responds.

viral spade
digital ibex
#

does anyone know why thats happening? im a bit confused

lusty quest
#

@digital ibex you need to supply a key for the query

digital ibex
#

wel, very confused

fresh hatch
#

*guilds

digital ibex
#

superbrain, wym?

lusty quest
#

1sec

bitter sundial
#

i intend to use it via the nodejs driver.
My example was mongoose but similiar exists in the nodejs driver

So when using <Model>.find().sort().limit().exec(), no data is transmitted until the exec has been executed?
@viral spade correct

pale vessel
#

depends on your library

dusk sphinx
#

Oh uh..i am lazy againist book

quartz kindle
#

@viral spade i have 0 experience with mongo, but both mongo and sql should do that. all dbs should run queries inside the db and transmit only the results

#

thats a basic design for databases anyway

lusty quest
#
guild.updateOne({message.guild.id, {prefix: a}})
``` this will update the prefix in the given guild
viral spade
#

its just the style of wrting with the dots in between always suggests to me that the first thing is resolved before the next gets executed

lusty quest
#

(if your model has a guild field)

quartz kindle
#

yeah i get that

#

mongo is weird, i prefer sql

dusk sphinx
#

I have mid low experience..so i try harder to get smarter

digital ibex
#

u can do it multiple ways, and im not using a discord api library

dusk sphinx
#

Same

lusty quest
#

its just a example

#

and i dont know how your model look. but if you want to have a per-server config you need to supply the index of the document you want to edit

long yew
#

how do i get the most recently called pokemon ID (the number from the array)(log it to a DB)
then when the person writes .catch, the pokemon name that was most recently called is logged into the mons.json?

#

that is my code

pale vessel
#

YIKES

lusty quest
#

bind the ID to the one that spawns and write it with the .catch command

long yew
#

how?

digital ibex
#

superbrain..

#

theres multiple ways of doing it, thats not the only way, and in the bot itself, thats the way i do it normally

long yew
#

cause i wanna log the id of the latest one that has spawned

digital ibex
#

it works perfectly fine for me

long yew
#

then be able to .catch

digital ibex
#

irrelevant, you should use a switch statement there

#

thats perfect for one

viral spade
#

Okey follow up question. I am thinking about migrating my statistics bot from mysql to a sharded mongodb.

  1. For calculating stats i have crazy long queries, doing joins over all statistics tables, group and sum up each channels entries for a specific user etc. Will this be "easily" doable also in the mongodb setting (in one query, without getting part results)?
  2. Currently i have usual split relational tables as such "guild, guildmember, guildrole, textmessages, voiceminutes, ..". Should i transfer this style to make a collection for each table, or should i make 1 guild collection that holds all the other tables as fields?

Are there any other special caveats i need to keep in mind when changing from mysql to mongo?

lusty quest
#

i recently switched from mysql to mongo. for now i have a single collection for the guild settings. and a additional one for userdata

digital ibex
#

u should try to use as little collections as possible

#

i only use two

livid rivet
#

uh quick question

#

is it possible for bots to have a rich presence as well?

digital ibex
#

no

livid rivet
#

uh damn

lusty quest
#

maybe with the SDK

near ether
#

how do i set up intents?

#

do i need to have verified my bot before i can do that?

#

because i keep getting
Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted.

#

whenever i try to launch my bot

lusty quest
#

go to the discord developers page and enable it

misty sigil
#

why do you need that

near ether
#

i did that a few minutes ago and it didnt do anything

misty sigil
#

I’m just curious why you’d need it

lusty quest
#

discord changes some stuff on the API to get better data protection

misty sigil
#

and did you remember to save the changes

lusty quest
#

to get in future access to it you need to be Verified if you have more than 100 guilds and enable it in the web panel

near ether
#

yep

#

personally, i just want to avoid dealing with anything i dont need to

#

my bot doesnt need to know presences or any of that stuff

#

and i dont want to deal with d.js caching it

lusty quest
#

then you probably need to switch to a other language

near ether
#

nah i mean for specifically presences, i dont want to cache them

earnest phoenix
#
            con.query(`SELECT * FROM economy WHERE id = ${message.author.id}`, function (err, result, fields) {
                if (err) throw err;
                if (!result[0]) {
                    con.query(newuser, function (err, result, fields) {
                        return message.channel.send("You current credit is " + result[0].coins)
                    });
                }
                message.channel.send("You current credit is " + result[0].coins);
            });
#

Help how i can fix

#

this

lusty quest
#

just dont deal with the new intent stuff. if you just have 1 or 2 commands that need them its better to just ignore them

#

@earnest phoenix what is broken?

earnest phoenix
#
{ Error: Cannot enqueue Handshake after already enqueuing a Handshake.
#

handshake in a handshake

lusty quest
#

bcs you have a query in a query

earnest phoenix
#

yes

#

so how i can fix it

lusty quest
#

dont query in a query

earnest phoenix
#

then my code wont work

#

cuz i wanted to check does user is in the database

#

if not

#

i will create a new data for him

lusty quest
#

then call a function for the other query

earnest phoenix
#

so

function newuser(){
con.query blalalala
}
#

?

near ether
#

nvm im dumb lmao i was enabling intents on my actual bot but trying to use them on my test bot

lusty quest
#

try it

earnest phoenix
#

ok

lusty quest
#

i usually have the mysql querys in a function and just call them in the code. so i can do ```javascript

const data = await getData(message.author.id)
if(!data){await createUser(message.author.id)

earnest phoenix
#

Oh

#

ok

#

How i can stop the query

lusty quest
#

stop the query?

#

does it stuck in a loop?

digital ibex
#

does anyone know why my prefix isn't updating?

#

my code: js app.post('/save/:guildId', async (req, res) => { const guild = await guildModel.findOne({ id: req.params.guildId }); console.log(guild.prefix); await guild.updateOne({ prefix: 'a' }); console.log(guild.prefix); }); ?

lusty quest
#

i had issues with a wrong field type

digital ibex
#

it says the prefix is a, on the second log, but its actually hi

lusty quest
#

this wont let it update it in the DB

digital ibex
#

me?

lusty quest
#

yes

digital ibex
#

why won't it update?

lusty quest
#

i dont think you use something else as fieldtype for your prefix as a string right?

digital ibex
#

wym by fieldtype?

lusty quest
#

when you create the model you define what type the field has.

digital ibex
#

string

lusty quest
#

like prefix: String

#

my guess is it cant find a document to update. but you said you use a different method

earnest phoenix
#

where is the discord development docs

digital ibex
#

wym

#

it can find the document, i log guild and it logs the guild object

#

the guild object in my db*

lusty quest
#

can you check on your DB server that it updates? (logging in with something like Compass)

digital ibex
#

it doesn't

lusty quest
#

its possible that there is some wired caching behavior that loggs the correct prefix but doesnt update it

digital ibex
#

i dont think so

#

im hosting it all on my pc

lusty quest
#

i still think you need to define a index to the update query. im sure that prefix is not your index

long yew
earnest phoenix
#
function getCoins(message) {
    con.query(`SELECT * FROM economy WHERE id = ${message.author.id}`, async function (err, result) {
        if (err) throw err;
        const embed = new RichEmbed()
            .setColor("RANDOM")
            .setTitle(`${message.author.username}'s balance`)
            .addField("**Money:**", result[0].coins)
        return message.channel.send(embed);
    });
}
function newUser(message) {
    const newuserAdd = `INSERT INTO economy (id, coins) VALUES (${message.author.id}, 0);`
    con.query(newuserAdd, async function (err, result) {
        if (err) throw err;
        const embed = new RichEmbed()
            .setColor("RANDOM")
            .setTitle(`${message.author.username}'s balance`)
            .addField("**Money:**", result[0].coins)
        return message.channel.send(embed);
    });
}

===============================================================

            try{
                var coins = await getCoins(message);
                if(!coins) coins = await newUser(message);
            }catch(e) {
                message.channel.send("Oops, there is a error !")
                return console.log(e)
            }

Damm it, it says handshake in handshake

#

sad

long yew
#

can anyone help me?

earnest phoenix
#

@long yew npm install fixed-width-string

digital ibex
#

@lusty quest im confused, wym?

long yew
#

ok ty

earnest phoenix
#

@digital ibex he didnt install the moduel

#

@lusty quest help me

digital ibex
#

im wasn't talking to u

lusty quest
#

one sec

digital ibex
#

or anything related to his issue

earnest phoenix
#

oh sorry

#

i thought u ping the zSam

lusty quest
#

@earnest phoenix your code will not work like expected

earnest phoenix
#

hmmm

#

why

lusty quest
#

@digital ibex iirc query is Model.updateOne(key, {fields})

digital ibex
#

you can do it that way, theres multiple ways of doing it

#

lemme show u something

long yew
#

what is wrong?

lusty quest
#

well my knowledge with mongo is not the best rn since i just started using it

digital ibex
earnest phoenix
#

@long yew show code

digital ibex
#

mongo is good

long yew
#

@earnest phoenix what part?