#development

1 messages · Page 859 of 1

marble juniper
#

thanks

#

I could use moment to format the remaining time

quartz kindle
#

then to mix them up you can do this ```js
let minutesAndSeconds = ${Math.floor(minutes)} minutes and ${seconds % 60} seconds

#

or that yeah

uneven lichen
#

Does anyone know what this is? After updating discord.js, something doesn't work. (ReferenceError: Discord is not defined)

quartz kindle
#

whats your node.js version?

queen needle
#

send code?

marble juniper
#

you need node.js version 12 or higher

#

also Discord is not defined means that the variable Discord does not exist

#

did you define Discord in your code

quartz kindle
#

@queen needle the difference between writeFile and writeFileSync is that writeFileSync will stop your process until the file has completed writing

marble juniper
#

like var Discord = require("discord.js")

#

did you do that

queen needle
#

shouldnt it be a const

marble juniper
#

doesn't matter

quartz kindle
#

doesnt matter much

queen needle
#

but you shouldn't have tp change it

marble juniper
#

const just makes it so the variable can't be changed after decleration

uneven lichen
#

like var Discord = require("discord.js")
@marble juniper I put it this way: const { RichEmbed } = require("discord.js");

marble juniper
#

there we go

#

the variable is called RichEmbed

#

not Discord

queen needle
#

so if i constantly update the file i should use writeFile @quartz kindle

quartz kindle
#

yes

marble juniper
#

cuz with { } you destructered it to only have the RichEmbed variable

queen needle
#

yeah(says yeah to sound smart)

marble juniper
#

if you want it to be Discord just do
const Discord = require("discord.js")

quartz kindle
#

in short ```js
Discord = require("discord.js")
new Discord.RichEmbed()

or

{ RichEmbed } = require("discord.js")
new RichEmbed()```

marble juniper
#

yes

uneven lichen
#

ok thanks

queen needle
#

i just dont bother with rich embeds i dont understand how they are different to real embeds

west raptor
#

RichEmbeds is literally just a embed builder

marble juniper
#

Discord Embeds are json format

#

so yeah

uneven lichen
#

Another question. Is it possible to create a script that will run the bot again after the crash?

mossy vine
#

you can use a process manager

#

like pm2

uneven lichen
#

ok thank you so much

golden condor
#

pm2 is good

#

It's really easy to use

marble juniper
#

you can make a config file

#

to make it auto restart

earnest phoenix
#

I want to store the user's time in SQL, but if I load it that way ```js
const accountsss = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0]));

con.query(INSERT INTO osu (uid, osuid) VALUES ('${accountsss}', '${args[1]}'));```
then <@> may also be there for me to remove <@> sql upload

quartz kindle
#

use the user id

earnest phoenix
#

thanks

torpid valve
#

What is the maximum of embed fields in embed?

slender thistle
#

25

queen needle
#

or is it?

blissful scaffold
queen needle
#

but is it?

spice pier
#

Yes it is

queen needle
#

why can't y'all just let me be mysterious

spare goblet
marble juniper
#

so I have this problem that if I update 1 thing in my 1 database

#

the second database gets also updated with the same content

#

and in my code I am not using the second database

#

only the first database

#

so that makes no sense

hollow token
#

does anyone use heroku?

queen needle
#

no

#

i want to use heroku but idk how

spare goblet
#

just use a normal vps

#

@marble juniper what db are you using tho

marble juniper
#

quick.db

#

cuz im too stupid to use anything else

spare goblet
#

Sorry I can't help you, I've never used quick db properly before :^)

#

move onto better-sqlite3 when POGGY

queen needle
#

why would you use a db

spare goblet
#

if you don't use a db then what do you use

#

your hand? uwot_confused

queen needle
#

yes

#

duh

spare goblet
queen needle
#

but like i was just asking like what data you use

#

a db for

spare goblet
#

For saving configurations

#

for example, customisable prefixes, settings, etc

#

leaderboard scores, mod-log cases

queen needle
#

i might have to learn how to use a db then

spare goblet
#

It's a vital part, yes

queen needle
#

what db should i use

spare goblet
#

uh it depends on what you're familiar with

queen needle
#

wdym

marble juniper
#

you can use things like sqlite

#

or mongodb

#

also there are different kinds of databases

#

there are local file databases

#

or database's where you need a connection and so on

#

try them out and then use what you prefer and think is easier to use

hybrid ruin
#

How would I get started on setting up a webhook on my server to listen to DBL?

slender thistle
#

Official DBL wrappers support simple webhooks

hybrid ruin
#

I'm not really sure how webhooks work

slender thistle
#

Just a server running on a machine, waiting for requests

hybrid ruin
#

Ah I see

#

What would I have to do once a server's set up and all? Do you know a good walkthrough perhaps?

modest maple
#

the docs

#

handles like 99% of it

slender thistle
#

On your bot's Edit page and fill out the webhook URL (http://<ip>:<port><webhookPath>) and authorization field

hybrid ruin
#

I think I'm either missing that 1% or misunderstanding most of it. To set up that webhook, do I not have to configure something within the server my bot's hosted on?

quartz kindle
#

no

slender thistle
#

Open a port, that's about it redShrug

hybrid ruin
#

Ah haha, alright

#

Thank you

quartz kindle
#

the term "webhook" is basically used to mean a reverse request, ie: instead of you making a request to some service, the service makes a request to you

#

discord webhooks are for sending data to discord that way (discord becomes a webhook receptor, so you can send webhooks to discord)

#

top.gg's webhooks are for sending you their data that way (you become a webhook receptor, so top.gg can send you their webhooks)

slender thistle
#

you correcting my definitions? wanna go? FiteMePunch

hybrid ruin
#

Oh okay, that makes sense to me

modest maple
#

Shiv u just got 1 upped

slender thistle
#

Can't believe I got wiped by a JS dev
Humiliating

quartz kindle
#

lmao wut

hybrid ruin
#

Painful

#

Thank you both either way

hybrid ruin
#

I hope I'm doing it right this time. I set the webhook's url within the api options for my bot to <ip>:<port>/dblwebhook and the dbl variable is set to const dbl = new DBL('<token>', { webhookPort: <port>, webhookAuth: '<auth>' }, client); but it keeps printing "Webhook running at http://0.0.0.0:<same port>/dblwebhook" instead of the assigned IP

quartz kindle
#

thats normal

#

dbl doesnt actually detect what your public ip is

earnest phoenix
#

Anyone know how i can get the role size on discordjs v12?

quartz kindle
#

0.0.0.0 just means "this machine"

stuck ravine
#

Hello, someone with this error? Prism is not a constructor

hybrid ruin
#

Ah of course

earnest phoenix
#

@hybrid ruin ipofthemachine(or your connection):port/dblwebhook

hybrid ruin
#

Gotcha, thank you

earnest phoenix
#

Np

#

Anyone know how i can get a guild roles size in discord.js v12?

elder vine
#

guildMember.cache.roles.size?

earnest phoenix
#

Ty

#

I test it

elder vine
#

Go ahead

earnest phoenix
#

(node:21678) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'roles' of undefined

hybrid ruin
#

To get the amount of roles a guild has, you're looking for guild.roles.cache.size

earnest phoenix
#

Yeah i've thinking this

#

Worf perfectly

#

Ty

#

^^

hybrid ruin
#

Any time

indigo folio
#

help what discord permission is required to change (voice) channel permissions

#

i thought it was Manage Channels but apparently not

static trench
#

hello. i am trying to host my bot ondiscloudbot.com but it says there is an error with my requirements.txt. an somone take a look at it>

quartz kindle
earnest phoenix
#
const userBest = await osuApi.getUserRecent({ u: 'hheadshot', m: 0 });
    console.log(userBest[0]);```

Console:```js
counts: {
    '50': '0',
    '100': '0',
    '300': '315',
    geki: '47',
    katu: '0',
    miss: '17'
  },```    50, 100,  300 ```js
console.log(userBest[0].counts.50);``` HMM???
spare goblet
#

That's incorrect

#

"50" is a string

#

50 <- integer

quartz kindle
#

you cannot access indexes by number like that

#

you have to use []

#

counts[50]

#

counts.bla only works when it starts with a string

earnest phoenix
#

THanks

#

working

#

😗

quartz kindle
#

a.b works
a.b1 works
a.1b doesnt work
a.1 doesnt work
a[1] works
a["1b"] works

earnest phoenix
#

I'm looking for someone to join me in developing a typescript bot powered by discord.js, dm me if interested uwu

digital ibex
#

hi

#

can someone help me make a prefix command in mongoose

grizzled raven
#

someone say a try it and see question xd

spare goblet
#

save prefix in a schema with guild id

tight plinth
#

make the db and call it for each message to look at the prefix

spare goblet
#

no

#

bad

#

don't call it for each message

#

cache it instead

digital ibex
#

can you help me with it, i am new to mongo

earnest phoenix
#

Im having an issue with my bot :
Im having an issue with my bot code :

callme = ['smarrbot', 'smart' , 'smartbo' , 'martbot' , 'sartbot' , 'sartbot' , 'smartbo' , 'smartbt' , 'smarbot' , 'smarbot'];
callmevalue = false
ban = ['ban', 'bannir' , 'banir' , 'banir le' , 'bannir le membre' , 'ban le membre' , 'ban the user' , 'ban an user' , 'ban the user'];
banvalue = false

client.on("message", async message => { let msg = message.content
callme.forEach(item => {if (msg.includes(item) ) {callmevalue == true;} });
ban.forEach(item => {    if (msg.includes(item) ) {banvalue == true;}    });


if (callmevalue == true && banvalue == true) {
    message.channel.send("Okay !")
    return;
}

if (callmevalue == true) {
    message.channel.send("Okay !")
    return;
}

})

#

I don't understand why it is spamming that much for no reason

distant plank
#

I have a big problem, I don't know what happens, but my bot doesn't work anymore, I already have the code ready, and it doesn't work, just turn on and nothing else, try another bot just changing the token and it works, but not with my bot's token. :C

tight plinth
#

first : what the fuck c quoi ce bordel
second : return message.channel.send ?
@earnest phoenix

earnest phoenix
#

return; c'était pour couper mon code mais ca sert a rien

digital ibex
#

it doesn't have to be return

earnest phoenix
#

Ignore le 😂

#

The return isn't the source of my problem, i tried to add it to like block my code but its snot working 😂

#

@tight plinth

#

J'avait oublié le ping :')

tight plinth
#

hm

earnest phoenix
#

oh shit

#

i just understood

#

I forgot to block bot messages and also reset my banvalue and callmevalue

tight plinth
#

lol

earnest phoenix
#

Cuz new message as its always true cuz don't rest it , of course its looping asf 😂

tight plinth
#

u know how to do, dont u?

earnest phoenix
#

Do what ??

tight plinth
#

block bots + resetting

earnest phoenix
#

I mean block bot i can find that

tight plinth
earnest phoenix
#

Je fait ce que je veux de mon status Mdr

tight plinth
#

mouais

#

mouais

#

so

earnest phoenix
#

Tu ne me semble pas très convaincu 😂

tight plinth
#

a bon tu crois?

earnest phoenix
#

Un peut

tight plinth
#

(lets not talk french here)

earnest phoenix
#

Yeah we are gonna get killed

tight plinth
#

yep

earnest phoenix
#

Im trying to make an old bot i made before

tight plinth
#

blocvking boz is ez

earnest phoenix
#

an fake AI

#

Yeah ik

tight plinth
#

resetting values too

earnest phoenix
#

@tight plinth is there a way to do like if message.content.contains[myarray]

#

Instead of looping ?

tight plinth
#

mesage.content is text

#

try it and see

uneven lichen
tight plinth
#

store messages and delete them later

#

we will not write code for you

earnest phoenix
#

@tight plinth i mean can i just .contains(array)
Because i need to do a for each item in value..

tight plinth
#

watch this

grizzled raven
earnest phoenix
#

its not that i don""t try

#

its just i don't know how to do it if its even possible

marble juniper
#
process.exit()

will this work?

#

oh wait

#

wrong channel

#

my bad

#

just ignore what I said

lyric mountain
#

so, does anyone here have experience with pgadmin4?

#

I'm almost losing my head trying to fix "CSRF session token missing" issue

left flint
#

i need help ... i need to know what prefix is

lyric mountain
#

__s!__somecommand
^-----prefix

left flint
#

the prefix is a command ? like !something ?

lyric mountain
#

the prefix is something that comes before the command

left flint
#

the sign ?

#

or symbol

lyric mountain
#

....note that I've made the prefix bold and underlined

#

that is a prefix

left flint
#

ok

#

thanks

mossy vine
#

why are you asking

lyric mountain
#

it could be:
__!__somecommand
__%__somecommand
__prefix!__somecommand
__--__somecommand
__!#$__somecommand

#

or anything else

indigo folio
#

pls meme

left flint
#

i just wanted to know because i am trying to add a new bot

lyric mountain
#

wait

#

stop right there

#

do you HAVE a bot to start with?

left flint
#

aha

#

i created one

lyric mountain
#

ok, go on then

sterile minnow
#

How can i log a Enmap Map like: console.log(the_enmap_thing)

mossy vine
#

does it respond to commands etc because if it doesnt then close the website right now

digital ibex
#

Hello

left flint
#

of course it respond commands

digital ibex
#

can someone help me make a prefix command in mongoose

mossy vine
#

aight then carry on

digital ibex
#

All i've got so far: ```js
try {
let guild = await GuildModel.findOne({ id: message.channel.guild.id, prefix: prefix });
if(!args.length) {
message.channel.createMessage(the prefix is: ${guild.prefix});
} else {
GuildModel.findOne({id:message.guild.id}, (err, db) => {
let nP = args[0];

             })

             
        }
    } catch (e) {
        console.log(e);
        message.channel.createMessage(`error\n${e}`);
    }```
lyric mountain
#

@digital ibex what's the issue?

digital ibex
#

there is no issue

#

i am just stuck on what to do from there

amber fractal
#

I would just use findOneAndUpdate using the $set operator on a prefix key

digital ibex
#

um

#

im stuck

#

i've got no idea :/

lyric mountain
#

if you use a database then you just need to update the prefix column

digital ibex
#

this is my first time using mongodb compass

lyric mountain
#

I don't use mongobd, so I can't help u with that

amber fractal
#

I gave you an option you could use

lyric mountain
#

but in sql would be a simple update transaction

digital ibex
#

I just connected to the compass and i dont know what to do from here to make the command

amber fractal
#

Are you using the official mongo driver from node or another package to interface with it?

digital ibex
#

im not sure, how would i check

#

i think im using the node one

#

i think

amber fractal
#

Well you had to install it

#

most people use mongoose or the official driver

distant plank
#

Help me pls :c

hasty valve
#

anyone know anything about glitch?

digital ibex
#

i am using mongoose

elder vine
#

Yes, mag.

amber fractal
#

Alright, I don't know much about mongoose, but it should have a findOneAndUpdate in it which should work the same

hasty valve
#

does glitch support node 12

digital ibex
#

okay

amber fractal
#

I would also look into upsert as well, but you don't need to

marble juniper
#

@hasty valve you can just go into the package.json and then find where the node version is located and then just change the number to your desired version and then it will beginn an install process so yeah you can update node on glitch

analog junco
#

How to clean all messages sent by bot in my dm? (Discord.js)

elder vine
#

You fetch all messages by bot, and delete them.

marble juniper
#

fetch the messages from the dm channel

analog junco
#

can i get the code?

elder vine
#

Code it yourself :P

marble juniper
#

can you try and look at the docs

#

and try to do it yourself

elder vine
#

We'll help you on your way :)

analog junco
#

Okay. thank you ill try it

elder vine
#

Use a mobile device, and copy text - and it should be there. Or fetch message

crimson vapor
#

wut

mystic leaf
#

lmao i just realised its plain js

#

soryr

#

million i pinged u

crimson vapor
#

yes

mystic leaf
#

was gonna ask what language you used in your error eval code block

#

then i realised its just js

crimson vapor
#

```js

```

mystic leaf
#

ty

crimson vapor
#

yeah

digital ibex
#

would i do it like this?

#
                let newPrefix = await GuildModel.findOneAndUpdate(filter, update, {
                    new: true
                  });
elder vine
#

To change prefix?

digital ibex
#

yeah

elder vine
#

what is your modal?

digital ibex
#

this? ```js
const Guild = Schema({
id: String,
ownerID: String,
memberCount: Number,
prefix: String
});

elder vine
#

ye, it's fine

#

you would do something like this

#
await GuildModel.findOne({
id: guild.id
}, async (err, guild) => {
guild.prefix = (prefix)
await guild.save().catch(err=> console.log(err);
});
#

I've not been able to use findOneAndUpdate

#

but I'm sure you're able to

digital ibex
#

okay

#

would that change the prefix?

elder vine
#

with this you would find the guild you would want to change prefix of

#

with the guild id

#

and you would update the value and save it

#

the GuildModel will be the one to your guildSchema file

#

If you use it correctly, yes.

ember atlas
#

There’s like a web panel to see your data base entries with mongo right?

elder vine
#

Wdym, Boss?

lyric mountain
#

something like phppgadmin or phpmyadmin

#

but for mongo

ember atlas
#

Ya I’m pretty sure it has it I’ve used it before

digital ibex
#

what would i define my prefix as then in my command handler file?

elder vine
#

Wou would need to use the findOne again

#

You need to set it as a variable

#

like let guild =

digital ibex
#

oh

elder vine
#

not quite

digital ibex
#

with eris its message.channel

elder vine
#

Oh

digital ibex
#

and with d.js guild takes a channel property as well

elder vine
#

Ok, so

#

in your case: prefix.prefix would be the prefix

#

since you set let to prefix

digital ibex
#

wdym?

elder vine
#

You named the variable prefix

#

to call for the prefix you would need to use prefix.prefix

#

also remember to use await before calling the guild.findOne

digital ibex
#

kk

#

im confused on what i need to do

elder vine
#

What do you have so far?

digital ibex
#

um

#
let Guild = require('./models/Guild.js');
let prefix = Guild.prefix
#

thats it

elder vine
#

with the await

digital ibex
#

okay

elder vine
#

You got it?

digital ibex
#

so like this? ```js
const Guild = require('./models/Guild.js');
let prefix = await Guild.findOne({id: message.channel.guild.id })

elder vine
#

instead of let prefix = use: let guild = so we can define the prefix after

digital ibex
#

okay

earnest phoenix
#

How can i detect if a message contains a mention ? old methods don't seems to work..

elder vine
#

then you can define the prefix let prefix = guild.prefix

#

What method @earnest phoenix does not work?

digital ibex
#
const GuildSettings = require('./models/Guild.js');
let guild = await GuildSettings.findOne({id: message.channel.guild.id })
let prefix = guild.prefix
#

like that?

elder vine
#

Yes.

digital ibex
#

okay

#

how would i check a guilds prefix via mongo compass?

elder vine
#

You can do { id: "idhere" }

#

in the search bar

digital ibex
#

uh

elder vine
#

like so

earnest phoenix
#

@elder vine ```
let member = message.mentions.members.first();
if(!member) message.channel.send("Please mention a valid member of this server"); return;
if(!member.kickable) message.channel.send("I cannot kick this user! Do they have a higher role ?"); return;

digital ibex
#

where?

elder vine
#

What djs version?

digital ibex
#

oh, ok

elder vine
#

You need to create a collection first

earnest phoenix
#

Last one

elder vine
#

with the modal

digital ibex
#

what is a good name to call it?

elder vine
#

Alright give me a sec XPY.

digital ibex
#

.cache

elder vine
#

message.mentions.members.first() should work?

digital ibex
#

so i should just call it "Guild"?

elder vine
#

Sure

#

But make it using code OfficiallyLost

digital ibex
elder vine
#

Yep

digital ibex
#

wdym make it using code?

elder vine
#

Don't use compass to create it.

#

Better way

digital ibex
#

oh, ok

elder vine
#

You could use some of your old code in the message event:

const GuildSettings = require('./models/Guild.js');
let guild = await GuildSettings.findOne({id: message.channel.guild.id })
#

then just use if(!guild) to check if the guild doesn't exist.

digital ibex
#

okay

#

so

#

if(!guild) return;

elder vine
#

no

#

if guild does not exist you would need to make it exist

#

by making a new GuildSettings

earnest phoenix
#

@elder vine doesn't work for me

digital ibex
#

w- how

#

xpy, its .cache

elder vine
#

Alright so.

#

let newGuild = new GuildSettings({
modal_here (with filled in values)
});
await newGuild.save().catch(e=>console.log(e));

#

so

#
    id: String,
    ownerID: String,
    memberCount: Number,
    prefix: String

Your modal right? so

    id: guild.id,
    ownerID: owner.id,
    memberCount: members,
    prefix: default_prefix
sterile minnow
#

how do i Fetch a message and edit this message? (djs 12)

digital ibex
#

you can only edit ur clients messages

#

so

elder vine
#

textChannel.fetchMessage('123456789012345678');

earnest phoenix
#

@digital ibex where am i suposed to add it ? That cache shit is so fcked up 😂

sterile minnow
#

like my Bot sends a message and then restarts. Fetch the message and then edit

digital ibex
#

yeah ik, but shrug

earnest phoenix
#

can u give me the line ?

#

Also the discordjs doc is fcked up too

digital ibex
#

let member = message.mentions.members.cache.first();

marble juniper
#

you could write the id of the message in a temporary file then when it restarts make it read the id in the file then fetch the message delete the file and THEN edit the message @sterile minnow

digital ibex
#

change ur <member> to that

sterile minnow
marble juniper
#

at least thats how I would do it

elder vine
#

or use your db

earnest phoenix
#

salut smartbot ban @[LEXA] Smart

marble juniper
#

yeah

#

or use db

elder vine
#

Did you use v12 Tayron?

sterile minnow
#

yes

digital ibex
#

probably use .cache

elder vine
#

channel.messages.fetch('123456789012345678');

digital ibex
#

channel.messages.cache maybe? idk

earnest phoenix
#

(node:2880) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'first' of undefined

digital ibex
#

haven't used djs in awhile

#

xpy, what line?

#

and show the code

earnest phoenix
#

let member = message.mentions.members.cache.first();

digital ibex
#

iirc that is

elder vine
#

.cache is not a thing..

digital ibex
#

it is

sterile minnow
elder vine
#

not in message.mentions

sterile minnow
#

da heck

digital ibex
#

never knew

elder vine
#

Why glitch :(

#

xD

#

.cache is v12 btw

#

I guess read here

sterile minnow
#

bc i'm broke lol

digital ibex
#

whats do i do with the second bit

elder vine
#

$3/month for a pretty good vps

sterile minnow
#

its Undefined

digital ibex
#

also

sterile minnow
elder vine
#

You change the values to what it should create in the new guild, @digital ibex

digital ibex
#

where would i put it?

elder vine
#

In message event

#

if(!guild) {
//here
}

marble juniper
#

you could try awaiting it@sterile minnow

sterile minnow
#

i try

digital ibex
#

oh

elder vine
#

but you need to use the other part i sent too

unborn steeple
#

How would i check if someone sent a message in a certain channel? Using discord.js btw

digital ibex
#

im so confused leny

elder vine
#

Read what I sent

digital ibex
#

yeah, and im more confused :/

elder vine
#

What did you write down so far?

digital ibex
#
if(!guild) {
    id: guild.id,
    ownerID: owner.id,
    memberCount: members,
    prefix: default_prefix
}
``` haven't put it in it yet bc there will be syntax errors
elder vine
#

not quite

digital ibex
#

:/

unborn steeple
#

yeah i know how to get the channel and all im just trying to is send a message everytime someone else sends a message in a certain channel basically

elder vine
#
if(!guild) {
let newGuild = new GuildSettings({
    id: guild.id,
    ownerID: owner.id,
    memberCount: members,
    prefix: default_prefix
});
await newGuild.save().catch(e=>console.log(e));
}
earnest phoenix
#

So any fix for my code ? 🤔

elder vine
#

Well - wdym Puddin?

digital ibex
#

okay

unborn steeple
#

Lile i have a suggestions channel, and it gjves them bot currency for every message they send in suggestions

elder vine
#

like if(message.channel.id === "id") {
let channel = client.channels.cache.get("send_id");
if (channel) channel.send(message.content);
}

unborn steeple
#

So im rryna to make the bot give the reward everytime a message is sent to the message author in the suggestions channel

elder vine
#

^

#

something like that?

unborn steeple
#

Hold on

elder vine
#

If it's v12

#

or else change client.channels.cache.get with client.channels.get

digital ibex
#

ok,

unborn steeple
#

So i have a suggrstions channel.
Everytime a member sends a message in the channel, i want it to give them the reward

What im tryna ro do is figure out how will i make it so the bot will know when they sent a message

digital ibex
#

this is what i have in my message event

elder vine
#

use the message event puddin

digital ibex
#
    const GuildSettings = require('./models/Guild.js');
    let guild = await GuildSettings.findOne({ id: message.channel.guild.id });
    let prefix = guild.prefix;
    if(!guild) {
        let newGuild = new GuildSettings({
            id: guild.id,
            ownerID: guild.owner.id,
            memberCount: guild.memberCount,
            prefix: 'a!'
        });
        await newGuild.save().catch(e=>console.log(e));
        }
``` minus everything else unrelated
elder vine
#

not quite OfficaillyLost

digital ibex
#

and- oh

elder vine
digital ibex
#

oh

elder vine
#

and ownerID: message.guild.owner

#

and message.guild.memberCount

digital ibex
#

ok

#

so

pale vessel
elder vine
#

^

digital ibex
elder vine
#

Yep

digital ibex
#

oh

elder vine
#

not message.channel.guild.prefix

digital ibex
#

oh?

pale vessel
#

why the unnecessary .channel?

digital ibex
#

GuildSettings.prefix?

elder vine
#

He's using eris

digital ibex
#

using eris

pale vessel
#

ah

#

eris smh

elder vine
#

No

#

'a!'

digital ibex
#

uh

elder vine
#

the default for any guild prefix

digital ibex
#

ok

earnest phoenix
#

How can i overwritePermissions to all the roles in a server?

digital ibex
#

ok, this is what i have

pale vessel
#

use a loop

elder vine
#

forEach role

pale vessel
#

no

digital ibex
#
    const GuildSettings = require('./models/Guild.js');
    let guild = await GuildSettings.findOne({ id: message.channel.guild.id });
    let prefix = guild.prefix;
    if (!guild) {
        let newGuild = new GuildSettings({
            id: message.channel.guild.id,
            ownerID: message.channel.guild.owner.id,
            memberCount: message.channel.guild.memberCount,
            prefix: 'a!'
        });
        await newGuild.save().catch((e) => console.log(e));
    }
    let oldGuild = GuildSettings.findOne({
        id: message.channel.guild.id,
        ownerID: message.channel.guild.owner.id,
        memberCount: message.channel.guild.memberCount,
        prefix: 'a!'
    })
pale vessel
#

forEach is slow

earnest phoenix
#

i tried but it didnt work

#

other way ?

elder vine
#

Well, you don't want to abuse Discord API

earnest phoenix
#

wdym

digital ibex
#

that'd cause api spam

earnest phoenix
#

really?

#

lmao

digital ibex
#

api spam = against tos

elder vine
#

no the last part

#

nothing else needed

pale vessel
#

not against ToS, just rate limited, afaik

earnest phoenix
#

@pale vessel any other way?

#

that would not spam api too

elder vine
#

like rainbow roles = api abuse /bannable

digital ibex
#

wdym?

elder vine
#

well

pale vessel
#

probably wait for like a second after every role?

earnest phoenix
#

how do i do it

digital ibex
#

so remove everything else apart from id?

elder vine
#

The findOne looks for all values and looks in db for existing values

earnest phoenix
#

it doesn't matter as long as your bot respects ratelimit headers, which if you're using a library, it probably does

elder vine
#

memberCount, prefix, and ownerID can be different from times to times. but ID will never change.

digital ibex
#

oh

#

so

lyric hawk
#

Hi, I have a very weird problem: DMchannels' IDs seem to change after a few minutes. I'm doing a client.get_channel(dmchannel_id) a few minutes after storing it into a dictionnary and it returns None all of a sudden

digital ibex
#

the other way around

earnest phoenix
#

the problem is when you keep doing the same request over and over again which at that point it becomes api abuse - updating overwrites on each channel isn't

elder vine
lyric hawk
#

Yes

digital ibex
#

everything apart from id remove?

elder vine
#

yea

earnest phoenix
#
channel.overwritePermissions(message.guild.roles.forEach), {
      SEND_MESSAGES: false
  }```
#

will this work without abusing?

elder vine
#

not quite

#

forEach(channel

lyric hawk
digital ibex
#
    const GuildSettings = require('./models/Guild.js');
    let guild = await GuildSettings.findOne({ id: message.channel.guild.id });
    let prefix = guild.prefix;
    if (!guild) {
        let newGuild = new GuildSettings({
            id: message.channel.guild.id,
            ownerID: message.channel.guild.owner.id,
            memberCount: message.channel.guild.memberCount,
            prefix: 'a!'
        });
        await newGuild.save().catch((e) => console.log(e));
    }
    let oldGuild = GuildSettings.findOne({
        ownerID: message.channel.guild.owner.id,
        memberCount: message.channel.guild.memberCount,
        prefix: 'a!'
    })
``` like that leny?
earnest phoenix
#

no

#

for the same channel

pale vessel
#

why forEach?

earnest phoenix
#

but all roles

elder vine
#

I'm just asking so someone else can help, since I don't know .py

lyric hawk
#

oh ok

#

I'm gonna specify it

elder vine
#

or use a for() loop

earnest phoenix
#

@pale vessel wdym

digital ibex
#

woz that right?

earnest phoenix
#

each role will not be able to send_messages

elder vine
#

No

#

You gotta keep ID

digital ibex
#

oh

elder vine
#

everything else is values that can change

cinder patio
#

Itay, you can provide the guild ID so "everyone" won't be able to see the channel

earnest phoenix
#

I used everyone

lyric hawk
#

Hi, I have a very weird problem with discord.py: DMchannels' IDs seem to change after a few minutes. I'm doing a client.get_channel(dmchannel_id) a few minutes after storing it into a dictionnary and it returns None all of a sudden, just like if the ID was no longer valid (shouldn't it remain unchanged?)

earnest phoenix
#

Idk if its good enough

modest maple
#

@lyric hawk No DM channel ids vary

earnest phoenix
#

I guess it is cause then only users with permissions can type...

modest maple
#

you should store user ids

earnest phoenix
#

Well thanks,

modest maple
#

and then get the user object and send via that

lyric hawk
#

Oh okkk

#

Thank you for your help

#

So you can send either via dmchannel id or userid?

#

No difference?

elder vine
#

Actually @digital ibex move this part:

    let guild = await GuildSettings.findOne({ id: message.channel.guild.id });
    let prefix = guild.prefix;

to the bottom under the if(!guild) {
}
//here

#

and remove the oldGuild variable

digital ibex
#

okay

balmy knoll
#

discord.py: once I get the member, how can I change his nickname?

digital ibex
elder vine
#

Hm.....

#

No, nvm. Move the let guild up again

#

and keep let prefix there

digital ibex
#

ok

#

(edited)

#

like that?

cinder patio
#

you can also do

if (!guild) {
  guild = ...
}
...and then use guild```
elder vine
#

^
Yea, that's actually better

digital ibex
#

okay

balmy knoll
#

discord.py: once I get the member, how can I change his nickname?
??

earnest phoenix
#

assuming genders smh

digital ibex
#
let guild = await GuildSettings.findOne({ id: message.channel.guild.id });
if(!guild) {
guild = new GuildSettings({
id: message.channel.guild.id,
ownerID: message.channel.guild.owner.id,
memberCount: message.channel.guild.memberCount,
prefix: 'a!'
})
await newGuild.save().catch((e) => console.log(e));
} else {
//code
}
#

so like that?

elder vine
#

well...

#

You would still need to guild.save

earnest phoenix
digital ibex
#

kk

#

(edited)

#

so like that?

elder vine
#
let guild = await GuildSettings.findOne({ id: message.channel.guild.id });
if(!guild) {
guild = new GuildSettings({
id: message.channel.guild.id,
ownerID: message.channel.guild.owner.id,
memberCount: message.channel.guild.memberCount,
prefix: 'a!'
});
await guild.save().catch(e => console.log(e));
}
let prefix = guild.prefix;
#

yea

digital ibex
#

okay

#

but i should remove the else?

elder vine
#

Yea

digital ibex
#

what happens to the guilds the bot is already in now?

elder vine
#

Isn't this in the message event?

#

Whenever they message, the bot will make a new Document for the guilds on MongoDB and it can be used as prefix.

#

Just try it, and see.

digital ibex
#

yeah, it is

#

ok, via mongodb compass, how can i check the guilds settings?

elder vine
#

Just refresh now

digital ibex
elder vine
#

Right by collections

#

in the top

potent tree
digital ibex
#

but where?

elder vine
#

top left

digital ibex
#

oh, okay

elder vine
#

.setURL("url") @potent tree

potent tree
#

thanksGWcmeisterPeepoLove

digital ibex
elder vine
#

You can also use text in the setDescription etc.

#

There you go

#

now, run the bot. And type something in a channel where it's in.

#

It should create a document

digital ibex
#

kk

#

nothing happens

elder vine
digital ibex
#

i refreshed it as well

elder vine
#

Weird

digital ibex
#

oh

elder vine
#

Any errors?

digital ibex
#

that refresh :D

#

oh, yeah

#

im getting an error

elder vine
#

What error?

digital ibex
#

i just fixed it

#

can't read property of prefix of null of undefind

elder vine
#

Did you fix?

digital ibex
#

or smething like that,

#

yeah

elder vine
#

did it create it now?

digital ibex
#

just getting a few errors

#

ok, i fixed them

crimson vapor
#

O mongo

#

I know mongo

elder vine
#

xD

digital ibex
#

more errors

elder vine
#

Show me

#
  • show code
digital ibex
#

im fixing them, they're just mistakes like guildsettings is not defined

elder vine
#

ok

digital ibex
#

ok uh

#

i sent two messages and nothing

elder vine
#

?

digital ibex
#

no errors

#

this might be the issue

#

i might be looking in the wrong place?

#

oh, yeah

#

it was :/

#

sorry

crimson vapor
#

why do they have the same ID but different owner IDs?

cinder patio
#

I am not sure why you're even storing ownerIDs / memberCount

digital ibex
#

they don't

cinder patio
#

you can get that with the guild ID

digital ibex
#

i want to make a blacklist feature, where if the owner is blacklisted, the bot leaves

#

and membercount is just for me tbh

elder vine
#

ok

crimson vapor
#

I will sent a picture of my guild storage

elder vine
#

but yea, why two of them..

crimson vapor
#

most of it gets migrated in the rewrite

#

so it only gets the preifx and shit it needs

elder vine
#

Lot's of customizations, I like it.

crimson vapor
#

yeah

#

allows for most things to be changed

#

I need to create an api so I can make do stuff on web

#

around 3k docs per small storage

elder vine
#

yikes

crimson vapor
#

it would be way more but people arent really active in this server

elder vine
#

In this server?

crimson vapor
#

yeah

#

I have no "big" servers

#

and I only have 34 servers in total

#

by I have I mean the bot is in

elder vine
#

Hmm

#

Well, I recently had to migrate my bot to a new token. So I had to get all new guilds

crimson vapor
#

why?

elder vine
#

Lost 2fa access to the Team Owner accc

crimson vapor
#

OOF

elder vine
#

only around 450 guilds tho

cinder patio
#

that sucks

crimson vapor
#

still way more than my bot

elder vine
knotty steeple
#

so about discord bots

#

who hates the new update

elder vine
#

Wdym, it's not all bad.

#

Verification is kinda good, but well yea

knotty steeple
#

it doesnt need to exist lul

#

and u have to send an id or passport

#

or driver's license

balmy knoll
#

await member.edit(nick='Test') Why doesn't this line change nickname in Test? (discord.py)

digital ibex
#

no errors

#
            let guild = await GuildModel.findOne({ id: message.channel.guild.id });
            let prefix = guild.prefix;
            if (!args.length) {
                message.channel.createMessage(`the prefix is: ${guild.prefix}`);
            } else {
                await GuildModel.findOne(
                    {
                        id: guild.id
                    },
                    async (err, guild) => {
                        guild.prefix = prefix;
                        await guild.save();
                    }
                );
            }
        } catch (e) {
            console.log(e);
            message.channel.createMessage(`error\n${e}`);
        }
balmy knoll
#

await member.edit(nick='Test') Why doesn't this line change nickname in Test? (discord.py)
Can someone help me?

digital ibex
#

@elder vine uh, its not logging when a message is being sent

modest maple
#

change nickname in Test?
Sense = None

digital ibex
#

and @balmy knoll its probably better to ask in the d.py server

uneven lichen
barren brook
#

Im having issues understand the discord.js new update where embeds are changed and my code is not working:

        let statusembed = new Discord.MessageEmbed()
        .setTitle('Update Patch: 0.1')
        .addField('Added Some X Dinos')
        .addField('Lowered Melay.')
        message.channel.send(statusembed)
      }```
cinder patio
#

looks correct to me?

#

oh

#

You need a title and a description in the .addField function

#

You just provide titles

barren brook
#

Ok

barren brook
#

@cinder patio if (message.content === "-status") {
let statusembed = new Discord.MessageEmbed()
.setTitle('Update Patch: 0.1')
.addField({title: 'Added Some X Dinos'})
.addField({title: 'Lowered Melay.'})
message.channel.send(statusembed)
}

Thats my code now

#

It isnt showing the fields tho how come?

fleet chasm
#

the format for a field is
.addField(name, desc, inline?)
...check the docs

barren brook
#

ty

unborn steeple
#

I forgot what object.map means lol

#

objectMap*

#

In discord.js

vocal oak
#

Sea

surreal folio
#

i was told to come here for help

earnest phoenix
#

Yes u were

#

What's ur bot name

#

@surreal folio

#

I'm curious:)

mossy vine
#

i can help you set up a bot that will loop the song you want

earnest phoenix
#

Oh

#

...

#

Does mystical know about the portal then

icy crane
#

is a github repository required to post on top.gg?

mossy vine
#

@icy crane o

#

no

icy crane
#

alr

earnest phoenix
#

Oh

#

Hmm

#

Theres this site

#

That tells you how to do that

#

I forgot its name

#

Wait

#

I remeber

#

No

#

A YouTube tutorial

#

For how to create a simple music bot

mossy vine
#

not every has an interest in programming and learning so much just for getting a bot that loops a song

earnest phoenix
#

I came across it

#

Hmm

#

Glitch

mossy vine
#

psst chances are that tutorial is fucking useless

earnest phoenix
#

Do that

#

True

#

It was

surreal folio
#

all i wan is one bot man

#

just to loop music

earnest phoenix
#

Yep

#

Then get a 2nd bot to ping it every 12 hours

mossy vine
#

@surreal folio i can help you set one up

earnest phoenix
#

@mossy vine the tutorials on yt is outdated but some in the websites are good

mossy vine
#

i know what im talking about i literally made what he needs two years ago

earnest phoenix
#

Same

#

Maybe fisquoro

#

He made P74Y

#

A music bot

#

But

#

Hes very pushy

#

Very very very very very pushy

#

Fisquoro isn't on here

#

Tho

#

It's pretty obvious why

#

A creator of youtube simulator

#

Remember that bot?

#

I was one of the 1st 10 to add it

#

Sure.

#

I gotta go... Maintence issuses

gritty bolt
#

does anyone have any good resources that could help me to better follow rate limits?

quartz kindle
#

what rate limits are you trying to follow?

#

rate limits are dynamic so they might change at any time without warning, and most libraries have systems in place to correctly follow them

#

so you dont actually need to do anything other than not abuse the api with some unreasonable function

gritty bolt
#

mainly discords since i've gone over a couple times

#

i use discordjs

#

so is there something i might be missing?

quartz kindle
#

are you running some function in a loop?

#

are you doing some forEach with an api call?

gritty bolt
#

oh shoot

#

im a literal

#

idiot

#

sandwich

#

i was looping a function

#

in the middle of some random command

#

thanks i guess lol

quartz kindle
#

lmao

gritty bolt
#

oh actually a real question

#

if i do go over a ratelimit

#

is there something passed so i can tell the user?

#

or will discordjs just wait before sending it?

mossy vine
#

if its message ratelimit it will wait

earnest phoenix
#

hi

mossy vine
#

(if you hit message ratelimit it would be pretty useless to tell the user through a message)

earnest phoenix
#

cana i use external animated emojis using a bot

gritty bolt
#

alright cool thanks

mossy vine
#

yes

quartz kindle
#

@gritty bolt discord.js actually has systems in place to prevent ever hitting the real discord api rate limits

#

if you get a rate limit error, its most likely discord.js's own rate limit prevention system warning you, not an actual discord api rate limit error

gritty bolt
#

oh

#

well that looping function actually was shutting off my bot

#

it was real bad

#

like i dont even know how i didnt shut the whole server it was on down

quartz kindle
#

if the process goes on an infinite loop it will eventually crash itself

#

but it shouldnt affect the whole system much, aside from a cpu usage spike

crimson vapor
#

how many times does a process do the loop before it crashes?

quartz kindle
#

depends

#

usually a few million times

crimson vapor
#

wow

#

thats a lot

gray pagoda
#

wrong place

crimson vapor
#

but I guess if it can do 3+ billion cycles a second

#

right?

icy crane
#

I'm sort of confused, what does this mean

#

like, what

#

max of 3?

#

why?

#

what is the point of that if its a max of 3

mossy vine
#

you can choose servers to display on your bots page

#

the servers must be listed and have your bot

#

basically just a showcase of "hi these servers use this bot"

icy crane
#

ok yeah

#

kinda like, hah this server uses my bot, im cool

mossy vine
#

yes

quartz kindle
#

this is from 2014, but its a good example Are you curious how many recursive calls you can make on your JavaScript engine? How many recursive calls? The following function lets you find out (inspired by a gist by Ben Alman). function computeMaxCallStackSize() { try { return 1 + computeMaxCallStackSize(); } catch (e) { // Call stack overflow return 1; } } Three results: Node.js: 11034 Firefox: 50994 Chrome: 10402

mossy vine
#

cant you change that tho

quartz kindle
#

you can

mossy vine
#

so its not very significant is it

#

how would you even reach that limit tho

crimson vapor
#

oh so I see it calls itself in its code

quartz kindle
#

the stack size is actually not limited to number of loops but to size in bytes

#

as your looping continues, the stack size increases in memory

#

and if it exceeds a certain size in bytes, it crashes

crimson vapor
#

I ran it and got 12568

quartz kindle
#

so depending on what your function does, which variables it uses, how much memory it is holding, the amount of loops you get will be different

#

also, some loops will be infinite and ignore the stack size

crimson vapor
#

doesnt that just say if size doesnt exist use 1?

quartz kindle
#

thats a true infinite loop, it wont crash until you kill the process

#

yes

#

the above rules however only apply to recursion, ie functions inside functions

#

stuff like while(true) will still be infinite regardless

crimson vapor
#

how often will it check a while function?

#

1ms?

#

it seems a bit random

#
const time = Date.now() + 3;
let x = 0;
while (time > Date.now()) {
  x++;
  console.log(x);
}```
#

not an efficient function

#

but it should return the amount of tries it does

#

in 3ms

#

and it was anywhere from 40 to 70

late hill
#

This would very much be affected by the specs of whatever is running it

#

Also keep in mind that your os decides which process gets "processor time" at which point

crimson vapor
#

oh yeah

late hill
#

and who knows what node does behind the scenes

crimson vapor
#

do you?

late hill
#

If I run that code I get "1"

#

If I change it to 4, i get up to 10

crimson vapor
#

what cpu do you have?

late hill
#

ryzen 9 3950x

crimson vapor
#

hmm

#

2600 and it gave me 60

late hill
#

simply executing it from a different type of terminal also changes the result heavily

crimson vapor
#

hmm

#

lemme see what it does on powershell and cmd

#

wait I dont think I can

#

because I use an ssh

small prairie
#

is there a way to check all common members between two servers
or i just have to loop through entire members
d.jsv11.5

crimson vapor
#

all common? I think you loop though

#

you can make it more efficient by checking the larger server for the members of the smaller server

small prairie
#

Alright thanks

true ravine
#

For some reason I can't find this on Google so it's probably a stupid question, but if I create a websocket with ws (js) how do I know what the URL of said websocket is

#

I want to connect to it externally so I can't use localhost

#

And the connection just times out of I attempt to connect with the public IP of the server it's hosted on

quartz kindle
#

your websocket runs in a port right?

#

then the url should be ws://YOUR.VPS.IP.ADDRESS:PORT

true ravine
#

Hmm I've tried that

#

I've also tried it's public DNS and no luck

quartz kindle
#

does it work if you try locally with localhost?

true ravine
#

Yeah

#

It's definitely making the server part, I just can't seem to connect to it

quartz kindle
#

if it works with localhost, but not with public ip, then there's a firewall blocking, or blocked port

true ravine
#

I (probably stupidly) deleted all firewall rules listed for the instance and that changed nothing

#

So I'm stumped

quartz kindle
#

check if your hosting has any firewall system in its admin panel

true ravine
#

I'm using AWS so I just changed the network security group settings

quartz kindle
#

then idk, i havent used AWS before

true ravine
#

Oh right, thank you for your help though

crimson vapor
#

what is hostapd?

earnest phoenix
#

Hey, would anyone know how one would convert a .js script into .py ??

crimson vapor
#

there is a translator I think

mossy vine
#

^

#

if there is its likely garbage

#

and you can optimize a lot

#

not to mention library differences

#

yes, i do

#

i have no idea what that even is

quartz kindle
#

@woven sundial have you checked the configuration docs?

#

i took a look there and found this

earnest phoenix
#

i need help

#

i made my bot in c# but when i do command it says "Unknown Command" on console

uneven wyvern
#

Code?

#

We cannot help without Code

earnest phoenix
#

^

#

sec

uneven wyvern
#

Markdown it with ``````

earnest phoenix
#

what?

#

delete the second one pls

#

and remove your token

#

asap

#

wdym second one

crimson vapor
#

O

earnest phoenix
#

The second file

crimson vapor
#

free token?

#

dont mind if I do

#

jk

#

I wont

#

delete the file from discord please

earnest phoenix
#

i am confused

#

@earnest phoenix the Program.cs.txt has your Bot token in it

#

yes

#

string token = "Njk3OTE1NDExOTY2MTk3OTcx.Xo-O2Q.CI4cUuNL4OD54Daa_uAfxGlo75U";

uneven wyvern
#

omfg

crimson vapor
#

LOL

quartz kindle
#

@earnest phoenix your token is your bot password

earnest phoenix
#

broh

#

bruh

#

dont star

quartz kindle
#

with that token anyone can login and hack your bot

earnest phoenix
#

Time to regen your token

crimson vapor
#

it will just get taken down by a mod

uneven wyvern
#

regenerate it

earnest phoenix
#

idc it is for testing lol

#

lol

uneven wyvern
#

STILL

earnest phoenix
#

this can still fuck up your account

quartz kindle
#

then dont mind if i hack your bot lol

#

and make it spam your server

earnest phoenix
#

alright

#

regen it asap

#

i regenerated

#

kk

uneven wyvern
#

good

earnest phoenix
#

now lets try this again

#

wdym regen it asap

#

what is asap

#

People can do bad stuff with it

#

as soon as possible

crimson vapor
#

as soon as possible

earnest phoenix
#

i am new in making discord bot okay?

#

i regenerated it

uneven wyvern
#

Ok

earnest phoenix
#

now what is problem in my bot

uneven wyvern
#

Idk

#

Im Not with C#

earnest phoenix
#

so no solution?

modest crane
#

@earnest phoenix your bot prefix is "+"

#

use "+test"

earnest phoenix
#

i used it

#

and it says unknow command

#

on console

#

but i putted it

#

sec

#

any solutions?

#

btw when i regenerate token it is same

#

wait a sec

#

yea

#

i fixed it