#development

1 messages · Page 1421 of 1

twilit geode
#

night t i m

#

from monty python...

queen hamlet
#

Nvm I'm not making embed, it just like a design anyways.

#

I wanna make it that the bot DM's a welcome message.

#

.createDM right?

twilit geode
#

its probably a good idea to get embeds down, they make your bot look alot nicer

twilit geode
#

idk i dont do dm stuff

queen hamlet
twilit geode
queen hamlet
twilit geode
#

?

queen hamlet
#

Do I just do .createDM before the code?

twilit geode
#

message.author.createDM()

sudden geyser
#

<User>.createDM(...)

queen hamlet
#

Does this work:
client.on("message", message => { if (message.content === "~dm-me") { message.author.createDM() message.channel.send("🥛 | Hello!") } })

#

Lemme try

twilit geode
#

hang on

queen hamlet
#

message.dm.send?

twilit geode
#
client.on("message", message => {
  if (message.content === "~dm-me") {
    message.author.createDM("🥛 | Hello!")
  }
})
#

i think

#

idk cant test it rn to be sure its right

amber thistle
#

i thought to dm the author u do message.author.send()?

twilit geode
#

createDM is a thing apparently

amber thistle
#

oh

queen hamlet
#

Or is createDM outdated cause it does not work-

valid grotto
#

If you want to send a message, just use author.send

sudden geyser
#

You create the DM, then you send a message in the returned DMChannel

twilit geode
#

ah

#

big brain

amber thistle
#

then theres no need to createDm u can just send

sudden geyser
#

So you must .createDM(), resolve the promise holding a DMChannel, and use that to .send("the message")

#

but yes, you can directly send to the user instead with <User>.send() I believe

twilit geode
#

note to self: "dont give advice before testing code"

valid grotto
#

Just use .send, if you have no purpose of resolving the DMChannel.

amber thistle
twilit geode
#

shut it

queen hamlet
#

Doesn't work, thanks tho.

twilit geode
#

i main java, not js

sudden geyser
#

What doesn't work about it.

twilit geode
#

is still not convinced its not glitch

#

whats your error code hughh

queen hamlet
twilit geode
#

in your console...

stark widget
#

wait i got it

#

@queen hamlet u want to dm the user, right?

valid grotto
stark widget
#

use, message.author.send('your message')

#

and i dont think createDM exists

queen hamlet
#

client.on("message", message => {
if (message.content === "~command-name") {
message.author.send("Hello!")
}
})

twilit geode
pale vessel
#

author

stark widget
#

¯_(ツ)_/¯

sudden geyser
#

authors

#

no s!

queen hamlet
#

There.

#

Omg worked!!

#

TY!!

stark widget
#

np

valid grotto
queen hamlet
#

I can at least be friends with a bot now

south aspen
#

lmao

twilit geode
#

that took far too long for a large group of devs to figure that out lol

stark widget
#

ohk

queen hamlet
#

Can a bot send you a fr lmao.

stark widget
#

¯_(ツ)_/¯

zenith gazelle
#

I have had an issue with text not displaying as "No" when I reply with "n" and I found out after 3 days of looking for the answer (not priority but it bothered me) I put an extra equals sign ;-;

    if x == "y" or x == "yes":                           finalresponses[i] = "Yes"
     elif x == "n" or x == "no":
           finalresponses[i] == "No"```
south aspen
twilit geode
#

bloop is that py

zenith gazelle
#

yes

#

why?

twilit geode
#

oh

#

nvmd

zenith gazelle
#

oh I though you were boutta tell me to just use a dictionary

twilit geode
#

i was..

zenith gazelle
#

I was gonna punch someone

twilit geode
#

lol

zenith gazelle
#

alright we gonna punch someone

twilit geode
#

uh

#

hek

#

can i punch my bot?

valid grotto
#

Equal operator also fucks me up sometimes, no worries 😂 @zenith gazelle

zenith gazelle
#

sure

twilit geode
#

it corrupted its own sd card thanks to pm2

queen hamlet
#

Also, how do I make it that you can do a command with any capitalization?

twilit geode
#

.toLowerCase()

queen hamlet
#

?

valid grotto
#

.toLowerCase()

sudden geyser
twilit geode
#

you have to take the input through .toLowerCase()

zenith gazelle
#
exampledict = {"y" : "Yes", "yes" : "Yes", "n" : "No", "no" : "No"}
finalresponses[i] = exampledict[x]``` happy? @twilit geode
stark widget
#

@queen hamlet .toLowerCase() is a function

queen hamlet
zenith gazelle
#

I like .lower() because it makes everything lowercase

sudden geyser
#

wot

pale vessel
#

Python

zenith gazelle
#

oh

stark widget
zenith gazelle
#

you arent using python

valid grotto
twilit geode
#

i just dont like py dictionary

#

at

#

all

#

vomit

sudden geyser
#

why

stark widget
#

so if the message was "Hi" it will become "hi"

sudden geyser
#

they're like { key: value } but make sense

twilit geode
#

ik

#

its just too much, little space

queen hamlet
#

client.on("message", message => {
if (message.content.toLowerCase ("fuck")) {
message.author.send("Okay.")
}
})
Does that work?

#

Lemme try.

stark widget
#

yep

sudden geyser
#

try it out and see

#

hint: it won't work as expected

stark widget
#

so if someone send the f word in caps

#

it will

queen hamlet
#

Worked! Thank you!

twilit geode
stark widget
#

np

sudden geyser
#

Menin just so you know, that doesn't work correctly

zenith gazelle
#

isn't there a bot command for tryitoutandsee?

queen hamlet
#

Now whenever I tell my bot to f it says okay.

zenith gazelle
#

wrong server nvm

sudden geyser
#

I know there's a site for it

stark widget
#

like i use it alot

sudden geyser
#

no it doesn't.

zenith gazelle
#

yeah, another server I am in has a command that sends the link

stark widget
#

in js it does

sudden geyser
#

no it doesn't

twilit geode
#

@queen hamlet did you go through the discord.js docs tutorial?

sudden geyser
#

message.content.toLowerCase() does not take any arguments, so the "fuck" argument does nothing.

#

It also doesn't check if the content is equal to it

queen hamlet
#

I tested the thing and people think I am mad at them

sudden geyser
#

So in reality it's doing implicit condition checking to see if the string is really empty

#

type anything else and it triggers the command

pale vessel
#

That's going to DM you "Okay." on every message

sudden geyser
#

in fact it'll probably cause an infinite loop omegalul

stark widget
#

no

sudden geyser
#

You can't explain it because it doesn't work.

stark widget
#

IT WORKS

sudden geyser
#

prove it!

twilit geode
#

@sudden geyser how high are YOU

stark widget
#

i have been using it in 2 bots now

zenith gazelle
#

I am no js expert but looks like it would work to me

stark widget
#

and have never found a single problem

queen hamlet
#

Whenever I say somethign with "F, u, c, k" it DM's me.

twilit geode
#
 const commandName = args.shift().toLowerCase();
``` is what i use @sudden geyser ...
stark widget
#

any js bot dev can say that .toLowerCase() works

pale vessel
#

toLocaleLowerCase() 😎 /s

zenith gazelle
#

/s

queen hamlet
#

Whenever I say something with f, u, c, k it DM's me someone help.

stark widget
#

hmm

twilit geode
#

make sure its starts with only

queen hamlet
#

Whatever I say warns me now.

stark widget
#

@queen hamlet do if(message.content.toLowerCase() === "fuck")

pale vessel
#

Did you not listen

sudden geyser
# twilit geode <@!345539839393005579> how high are YOU

I'm on the third floor in my room if that's high for you 😎

As I said, if (message.content.toLowerCase("fuck")) {...} is wrong for several reasons:

  • .toLowerCase takes no arguments.
  • You're not checking if the result of making it .toLowerCase is equal to the command you want to compare it with.
  • You're using implicit condition checking, where it'll try converting the value to its truthfully value.

It causes an infinite loop because it passes the if condition, and sends a message. Then, it triggers the message event, evaluates the if condition (which is always true because it's wrong), and does the same thing over and over.

stark widget
#

that 3 equals will work

stark widget
#

@sudden geyser dude

#

thats not how .toLowerCase() works

pale vessel
#

He knows better than you

stark widget
#

who

pale vessel
#

Don't act ignorant

sudden geyser
#

Then please educate me on how it works.

twilit geode
#

also

stark widget
#

u only need to do let msg = message.content.toLowerCase() and then logging msg would show the message sent in lower case

twilit geode
#

you have three floors?

#

jeez

zenith gazelle
#

I was surprised when I joined and the server wasn't like this, I thought it might be tolerable today, guess I was wrong. This is my queue to head out Salutaba

queen hamlet
#

I'm spamming "fuck" in my test server rn.

pale vessel
#

fuck

sudden geyser
#

Head out before you lose your sanity

stark widget
sudden geyser
stark widget
#

oh

sudden geyser
#

when it's simply not

stark widget
#

i didnt see that

#

sry

#

*mistakes happen

sudden geyser
#

alright

stark widget
#

sry

valid grotto
#

🤦‍♂️

queen hamlet
#

now last step to finish anti-swear.

#

How do I make it delete it?

#

Like when I say "fuck" it deletes my message and dm's me saying not to swear.

pale vessel
#

You can use <message>.delete();

queen hamlet
#

I put message to delete <here> ?

sudden geyser
#

you put your instance of <Message> here

#

the message event receives a parameter that is an instance of Message

#

You named it message, so instead of <Message>, you put message.

#

If you named it msg, you'd use msg instead.

queen hamlet
#

client.on("message", message => {
if(message.content.toLowerCase() === "shit")
message.author.send("You have been warned. Do not swear.")
<shit>.delete();
}
)
There is an error.

#

Unexpected token

valid grotto
#

Christ

pale vessel
sudden geyser
#

Hughh may I ask if you have a good understanding of JavaScript

pale vessel
#

@sudden geyser I think your way of explaining might confuse some beginners

queen hamlet
#

client.on("message", message => {
if(message.content.toLowerCase() === "shit")
message.author.send("You have been warned. Do not swear.")
<message>.delete("shit");
}
)

?

sudden geyser
#

yeah I know, but I think it's better to get the obstacle out of the way first

pale vessel
#

Understandable

valid grotto
#

Beginners do like to copy code without actually filtering what is being explained

rare moss
#

$help

sudden geyser
#

Hughh you may want to spend some time learning JavaScript as a language.

pale vessel
#

Like Lite said, you need to replace that <message> with what parameter you defined for the message callback. You defined it as message so put message instead of <message>

sudden geyser
pale vessel
#

That should be pinned if it isn't already.

queen hamlet
#

Okay

rare moss
#

shouldn't you always have a grasp on the basics of a language before you start a big project?

jaunty surge
#

@earnest phoenix I forgot to say thank you to you, thank for helping me!

sudden geyser
#

Yes, but you can learn a lot from working with a project.

#

Discord bots usually attract beginners because they're learning to code only because of it, so some want to get directly in action and skip the learning bits.

#

Hence, you get this channel's state.

ivory seal
#

how do i make it permant like doesn't crash during a restart?

rare moss
#

@sudden geyser quick question, how do i get my topgg token for my bot lol

#

im reading the docs for the API and I don't know where to get mytoken

#

am I dumb?

sudden geyser
#

go to the dashboard of your bot or something

#

let me find it

rare moss
#

tysm

sudden geyser
rare moss
#

YOOO

#

you are a god

#

actually insane

haughty bough
#

Hello. Does anyone know any module that allows me to search for videos on Youtube and that has a safeSearch function?

sudden geyser
#

imperial 🕺

#

Joao why not use YouTube's public API?

haughty bough
#

This API has a limit :/

#

Besides relying on a google token

sudden geyser
#

Your alternatives are probably going to be using YouTube's API, which is going to have its limits as well. I don't see how that'll work unless you go for something like scraping.

haughty bough
#

I was using ytsr, but bugs often happen. I think the way will really be to use the YouTube API

#

Thank you!

ivory seal
#

is there any way to perform mute without a timeout?

#

because timeout's would go every restart

zenith knoll
#

How do i check if a member can ban another member? So one cannot use the ban cmd to ban someone higher than the cmd sender

pliant orbit
#

how to install ffmpeg on discord.js

zenith knoll
#

...

#

npm i ffmpeg i assume

pale vessel
#

You have to actually install ffmpeg on your machine

#

That npm package is not needed

pliant orbit
old crane
#

is googletrans api drunk?

pale vessel
#

Probably

#

What's wrong with it?

vivid schooner
#

It works sometimes and other it doesn’t

#

I use a try catch in a while loop until there where no more error but somehow sometimes it still doesn’t work GWhurpyShrug

earnest phoenix
#

How to add 2 workers in Procfile?

rugged terrace
#

How many times can a bot edit a message?

#

Is there a limit?

earnest phoenix
#

@rugged terrace can you help me?

rugged terrace
#

Sorry, I don't know anything about that

valid grotto
rugged terrace
#

I'm having trouble editing a message every 30 seconds or so

#

Doesn't seem to be updating

valid grotto
#

Shouldn't really be a problem, try logging it?

rugged terrace
#

I've tried catching errors, how else would you log it?

#

ahh actually

#

i'll have a look

#

looking at the documentation is always a good idea tbh

earnest phoenix
pale vessel
#

There is no limit but there are ratelimits

rugged terrace
#

This is going every 30 seconds, might that be ratelimited?

valid grotto
#

It shouldn't

rugged terrace
#

Strange

earnest phoenix
#

How to add 2 workers in Procfile?

rugged terrace
#

@earnest phoenix have you tried searching it up

valid grotto
#

Will 1 minute intervals work? @rugged terrace

rugged terrace
#

I'll have a go

#

Thanks for your help so far anyways

queen hamlet
#

if (command === '~store') {
const testEmbed = new Discord.RichEmbed()
.setColor(0xed4a96)
.setTitle('Store')
.setDescription('Store')
.setAuthor(message.author.username)
.setFooter('Store')

Someone help me fix the error to this.

#

Making am embed.

twilit geode
queen hamlet
#

if (command === '~store') {
const testEmbed = new Discord.RichEmbed()
.setColor(0xed4a96)
.setTitle('Store')
.setDescription('Store')
.setAuthor(message.author.username)
.setFooter('Store')
try {
message.author.sendEmbed(testEmbed);
} catch {
message.channel.send("Sorry <@{message.author.username}> I cannot message you, make sure your DMs are turned on.")
}

}
I need help with this.

#

There are errors.

rustic nova
#

We can't read minds

queen hamlet
#

command and message

rustic nova
#

Yeah but what is the error message

queen hamlet
#

"message is not definded".

#

"command is not definded".

pale vessel
#

Did you copy pasted that from somewhere?

queen hamlet
#

No.

#

I just copied :>

#

I typed it tho

rustic nova
#

message is not defined, command is not defined

#

meaning you need to change both message.author.. and message.channel with the variables that are associated with your onMessage

queen hamlet
#

I fixed it...

#

client.on(message === '~store') {
const testEmbed = new Discord.RichEmbed()
.setColor(0xed4a96)
.setTitle('Store')
.setDescription('Store')
.setAuthor(message.author.username)
.setFooter('Store')
try {
message.author.sendEmbed(testEmbed);
} catch {
message.channel.send("Sorry <@{message.author.username}> I cannot message you, make sure your DMs are turned on.")
}

}
)
This is what it looks like now ^^

pale vessel
#

That's...

queen hamlet
#

There is a new error

rustic nova
#

what's the new error

queen hamlet
#

With " { "

#

The first one.

pale vessel
#

This is completely invalid

rustic nova
#

you need to learn how to syntax correctly, get into how to use discord.js first

pale vessel
queen hamlet
#

Huh?

twilit geode
#

@queen hamlet you are looking at code from old videos

queen hamlet
#

Oh.

#

It is from April 27 2020

twilit geode
#

go through that tutorial

#

it has all da shit

queen hamlet
#

Invalid

rustic nova
#

also, you seem like you partially just jumped into it, i suggest reading documentations instead of youtube videos

valid grotto
marble juniper
#

youtube videos are a bad way to learn to make discord bots

pale vessel
#

Best way to learn is to read docs

#

You won't have to worry about it being outdated

marble juniper
#

yes

#

the discord.js guide above is already updated to the latest version of discord.js

#

also it has other stuff like an easy cooldown system and so on

#

very useful guide

valid grotto
queen hamlet
#

Yep, thanks.

rustic nova
#

i just suggest not jumping right into it

twilit geode
rustic nova
#

true, but not jump in with outdated things

twilit geode
#

true

#

again

#

thats how some people learn lol

marble juniper
#

don't use youtube tutorials for discord bots in the first place lol

valid grotto
#

You can ask all you want here, we'll greatly help but we can't spoonfeed you on basic stuff that you can easily find on docs

marble juniper
#

yes

queen hamlet
#

It's just annoying to not be able to find things.

marble juniper
#

just use the discordjs.guide

twilit geode
#

you can

#

simple error searching and general coding knowledge go a long way

valid grotto
queen hamlet
#

Okay :)

earnest phoenix
#

hello

#

i am creating a currency system in my bot

#

i coded a daily

delicate shore
#

my new package is breaking records of my previous packages

earnest phoenix
#
  if(!message.content.startsWith('m!'))return;  

  let user = message.author;

  let timeout = 86400000;
  let amount = 200;

  let daily = await db.fetch(`daily_${message.guild.id}_${user.id}`);

  if (daily !== null && timeout - (Date.now() - daily) > 0) {
    let time = ms(timeout - (Date.now() - daily));
  
    let timeEmbed = new Discord.RichEmbed()
    .setColor("#FFFFFF")
    .setDescription(`:Cross: You've already collected your daily reward\n\nCollect it again in ${time.hours}h ${time.minutes}m ${time.seconds}s `);
    message.channel.send(timeEmbed)
  } else {
    let moneyEmbed = new Discord.RichEmbed()
  .setColor("#FFFFFF")
  .setDescription(`:Check: You've collected your daily reward of ${amount} coins`);
  message.channel.send(moneyEmbed)
  db.add(`money_${message.guild.id}_${user.id}`, amount)
  db.set(`daily_${message.guild.id}_${user.id}`, Date.now())


  }
};```
#

but when I do it, doesnt work

#

and my main - ``` bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
let prefix = config.prefix
let messageArray = message.content.split(" ");
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
let commandfile;

if (bot.commands.has(cmd)) {
  commandfile = bot.commands.get(cmd);

} else if (bot.aliases.has(cmd)) {
commandfile = bot.commands.get(bot.aliases.get(cmd));
}

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

try {
commandfile.run(bot, message, args);

} catch (e) {
}}
)})```

sudden geyser
delicate shore
#

I did today

#

Right now

earnest phoenix
#

can anyone help?

earnest phoenix
#

when i run the command, nothing happens

#

Hmmmm

#

there is an error

#

Can i see the code?

#

yes its above

rustic nova
#

add a debug line, something like console.log("command") on the beginning of the message

earnest phoenix
#

ok

#

thx

#

i will try

#

why that return after the startsWith?

#

if it doesnt start with the prefix

#

._.

#

then ignore

#

Oh i actually saw the !

#

?

#

Vut

#

But

#

o

#

nvm

#

ic ic

#

That line is not neccesary

#

o yeah i can put it in the main...

#

If the content of the message doesn't starts with the prefix and the command it will ignore without that line.

#

So that line is not neccesary.

#

And the embed builder

young flame
#

uh i have a quuestion

earnest phoenix
#

Is new discord.MessageEmbed()

#

Not richemned

#

Embed

#

That was removed

young flame
#

is there a way to have like the bot respond to both a @ mention and the regular prefix?

earnest phoenix
#

M

#

Idk

young flame
#

@solemn latch dev senpaii

earnest phoenix
#

I hope yes, bc my bot reponds to mentions

#

But with prefix idk

#

use a or (||) statement?

solemn latch
#

yo

earnest phoenix
young flame
#

i have my prefix in a .env file H

earnest phoenix
#

for the mentions

young flame
#

it would work for .env to?

#

@earnest phoenix

earnest phoenix
#

message.members.mentions.first();

young flame
#

oopS

#

thats for users

earnest phoenix
#

when

#

Ik that's for PM

#

i had no idea...

#

PM

#

yes

#

You create a variable with that value

#

ik

#

does it have to be const?

#

bc i did let

#

Like this: var user = message.members.mentions.first();

#
  .setColor("#FFFFFF")
  .setDescription(`**${user}'s Balance**\n\nPocket: ${bal}\nBank: ${bank}`);
  message.channel.send(moneyEmbed)```
#

Let, var, const

#

i dont need mentions

#

my embed

#

To display a selected user you must use mentions

#

oooooo

#

ic ic ic

young flame
#

ike this

earnest phoenix
#

That's Python?

pale vessel
#

that won't work

young flame
#

oh

pale vessel
#

You need to define that in your code

earnest phoenix
pale vessel
#

otherwise the prefix is literally that

young flame
#

my bot prefix?

pale vessel
#

Yes

young flame
#

ok

#

brb

earnest phoenix
young flame
#

@pale vessel i also have a command to change the prefix to

#

so how would i structure it

#

like a normal prefix or

pale vessel
#

Do you have a database?

earnest phoenix
#

ooo

young flame
#

uh yes

earnest phoenix
#

@earnest phoenix use this let user = message.members.mentions.first();

pale vessel
#

Show the prefix from the database if exist. If not, show the default prefix

earnest phoenix
#

ok

#

sure

pale vessel
#

That's a member, not a user

pale vessel
young flame
#

oK

pale vessel
#

You should avoid it though since it could be corrupted easily

earnest phoenix
pale vessel
#

Why would it

earnest phoenix
#

he's trying to display a target user into an embed

pale vessel
#

Yeah and why would message.author be undefined?

sudden geyser
#

when you release updates for a package, a lot of scripts are usually installing it

earnest phoenix
pale vessel
#

Package is not popular, I guess... sadge

sudden geyser
#

so the number of installs you get don't truly represent the number of users who saw your package and decided to try it for themselves

earnest phoenix
#

I said probably, idk what's the all code, and he doesn't use user.tag so it wouldn't display something

sudden geyser
#

something I think Xetera was telling you before

earnest phoenix
#
  console.log(`Daily run successfully!`)

  let user = message.members.mentions.first();

  let timeout = 86400000;
  let amount = 200;

  let daily = await db.fetch(`daily_${message.guild.id}_${user.id}`);

  if (daily !== null && timeout - (Date.now() - daily) > 0) {
    let time = ms(timeout - (Date.now() - daily));
  
    let timeEmbed = new Discord.MessageEmbed()
    .setColor("#FFFFFF")
    .setDescription(`:Cross: You've already collected your daily reward\n\nCollect it again in ${time.hours}h ${time.minutes}m ${time.seconds}s `);
    message.channel.send(timeEmbed)
  } else {
    let moneyEmbed = new Discord.MessageEmbed()
  .setColor("#FFFFFF")
  .setDescription(`:Check: You've collected your daily reward of ${amount} coins`);
  message.channel.send(moneyEmbed)
  db.add(`money_${message.guild.id}_${user.id}`, amount)
  db.set(`daily_${message.guild.id}_${user.id}`, Date.now())


  }
};``` alright this is my entire daily code
#

it does nothing

pale vessel
#

Also, you should fallback to message author if that doesn't exist

earnest phoenix
#

wdym

valid grotto
#

If anyone here is familiar to sql, will having a query inside a query causes any delays/problems?

sql.query(`SELECT xx1`), (err, result) => {
  sql.query(`SELECT xx2`), (err, res) => {
    sql.query(`SELECT xx3`), (err ress) => {
    })
  )}
)}

sql is a MySQL pool getconnection

young flame
#

should make it 'your new guild prefix' but H

earnest phoenix
#

?

earnest phoenix
young flame
#

uh ig

earnest phoenix
#

Alrigut

#

Alright

#

You must use a DB

#

With a DB you can log these prefixes and save that prefixes for each server

#

ye

#

quick.db is what i use

#

megadb is better, or mongoose.

sudden geyser
#

You can use JSON to accomplish this task.

earnest phoenix
#

oh

young flame
#

i used it before

sudden geyser
lusty quest
#

json works but is bad practise

old latch
#

is this about custom prefixes?

young flame
#

i just want to know if they change the prefix will it change the other one

lusty quest
#

depends on how you save the prefix

pale vessel
young flame
#

quick.db is bad because if one thing goes wronng you have to reset the entire DB

pale vessel
#

It can't be corrupted, I think since it uses atomic file writing

lusty quest
#

if you make a json array within the json and use the guildID as key it will work

sudden geyser
#

JSON is looked down upon because of the use case in this situation. Think of CLI apps where you have a config.json file. It's completely normal, but as a Discord bot will have an arbitrary activity range, people prefer to use actual databases (SQLite, Postgres, etc.)

valid grotto
valid grotto
#

Asked twice on SO, still no answers.

pale vessel
#

My goodness, callbacks

young flame
#

that moment you have the app and website open

young flame
#

like the prefix and guild id?

#

but that would change all the prefixes

#

i want it to just change one

lusty quest
#
{
"Guild1.id":{
  "prefix": "!"
},
"Guild2.id":{
"prefix":"?"
}
}
``` @young flame something like this
sudden geyser
#

I don't see how running three queries would be giving you performance issues (especially for minutes). Then again, I don't know what database you're using, and the one you're using, I'm not familiar with (MySQL I assume).

young flame
#

i know how to store iT

#

i know how to store the keys ect

lusty quest
#

this will if used right only change the prefix for one guild

young flame
#

i just want to know is there a way to change ONE prefix

valid grotto
# sudden geyser I don't see how running three queries would be giving you performance issues (es...

Correct, MySQL.

And if anyone's wondering my sql pool handler :

let sql = {};
sql.query = function(query, params, callback) {
pool.getConnection(function(err, connection) {
 if(err) { 
  if (callback) callback(err, null, null); 
  return; 
}

connection.query(query, params, function(error, results, fields) {
  connection.release();
  if(error) { 
    if (callback) callback(error, null, null); 
    return; 
  }
  if (callback) callback(false, results, fields);
     });
   });
 };
young flame
#

the default prefixes is + and mention the bot

pale vessel
#

Please wrap it with promise

young flame
#

i want to know if someone doesn't like the + they can change that

#

but the mention stays

lusty quest
#

yes. but i would have to look it up first bcs i never used json as a storage bcs its slow, easy corrupted.

young flame
#

brb

restive furnace
#

SQLite is what I use

lusty quest
#

any type of proper db is already better than json

#

json is fine for static configs but not for dynamic stuff or if it get written a lot on it

young flame
#

what would be a goood prefix

#

for the bot

#

instead oof +

restive furnace
#

++

slender thistle
#

Depends on the bot's name

#

Though, + is quite simple

earnest phoenix
#

a mix of two?

#

like !$

slender thistle
#

imo that's inconvenient in a way

earnest phoenix
#

ye

#

but its unique...

#

also letters

#

i feel like dank memer is the only one that actually uses letters

young flame
earnest phoenix
#

like pls

lusty quest
#

use a insult as prefix. the bot will be non functional at some servers that use word filters.

earnest phoenix
#

??/??

young flame
#

hmm

#

i kinda like +

#

+?

#

or like

#

idk

#

probs just gonna use !

earnest phoenix
#

maybe rs

young flame
#

oo

earnest phoenix
#

if u want to get ur bot on top.gg, i think u need to have an uncommon prefix

rustic nova
#

nope

lusty quest
#

they stopped adding bots bcs of a limitation

young flame
#

i nedeed ideaS

rustic nova
#

It never had any general impact on approval, it just got muted here in this discord

lusty quest
#

^

young flame
#

h

#

which one should i use

lusty quest
#

!r ?

young flame
#

not that

#

the photos

#

bot pfp

tardy hornet
#

i want to put in the thumbnail the bot avatar and i forgot howw

#

.setThumbnail(``)

young flame
#

nvm

stark widget
#

@tardy hornet client.user.displayAvatarURL()

slender thistle
earnest phoenix
#

yes

slender thistle
#

Basically whatever a numpad would have prepended with r

earnest phoenix
#

??

twilit geode
#

hey how do you convert from int to char in js

lusty quest
#

number to string?

twilit geode
#

uhh

#

is there no char in js?

lusty quest
#

never heard of it.

twilit geode
#

oh god

#

mk

#

nvmd

lusty quest
#

int = number char = string

#

you can use .toString() to make a number a string

twilit geode
#

in java char is a primative data type that is a single ASCII character

young flame
#

how would i make a command

#

send a message then after it sent the message check if it did

hollow sedge
#

@twilit geode you know there's a Java lib for discord right?

twilit geode
young flame
#

so it like sends one message and then sends the other one

#

it is?

twilit geode
#

yes

#

hang on

young flame
#

i spent 5 hours-

twilit geode
#

i saw a video over it the other day

lusty quest
#

and then send again a message?

young flame
#

no like

#

the bot sends hi

#

then it is like oh i sent hi

#

and then says hi again

lusty quest
#

there are 2 ways, use a message event that doesnt listen to your prefix or use message collectors

young flame
#

mhm

#

whats a message collector?

twilit geode
lusty quest
young flame
#

lmao

#

30k results

#

of me typing in development

#

thats how slow i am

lusty quest
#

wtf i have 5k results and im now for almost a year here

waxen obsidian
#

Where can I get the DBL WEBHOOK password

young flame
#

it took 4 hours to fix one line of code with 3 people helping me

lusty quest
#
client.on("message")(msg){
if(msg.toLowerCase().contains("hi")) return msg.channel.send("hi")
}
``` @young flame this does more or less what you want to do (but its not really good practise to use a 2nd listener to the message event)
slender thistle
ionic shard
#

this maybe the most annoying question but does someone knows how can i get real time data from api?

To be more clear...
I'm trying to make an embed when a new transaction takes place in a specific wallet (BTC)

Easy solution is to keep looping on the api to find any new transactions. But that would be not good if i have a lot of address to look through....

I am trying to make an event that triggers when a new transaction takes place so i can notify the use....

lusty quest
#

use a timer to shedule a api call ever few minutes. unless the API you use got a client that can spawn events you can listen on

ionic shard
#

im using this api
https://sochain.com/api#realtime-balance-updates

lusty quest
earnest phoenix
lusty quest
ionic shard
#

aw ok

sick sluice
lusty quest
#

did you use any extension that apply a darkmode?

#

like Darkreader?

sick sluice
#

mm no

restive furnace
#

just change the css color inside dev console

young flame
#

wait

#

cant i use a function?

lusty quest
#

?

young flame
#

like

#

once it sends hi set it like TRUE and the call a function to see if it was sent

lusty quest
#

but why?

earnest phoenix
#

I'm confused, what are you trying to do moon

young flame
#

like

#

send a message

#

check if it sent the message

#

then send the other one

lusty quest
#

you can use .catch() to catch an error if the message fails to be sended

earnest phoenix
#

You don't have to check it was sent

lusty quest
#

or a try/catch block

earnest phoenix
#

Because if it didn't get sent it would return a promise rejection

young flame
#

its not a error

lusty quest
#

if the message fails to be send you get an error

#

or did you want them in a certain order?

young flame
#

yes i got no errors

#

yes

lusty quest
#

then use async code

young flame
#

it warns them then mutes

#

ig

#

why would i async it?

lusty quest
#

then it will send one message and awaits until its done then it sends the next one

earnest phoenix
#

messages returns a collection of messages

young flame
#
const filter = m => m.content.includes('discord');
const collector = message.channel.createMessageCollector(filter, { time: 15000 });

collector.on('collect', m => {
    console.log(`Collected ${m.content}`);
});
#

would that work

lusty quest
#

?

young flame
#

but i have it filter the word i want then after it collects it run the other functions

#

like

lusty quest
#

i have no idea what you want to do. the stuff you write here is quite random

earnest phoenix
#

whatNOyoucantdothis What is she trying to do, [Confusion]

young flame
#

i told you

#

?

tardy hornet
#

what is the dbl website?, not the top.gg

earnest phoenix
#

Are you trying to sent stuff in order but like, what else?

lusty quest
#

yes but i dont get it. you want the bot to react to hi, then you want to send messages in a certain order then you are again at message collectors that are somewhat connected to the bot reacting to hi

young flame
#

i have it set up

lusty quest
young flame
#

so it sends the warning message

tardy hornet
#

and stuff

lusty quest
#

top.gg used to be dbl but got rebranded

young flame
#

but after that i want it to check to see if it sent the warning message and mute them

lusty quest
#

so you want to add a new bot?

young flame
#

IsWarned is what i want to set it as

#

well i was

earnest phoenix
#

"if it sent the warning message"

lusty quest
#

so you want to see if someone spams?

young flame
#

sigh

tardy hornet
young flame
#

i already can

#

listen

#

once they spam

#

the bot

#

send a warning

#

after the warning

#

it should mute them

lusty quest
#

we have to make it step by step bcs your informations are a bit consufsing

young flame
#

but it doesnt

#

does that make since?

lusty quest
#

so it fails to set the Mute Role

young flame
#

it fails to call the entire mute function

lusty quest
#

the mute function is only for voice

earnest phoenix
#

mute function?

lusty quest
#

if you want to mute text channels you need a role

young flame
#

it

#

mutes them

#

LIKE THE DAMN MUTE COMMANDS

#

god

lusty quest
#

yes. but discord doesnt offer any buildin function to mute users in Text Channels

earnest phoenix
#

whatNOyoucantdothis Wtf is happening

young flame
lusty quest
#

did you got the role thing sorted out

young flame
#

stressful your not listening

#

its not muting them in a voice it gives them a role

lusty quest
#

this is what i wanted to know lol

young flame
#

if you look the mute function or part only runs if they are warned

#

its not running cause its not setting them as warned

#

i just want to know how to set them as warned

lusty quest
#

a quick reminder, dont use a timeout for temporary muting people

#

i can recomend using redis for it

earnest phoenix
#

Just set a boolean to a database sort of thing, if it's true then mute

young flame
#

im using maps

earnest phoenix
#

It should still work

lusty quest
#

but you still store it somewhere right?

young flame
#

i want to store it using maps

lusty quest
#

bcs maps and timeouts are not persistent over restarts

young flame
#

i know that

#

thats why im using maps

#

i dont need them permanently saved

stable nimbus
#

Something changed on me and I wasn’t ready for it, how do I define something when doing a randomNum sequence? Currently I’m getting an [object Promise] return when I should be getting an item. Here is the code:

young flame
#

it's temporary

lusty quest
#

so to be clear your isWarned function is never called right?

#

how do you execute it?

young flame
#

yes

#

iif iswarned checks to see if its true

#

if it is it executes the warning part

lusty quest
#

yes but something has to trigger it

young flame
#

THATS WHAT I ASKED

earnest phoenix
young flame
#

"how do i set it"

#

i said it

#

like 3 times

lusty quest
#

i would define it as a function

young flame
#

how

lusty quest
#

like ```js
function isWarned(userid){
//your code checking if the provided userid is warned
}

young flame
#

hm

lusty quest
#

then just call somewhere isWarned(userid)

young flame
#

i have it send the warning message

#

how-

#

what?

#

i just need to set it to true.

lusty quest
#

then set it true

young flame
#

like once it sends the warning message it is like IsWarned = true;

#

I DONT KNOW HOW TO SET IT TO TRUE

earnest phoenix
#

Just

#

Get them in the map

young flame
#

if i did i wold not be here rn

rustic nova
#

return true 4HEad

earnest phoenix
#

Set it to true

young flame
#

ok

#

like

#

TRUE;

#

or true;

earnest phoenix
lusty quest
#

lowercase

young flame
#

idfk how maps work

#

OH

#

ok

cinder patio
#

that's not related to maps

earnest phoenix
#
Warns.get(<ID>).isWarned = true```
young flame
#

what isnt

earnest phoenix
#

Yes, and to check if the user is warned

young flame
earnest phoenix
#
usersMap.get(<ID>).isWarned```
#

That's it

young flame
#

it took me 7 hours just to figure this out lool

earnest phoenix
young flame
#

put that

#

where i have IsWarned

earnest phoenix
#

Yes

lusty quest
#

if i had this speed i guess i would still try to figure out how to use ML.net

young flame
#

wtf is that

lusty quest
#

dont ask you wont get it

young flame
#

oh

#

ok

lusty quest
#

but its for Machine Learning with C#

young flame
#

i know c#

earnest phoenix
#

Machine learning on crack

lusty quest
#

why did you then write a bot in js?

young flame
#

i know alot of programming languages just retarted with functions

lusty quest
#

C# is more efficent in my opinion

young flame
#

it is

young flame
#

this bot is more of a fun build

earnest phoenix
#

Yes

young flame
#

i have a bot made in elixir that took 1 month to make

lusty quest
#

is it fun to figure out how to make a single function for 7 Hours?

young flame
#

thats me being sireous

young flame
#

then i can clown myself

stable nimbus
#

Okay. I’ll get to work, thank you Voltrex

earnest phoenix
#

Making a function for 7 hours

#

Omega

#

Kek

stable nimbus
#

Yes

young flame
#

once it took me 4 hours with 5 people helping me to fix one line of code

lusty quest
#

well sometimes you just cant see the issue, if im at this point i take a break and maybe get an idea later

young flame
#

yeah

earnest phoenix
#

The thing is, you shouldn't push yourself too hard while coding

#

If you can't get an idea of why your stuff doesn't work just take a break

lusty quest
#

had this the last time when ive made the multi language support for my bot. i use a Github repo for having the Translations open source and easy to merge if someone makes corrections or want to add a new translation.

young flame
lusty quest
#

i just need to restart the bot to get the latest language file loaded

young flame
#

uH

#

should i remove it?

earnest phoenix
#

Why

#

An

young flame
#

idk

earnest phoenix
#

Arrow

lusty quest
#

why a lambda function?

young flame
#

oh isnt that how you call it?

lusty quest
#

you can use it but you need to tell what you want to get

earnest phoenix
#

They can be called an arrow function or lambda function

young flame
#
if((a) => {
});
earnest phoenix
#

Tf

#

That's cursed

young flame
#

idk

lusty quest
#

this is not how they work in js

young flame
#

so remove the arrow function?

earnest phoenix
#

Just remove =>

young flame
#

ok

#
usersMap.get(message.author.id).isWarned = true;
#

shouldn't get be set

lusty quest
#

everything before = is to fetch the user

cinder patio
#

Maybe you wouldn't have 30k messages in this channel if you actually took your time to learn the language you're using? Just a thought

young flame
#

ohh

#

ok

#

taking a break

#

started at lets see

#

3pm it is 2 am

earnest phoenix
#

It should be

usersMap.set(<ID>, {
isWarned: true
})``` if they're not in the map
young flame
#

ok

earnest phoenix
#

just asking: how can we use css in top.gg?

weak parrot
#

Using the <style> tag within your long description. Below is just example

<style>
body {
  background-color: black;
}
</style>
earnest phoenix
#

ok

#

it works

#

thx

young flame
#

it workS

lusty quest
#

you spammed on a server and the bot sends a DM?

young flame
#

nope

#

i spammed on my test server

sour oxide
young flame
#

and it muted me but i set the timeout for 10 seconds to test it

rustic nova
young flame
#

now the timeout is 20 minutes

#

cause it workS

lusty quest
#

i still would recomend using something like Redis to temporary store the muted users. if your bot mute someone and a few seconds after it restarts the user will stay perma muted

young flame
#

it only resets when the bot is turned off and on right

#

but if the bot is always on it wont reset

lusty quest
#

(you can get a free redis server and it emits a event if a entrys ttl runs out) if your bot restarts for some reason its broken

#

like even apply an update to break it

young flame
#

mhm

fallow vapor
#

is possible to .hasVoted() return also the left time to vote again?

lusty quest
#

just get the current timestamp + 12 hours iirc

young flame
#

pog bro

#

making a bot called roses

#

@lusty quest oh and

#

is there a way to make a filter for mentions and invites?

#

like if there not spamming messages but invites or spamming a role or user mention

lusty quest
#

you can use regex to match all urls or certain urls

#

and mentions is also relatively easy

young flame
#

oH

#

how would you like put it in a map though?

steel drum
#

i assume the library you are using automatically stores mention data

young flame
#

im using maps to store each message

#

i want to make a filter so i can use my regex for mentions to filter the messages out

#

so it isnt just like oh there spamming instead of oh there spamming mentions

steel drum
#

for example for discord.js you can do ```js
const users = msgObject.mentions.users;
const guildMembers = msgObject.mentions.members;
const allMentionsInGeneral = msgObject.mentions;

lusty quest
#

you couls use regex for both urls and mentions

#

it has pros and cons tho

fallow vapor
#

I am currently doing something like that, I will set a conf that a limit of mentions then use message.mentions.members.size also you can include the roles or channels mentions

sour oxide
#

please help i can't get my bot to work without admin perm

young flame
#

how would you even implement it

#

in the code

lusty quest
#

@sour oxide what stuff did you added?

steel drum
#

if you're storing the messages in a map, the mentions will be stored with it..

#

i dont see why they wouldnt be

young flame
#

oh

#

so no filter neeed?

#

i have a anti message spam command and a anti mention spam one

earnest phoenix
#

what did they add in new version of discord.js?

steel drum
#

you can check to see if there are any mentions

young flame
#

how would you do that?

sour oxide
south falcon
#

hi

lusty quest
#

manage channels permission

sour oxide
#

yes i tried that but it didn't work

lusty quest
#

and probably send messages possible manage messages

steel drum
#

heres the documention

young flame
#

ok

lusty quest
#

also the role of the bot has to allow the creation of Channels

steel drum
#

@sour oxide you should be checking to see if the bot has permissions for whatever actions you're trying to do before you try to do them

young flame
#

and it will filter automatically

steel drum
#

well

#

im psure that will

sour oxide
lusty quest
#

make sure to use some detailed informations for errors if your bot doesnt got the Permission. like just writing no permission wont help you. if you check for certain permissions make sure to add the same permission to the error or you wont be able to find the issue

earnest phoenix
#

like if ur on discord.js

sour oxide
#

It's not a permission error, it's an access error

lusty quest
#

permissions grants your access

earnest phoenix
#
if (!message.member.hasPermissions("ADMINISTRATOR"))
{
    // stuff here
}
sour oxide
earnest phoenix
#

so simple

young flame
#

i just sneexed

#

everywhere

lusty quest
#

TERI its not really helping. his bot works with Admin permissions but not with lower ones

#

and this is bad

sour oxide
lusty quest
#

since it can get you denied here

earnest phoenix
#

oh

steel drum
#

loooooool

earnest phoenix
#

but ok

steel drum
#

if it only works on admin im 99% theres a permission error

#

somewhere

young flame
#

bruh

earnest phoenix
#

i also need help but ill ask later

sour oxide
young flame
#

ok

earnest phoenix
#

ok

sour oxide
#
So my bot makes private channels so that only specific members may see them (it disables the @everyone role from seeing it), and when I don't have administrator.
Wait that may be my issue, I probably have to enable myself before removing @everyone...
lusty quest
#

more context?

#

did you get errors?

young flame
#
message.mentions.ROLES_PATTERN
message.mentions.USERS_PATTERN
message.mentions.EVERYONE_PATTERN
#

that would filter it right @steel drum

sour oxide
lusty quest
#

dmChannel is not a thing

lusty quest
young flame
#

uh

#

createDM

#

im pretty sure

#

or member.send

#

should dm the user your message

#

or in you message event you have run commands in dms off

#

so you can like have a message content thing

#

basically the same

lusty quest
young flame
lusty quest
#

i dont think so

young flame
#

or should i just use a regex and try to find a way to implement it

#

well i have a regex for mentions

#

idk how to put it in my maps

lusty quest
#

never used regex on maps so idk its probably possible but i would have to search it first too

carmine summit
#

how do I do debug?

young flame
#

OH WAIT

#

fuck

#

im just making things difficult again

lusty quest
#

read the error and understand what causes the error

young flame
carmine summit
#

k

young flame
#

if you want to debug your code but still have it run just do

#
client.on("debug", console.log)
young flame
#

i ca just use this

#
 if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) { //if it contains an invite link
    message.delete() //delete the message
      .then(message.channel.send('Link Deleted:\n**Invite links are not permitted on this server**'))
prime glacier
#
case "lite":
            if(!msg.member.hasPermission("ADMINISTRATOR")) {
      return msg.channel.send("You do not have enough permission to use the command");            
    }```

error :-```js
  if(!msg.member.hasPermission("ADMINISTRATOR")) {
                           ^

TypeError: Cannot read property 'hasPermission' of null```
young flame
#

i always make things more complicated then they are

lusty quest
#

this is more or less how regex work lol

young flame
#

^^^

lusty quest
#

and for mentions you can just check if your spam messages contain mentions and check on the first one already how many mentions are present

lusty quest
cinder patio
#

message.content.includes('discord.gg/'||'discordapp.com/invite/') that's not how the OR operator works

prime glacier
prime glacier
lusty quest
#

how did you define your msg object?

#

bcs for some reason there is no member defined

prime glacier
# lusty quest bcs for some reason there is no member defined
client.on('message', msg => {
    if (msg.content.charAt(0) === botChar) {
        const request = msg.content.substr(1);
        let command, parameters = [];

        if (request.indexOf(" ") !== -1) {
            command = request.substr(0, request.indexOf(" "));
            parameters = request.split(" ");
            parameters.shift();
        } else {
            command = request;
        }```
lusty quest
#

its in the same file as your switchcase?

prime glacier
#

yup

#
client.on('message', msg => {
    if (msg.content.charAt(0) === botChar) {
        const request = msg.content.substr(1);
        let command, parameters = [];

        if (request.indexOf(" ") !== -1) {
            command = request.substr(0, request.indexOf(" "));
            parameters = request.split(" ");
            parameters.shift();
        } else {
            command = request;
        }

        switch (command.toLowerCase()) {
            case "mem":
                sendUserApplyForm(msg);
                break;
            

            case "help":
                msg.reply(`Available commands: \`\`\`${botChar}apply, ${botChar}addrole, ${botChar}setup, ${botChar}endsetup, ${botChar}setsubmissions, ${botChar}help\`\`\``);
                break;
                case "lite":
            if(!msg.member.permission.has("ADMINISTRATOR")) {
      return msg.channel.send("You do not have enough permission to use the command");            
    }
    if(msg.member.permission.has("ADMINISTRATOR")) {
      let target = msg.mentions.members.first();
      if(!target) {
      return msg.channel.send("cannot found the member, try again");
    }
       const acceptchnl = client.channels.get("781500691117506561")
       acceptchnl.send(`${target} , your **LITE MEMBERSHIP** has been confirmed, kindly check [#752137420522389544](/guild/264445053596991498/channel/752137420522389544/) & [#746497133678559242](/guild/264445053596991498/channel/746497133678559242/)`)
        //target.send(`Your **LITE MEMBERSHIP** has been confirmed, kindly check [#752137420522389544](/guild/264445053596991498/channel/752137420522389544/) & [#746497133678559242](/guild/264445053596991498/channel/746497133678559242/)`)
        let role = msg.guild.roles.find(role => role.id === "749348685074137098")
        target.addRole(role.id)      
    }
            
         
        break;    ```
lusty quest
#

did you use normal Discord.js or some other libary?

prime glacier
#

whole code

atomic vault
lusty quest
#

next time pls a hastebin

lusty quest
atomic vault
#

how to use guildMemberAdd
in node js

lusty quest
#

its an event that is called if someone joins the guild your bot is in

atomic vault
#

i know but when i tyr like this
client.on('guildMemberAdd', member => {
console.log(member.user.username)
})
for testing it dont show anything in console when a user is added

young flame
#

@lusty quest do you have a regex i can use for the mentions thingy

lusty quest
young flame
#

tyy

lusty quest
prime glacier
lusty quest