#development
1 messages · Page 915 of 1
as i said, literally just updated it and it works
dont copy and paste things in package.json, always install using the "add package" button
thanks
omg wth
but the boot is still not open
https://oliy.is-just-a.dev/ab7mdd_3853.png well aint that nice
yea i think for my next project ill certainly be using this uws to try it out 🙂
ty for the info guys
the boot lol
how long does bot verification usually take?
like 2 weeks
ok thanks :)
how do i get my bot to send info to the discord bot list website for server count
@solar quarry
To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.
@solar quarry Also what lang?
node.js
what file do i put it in for it to run
your event file
so index.js
you can try in the bots main file at first, you may want to set a cronjob that periodically sends the info
maybe thats included int he package
what about a function that runs every minute
dblapi updates counters periodically
you can use the setInterval() function to do a basic loop every x amount of time
(javascript)
alright so I have a -cat command which generates a random cat image from an api in an embed
and sometimes it gives an error
embed.image.url: Not a well formed URL.
any ideas?
It's not a well formed url
do you have an example of one of these bad urls?
or does the api just return nothing but the error?
it works but sometimes it just happens
maybe try formatting with https://www.npmjs.com/package/base64-url
if (command === "cat") {
if (message.channel.permissionsFor(message.guild.me).has(["SEND_MESSAGES"], true)) {
let {body} = await superagent.get(`https://aws.random.cat/meow`)
if (!body) return message.channel.send("Error sending cat, please try again.");
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(":cat: Meow!")
.setImage(body.file);
message.channel.send(embed).catch(console.error);
}
}
thats my code
now im getting error
I'm not familiar with the library but I doubt body.file is a url
5xx status codes are server sided and you can't do anything about it
You didn't define dbl
so how do I solve the 'not well formed url'
i did
Well it is not being seen
@royal portal console.log(body.file)
well thats what the npm package says to do
are you trying to use dbl.on() outside of the ready event?
outside
then you need to define dbl outside
ok now how do i get it to post the server count
it will post automatically
is it meant to memory leak
no?
well its doing that
how so?
thats not a memory leak, thats a warning for adding too many event listeners
o0
do you have multiple events of the same type?
like ```js
client.on("ready",() => {
// bla
})
client.on("ready",() => {
// bla
})
client.on("ready",() => {
// bla
})
nope
put DBL outside of the ready event
ok now i am getting message is not defined
does anyone know how to fix the unknown messag
so if you want your bot to delete a messag
and another bot deletes it first
i fixed my issue
and a top.gg token is a token to put your server count on the website
where do i get it though?
on the api section on the edit bot page
does the first line of code outside of the if statement make the 2 other underlines of code redundant ?
as in I can access the target and timestamp thru the first one?
Yeah you could probably store alog into a variable
aight, wasn't sure did I needed the secondary await and fetchAuditlogs
so that's why when I was making it I made it that way lol
Yeah await will make it so you get it in the variable
Without await, I I think you store the action so you can execute later
no just a promise
Idk I dont do js
like, if he calls the promise, it will store a promise, as well as sending it, if just the promise is referenced it will just be there for execution later
Without await, I I think you store the action so you can execute later
so im trying to display the server count and i get this error Oops! Error: 401 Unauthorized
await isnt whats calling it, the () is. await makes no difference except if calling it with await, it will await execution, otherwise it will execute and move on immediately.
What's the code? For the 401 error
kk
Hi, I can not understand why he gives error here. Can anyone tell me?
const webhookMsgAtt = await Sondage.send('', {
username: message.author.username,
avatarURL: message.author.avatarURL,
embeds:[EmbedAtt]})
await webhookMsgAtt.react('1️⃣');
await webhookMsgAtt.react('2️⃣');```
(node:19531) UnhandledPromiseRejectionWarning: TypeError: webhookMsgAtt.react is not a function
v11
@slender thistle so thing is i want it to only replace at that index
Technically you could go the hard and stupid way and convert the string into list, change the characters, and join the elements back
Thanks
i was hoping i could do that sort of string[i] method
got any other ways other than converting to a list shiv
Creating a new string with iterations?
i have no idea how you'd do that shiv
newstr = ""
for i in range(0, len(oldstr)):
if i != someindex:
# add old symbol
else:
# add new symbol
but do you really need to bother with the precise indexing
yes
also um
File "main.py", line 64, in encrypt
elif text[index].isupper() and text[index + 1].islower():
IndexError: string index out of range
@slender thistle is this something to do with doing index + 1?
like 64 is pretty deep in the func so why didn't it error earlier
The third argument in replace isn't the index
maybe
also for index in range(0, len(text)):
len(text) - 1 
ok
um
File "main.py", line 30, in encrypt
for index in range(0, len(text - 1)):
TypeError: unsupported operand type(s) for -: 'str' and 'int'```
wha
did you mean to put the -1 outside the len
minus in the wrong place
oh duh ok
yep
well, works i guess, but it replaces nothing
guess that replace function i did was dumb
replace returns an edited string
i made a custom replace
but its dumb
also, can you do inline stuff
like if text[index] == ' ': arr.append('_')
on one line
Sure

turns out this entire function sucks because i don't know what letter it is when i try to decrypt
Hello becomes &!!!!
(& for uppercase letter and lowercase next letter)
(! for lowercase letter and lowercase next letter)
so i have zero way of telling what it is lmao
use special characters for each letter
we have to make it by hand for school
and only use basic kbd letters/symbols
basically any QWERTY layout thing
!@#$%^&*()_+1`234567890-=qwertyuiop[]\QWERTYUIOP{}|asdfghjkl;'ASDFGHJKL:"zxcvbnm,./~ any of these
and yes i just ran my finger over my keyboard
can't you just a-zA-Z
idfk then
i remember making ascript which just did the letter a with some special characters
was a mess
Can anyone help me with a question real quick on an event that is returning 3 times
console.log(path)
})```
this is returning 3 times, how can I check if it repeats?
how i do youtube bot?
depends. what do you want it to do
@magic jackal are you spamming CTRL+S
@sudden geyser like mee6
like every dev does
when i upload a video
auto save gang
jetbrains ide gang
no, it just randomly returns 3 times and for some reason I cant figure out why, probably because of file changes that are still happening but i want to check against that. @delicate zephyr
idk how to check it efficiently
Here is the package
its weird
why are you watching for a file just out of curiosity
im watching my sharex folder for new file additions thats it
the 'add' event is just as bad
idk, ive never used chokidar
hmm
What code can I use to make my status: >help | On (number) servers?
I could use the watcher.close(); after it returns but idk about that
@nimble hazel client.guilds.size
thanks
np
v11?
me?
yea?
you are 11v or 12v?
ok nvm
lavalink
@earnest phoenix npm?
Node version?
thx
yeah theres a node package for bots
@earnest phoenix
wait
but the main program is java iirc
u say music?
yes
i dont want that
i want this
oh you want a youtube search?
wait
like this @earnest phoenix
@sick cloud Which number thing goes in the <client> part? is that the id or secret?
the client
like client or bot
whatever you use for your <this>.on('message') and such
<this> is the client
okay
@earnest phoenix to do that, you'd need a pubsub server and knowledge of XML, websockets, subscriptions and some other bits
good luck
go to my bots section
go on ur bot
what is the deadline for the bot to be accepted or disapproved?
jesus christ
this is sad to watch
click on ur bot
oh :v
generate token
pepega
oh xd
any password
no
no what?
nothing
ok
this (https://top.gg/api/docs#jslib) is 11v?
dbl api supports discord.js v11 and 12 i beleive - if thats what your asking.
.setFooter("Requested by", message.displayAvatarURL)
it doesnt display there picture?
@queen needle message.author.displayAvatarURL()

But i know how to make avatar command 
@queen needle you forget to add author also
after what @pale vessel said i added author but i just forgot ()
(node:4965) UnhandledPromiseRejectionWarning: TypeError: message.guild.channels.find is not a function
??
code:
const channel = message.guild.channels.find(channel => channel.name === "reports");
what is your djs version
v12
read docs
how would I change command.execute to be compatable with module.exports.run
well exports.run is like your execute function. They do the same thing.
So it's a matter of how you call it in your message listener.
It isn't magic. It's just a set of instructions you give it.
so command.execute should work with module.exports.run
I've no idea how you structured it. How did you do it before, and how are you doing it now?
I tried switching command.execute for module.execute.run
well not EXACTLY that
but
Like did you do this before? js module.exports = { // ...stuff execute() { // more stuff } // or `execute: async () => {...}` };
yea
but I'm using an older piece of code, one from my scrapped bot
it uses module.exports.run
just change run to execute lol
Then why not do what flaz said or properly go to where you call the function and instead do .run() instead of .execute()
I'll try both
right after im finish driving my pc up the fucking wall unknowingly
what
vsc is not responding
Soooo I've got a question. I've been waiting for my bot to be reviewed and watching some of the rejections in #mod-logs. While I'm confident my bot has no issues that would cause rejection, I did see some curious rejection issues regarding privacy. So I had a question about a feature I plan to implement in the future.
I have a separate bot that functions only on one server, this bot maintains a database for verified users and their verified account (think of an account like YouTube tied to your Discord). I plan on exposing this data to my new bot and using it for ease of use (so instead of typing in account names they can mention the user).
The question is regarding privacy - would this cause issues? I see nothing in #rules-and-info regarding it but I saw rejections with bots that had a userinfo command that let people lookup userinfo on users not in the server. So I assume my planned functionality would be fine as long as it only resolves for users in the server where the query is ran?
If that makes sense.
if the user knows that their information will be public, it should be fine
and you already made it server members only
seems good to me
but let's wait for a moderator to respond
Well, it's a bit weird. Bot A is on Server A, Bot B is on Servers B - Z. They don't share a mutual server. But Bot B uses the database from Bot A to get this data.
@coral trellis can you help on this one
https://discordapp.com/channels/264445053596991498/272764566411149314/708165258216341514
hmmm maybe I'm overcomplicating it. I should probably just add the functionality to Bot B and not share databases. To let users selectively opt in again.
Problem is I want to put Bot B in Server A so I can take redundant commands out of Bot A. But I want to maintain feature parody, which I can't without implementing this feature I mentioned.
I could restrict it to feature parody only works in Server A I guess
Well it comes into question of consent as they may not want their data being exposed publicly like that
Ontop of the fact that they gave that specific application consent and not the new one for a specific use
True. And I don't have any nomenclature in Bot A regarding this usage (public data).
Sounds like I should just reimplement the feature in Bot B and specify where the data will be used.
Means I have to maintain feature parity between Bot A and Bot B though instead of supplementing Bot A with Bot B. But that shouldn't be too much of a hassle.
if(message.content.startsWith(prefix + 'yeet')){
let fish = args.join("")
if(!fish) return message.reply("Please say something")
fs.writeFile("./idk.json", JSON.stringify(fish), err => {
if (err) console.error(err);
})
await message.reply(fish + " has been saved")
}
});```
everytime i do ^yeet <text>
it saves it but if ido it again it just replaces the already existing text
it's supposed to
how?
wdym flags?
js { flag: 'a+' }
thank ou
how could i save it by id so they could do a command like ^get and it would grab the first thing that is from their id in the file
and sends it
might as well have a database for that
would it work with quick.db?
uhhh sure
Please help me, I am trying to store channel id in a mysql database, the column is of type BIGINT, when I send the id, in the table it is shown correctly, but when I get it in my code, it changes the last 3 numbers by 0
cool coincidence because i had the same problem 2 days ago
no problem
flazepe is one of the best people to get help from
because they dont spoon feed you and are nice about he;ping you unless you are a idiot
lmao imagine storing guild name
I hope those variables are sanitized.
if(message.content.startsWith(prefix + 'sitem')){
if(!args[0]) return message.reply("Please include something to store")
db.set('stored', args[0])
}
if(message.content.startsWith(prefix + 'stored')){
let f = db.get('stored')
message.author.send(
f
)
}
})```
how could i make it so if they already have something stored and go to add something else it doesnt get rid of the first thing they have stored
how about the append flag
Does that work for quick.db?
are you sure?
i think i just figured out how to get it to work ijust have to test it now
nvm
lol
Do you know if any database could do something like that
I had a problem, was there anyone to deal with it?
what is your problem
wdym
I don't know what you mean
what do you mean coming to your bot?
do you mean on the approval process?
that can take several days up to over a week
Okay what are you talking about then
what
@pale peak your bot was declined so you can’t update it on the site if that’s what you mean
You’ll have to resubmit it after resolving the issue
what do you mean by "update"
^
this hurts
Hey sorry, I am new to making discord bots. I was following a tutorial and they told me to type "node ." to start up the bot it came back with an error message, I don't know if this is a common problem but does anyone know another way to get the bot online?
How far into the tutorial are you?
Did you make a file called index.js?
If so cd into the folder and do “node index.js”
how would i cd into the folder?
cmd documentation: Navigating in cmd
Okay, one second, sorry
I did that and it replied with "code:'MODULE_NOT_FOUND'"
I'm working with modules and classes in Node (for my Discord.js bot); how would I pass an object (message) from my index file to my file where all of the classes are stored?
@earnest phoenix Also, you probably didn't run npm install
It replied with:
(alot of other stuff)
"up to date in 0.715s
found 0 vulnerabilities"
ima punch somebody if I needed to update the software -_-
@green vale use module.exports s m h
yes but apparently the people at djs think that i'm absolutely stupid dumB for using module.exports = message
@earnest phoenix try node . now
Pass them as parameters for the class constructor? Using module.exports = message IS pretty dumb
Well what you want to do
Like a message.js file?
Nah, I have that for my main bot already
I feel like the code is cleaner if I spread it out between files
But yeah I did const [variable] = new exampleClass(message)
@green vale , it replied with "await is only valid in async function"
Make it async
No
well actually it's just async function instead of function so
If you want to program a discord bot you MUST know your programming language
I learned JS from DJS
bad
I like to learn languages in practice, and just search up or ask whenever I have a question with something
i guess "async === true"?
No
(Remove the token ofc)
const Discord = require('discord.js');
async === true
const client = new Discord.Client();
client.once('ready', () => {
console.log('Ready!');
});
client.login(' Token removed ofc ');
no
no
learn the language you're working with before making a bot in it 👏
@earnest phoenix What's this file called?
index.js
first: remove async === true, this makes no sense
is the index.js THIS index.js?
Try running node index.js in the dir that you have your code in
Is it possible to use a class before declaring it?
ok so I made a small game Console game engine in cpp
oh
no it's not
It kinda did nothing, I think I screwed up in a lot of places
oh
my coding classes taught me nothing about this
they probably taught another lang than JS--what language did they teach you
w o a h
they taught me legit nothing
@earnest phoenix who
my coding teachers
oh
what the hECK am i doing wrong
mines r starting a lesson about javascript LOL
they used the same website that 1st graders use i swear
what's that website
i dont remember
our cs class was just office for the first year and then second year we started doing cpp and c# lol
yeah same thing here
then, we went ahead and learned how to code in Docker Python
second semester was much more interesting
Im gonna try doing this in the morning
How can I get all row data for same guild in sqlite
I forgot most of the things for Python since they teach in a much more different way that I usually effectively learn, but I'm gonna relearn it soon
aaaaaaa wHY isn't it defining message even though i added it in constructorr
on a scale of 1-10 how normal is it for a websocket connection (discord bot) to close every few hundred events with code 1005
it has
wats ur bot
@small osprey
But it's in other language, so it will not spam
still
The help command is .pomoc
common prefix = cant talk
if(body.populationByDistrict["Blam Canyon"]===undefined)return message.channel.send("Erreur, la ressource demandée n'est pas disponible\nCode Erreur à signaler au développeur : **"+body.error.id+"**");```
I'm trying to see if the property "Blam Canyon" exist in an online .json file
but it returns me
```js
TypeError: Cannot read property 'Blam Canyon' of undefined```
thats weird bc I'm checking if its undefined and give an action to if yes
v info :
djs 11.5.1
nodejs 11.9.0
Any one can give me questions and answer json data bass please help me
Oh yeah sorry, a data bass; either way
Generally not a good thing if you want to use a file database. Just try to use a real database like MySQL, PostgreSQL, MongoDB or whatever
Good luck with using a file database when you use something like Heroku
is it possible to change the color of that too?
M
Anyone here use chart.js on the server side?
I know I've seen people's bots here use it
I can't seem to install it without loads of angry errors
how i can see channel name with channel id
get the channel name and channel id?
yes
no by channel id
with channel id to get channel name
ooh
then there is a thing to get channel by id
you should look in the documentation
wait my name is changed ?
YEY
A simple *get" ? For example with client.channels.get('id", "youtIDChan"); ?
ppppp
That's just a variable name, there is no problem
ok
What
????
To get your channel, try bot.channels.get("id", "ChannelID"); and just see the doc
Hey, is there a difference between client.setInterval() and just setInterval()?
client.setInterval() will clear the interval when the client is destroyed
ohh thank you. So also when the client loses connection?
I am not sure, the docs just say that
probably when you do client.destroy()
oh
but why would you even use client.destroy(), you can just restart your program or am I missing something?
if for some reason one wants to close a bot and start another bot on the same process
while doing/managing other things
ohh
thanks
will just keep my 'normal' interval then 🙂
oh and another thing, is a retryLimit in the Client constructor of 5 okay? I know what's doing and I hate it when I get 'User aborted a request'
Any ideas on how to promote your bot for a faster growing community? 🙃
Apparently collaborations are considered advertising by some.
That step is almost done ^^
Kind of. I was first trying to reach a point where I only need to fix things instead of adding things
Seems like coding 1 full week isn't enough, still having so many ideas to implement.
- make a good bot
- market it well
you may make the best bot ever but if noone knows about it or finds it unappealing its worhtless
hello
i have a problem
when i put this
return message.channel.send(message.guild.id)
}```
it return me this in the text channel
698550448273227856
but when i put hits
return message.channel.send(message.guild.id)
}```
That if statement is useless btw
dont work
what?
oh. with ``
now work
thanks
I tested api with servers on site and deleted the code also uninstalled dbapi.js, but its still bugged and shows 155 but there are 300 ;d
@earnest phoenix what is your bot id?
@sinful belfry 684805224573042688
how come you unistalled dblapi.js?
ubuntu vds, npm remove dblapi.js
why did you uninstall it though?
and you are expecting your bot stats to get updated or am I missing something
hmm
is wrong number
k
If you remove it, it will show N/A, wouldn't you prefer to update the count to the correct number?
no i want n/a
oh and another thing, is a
retryLimitin the Client constructor of 5 okay? I know what's doing and I hate it when I get 'User aborted a request'
does anyone know?
guys, how long can it take to approve my bot?
-faq 2 @sullen night
@sullen night
@nocturne grove d.js I assume?
@sullen night #502193464054644737
I mean, why not leave it to infinite?
console.log("Servers:");
bot.guilds.forEach(guild => {
console.log(" - " + guild.name);
}``` On discord.js 11.6.1 this worked fine.
how do i get it to work on 12.0.2
I see
so you mean, change it to infinite?
Default is indeed 1 mb
is someone able to help me
I mean, if 5 solved it sure I guess
@slender wagon change bot.guilds to bot.guilds.cache
@slender wagon read the changelogs, it's bot.guilds.cache rather than- ok then
thank you!
okay so 5 isn't harmful or something?
not really
and infinite isn't harmful too?
I mean if Discord has an outage then it would try forever which isn't the best I guess
oh okay. Thank you
https://i.callumdev.pw/588fa.png
Why does this not work, I do not get any errors.
download?
by the way
you can just pass the buffer
saving to a local file takes time
const download = `https://...`
const attachment = new discord.MessageAttachment(download, 'achievement.png')```
Idk if it will work on not because i have never used MessageAttachment 😅
https://... means that link in bracket
MessageAttachment takes a buffer or a stream
you still need to do the downloading of the file yourself
i will google
let start = Date.now()
let time = Date.now() - start
passing just the url will not work, as MessageAttachment doesnt download it for you
but like cry said, you dont need to download it to disk as a file
you can download it and keep it in memory, as a buffer, or as a stream
hey, i'm trying to make a log when my bot is added to a guild, and i'm trying to make an invite link, to let admins join the server if there is any problem. My code looks like this :
let channel = bot.channels.get("707638470297780254")
let defaultChannel = "";
guild.channels.forEach(channel => {
if(channel.type == "text" && defaultChannel == "") {
if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
defaultChannel = channel;
}
}
})
let inv = defaultChannel.createInvite()
let embed = new Discord.RichEmbed()
.setTitle("Nouveau serveur")
.addField("Propriétaire du serveur :", `${guild.owner} (${guild.owner.id})`)
.addField("Nombre d'utilisateurs sur le serveur :", guild.memberCount)
.addField("Nom du serveur :", guild.name)
.addField("Région du serveur :", guild.region)
.addField("Invitation vers le serveur :", inv)
channel.send(embed)```
And the var "inv" is just [object Promise]. Does anyone know how i could crete an invite link to the guild ?
ps : ping me i don't read every messages 😋
creating invites to other guilds is a privacy breach. guild owners should invite you to their server if there is any problem, not you invade their server without permission.
other than that, createInvite() returns a promise, you have to await it
@earnest phoenix
bot.guilds.cache.reduce((a, b) => a + b.memberCount, 0).toLocaleString()
try it please
for count
Ok
Didn't work
maybe its a bug
not a.memberCount?
yeah and its meant to be a.memberCount
its working btw
you guys are smart: How can I display something like ``hi`` in this format?
just do it like that in ur output
no that sadly does not work
show code
just try it yourself here
\`${roleName.replace(/`/g, '\\`')}\````
this doesn't help
lol that `
what are you doing
whats the problem
why are you replacing
if u want to use codeblock just do
"`ur text`"
and it will output as ur text
``hi`` this should be in the code block
or are u trying to escape it
probably because the role could have the character `
``wwq`
i dont think u need to double escape
test
double works too
wwq
they're just escaping it
a single is not right acc to eslint
but try typing it yourself (and replace it), it doesn't work for me
no in Discord
Anyone has experience with hetzner vps? is it recommendable for a bot / databases ?
``hi``
😱
that was with a space
``hi``
okay
but you can see the space 🤔
what if a add a zero width space
What are you trying to do?
you guys are smart: How can I display something like ``hi`` in
thisformat?
this
You mean for your bot?
yes
``hi``
Yes
but you can see the space 🤔
@nocturne grove i can't see the space
"````hi````".replace(/^`/, "` ").replace(/`$/, " `")
a bit tho
maybe this?
@copper cradle that's not so nice in a sentence, and that's going to give the same problem if you add `
will try that
@pale vessel that gives `hi` instead of ``hi``
then double it
"````hi````".replace(/^`/, "` `").replace(/`$/, "` `")
wait
there
also if you try with 2 `?
2020-05-08T12:57:19.055167+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
2020-05-08T12:57:19.055169+00:00 app[worker.1]: at IncomingMessage.<anonymous> (/app/node_modules/dblapi.js/src/index.js:118:25)
2020-05-08T12:57:19.055169+00:00 app[worker.1]: at IncomingMessage.emit (events.js:322:22)
2020-05-08T12:57:19.055170+00:00 app[worker.1]: at endReadableNT (_stream_readable.js:1187:12)
2020-05-08T12:57:19.055170+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21)
2020-05-08T12:57:19.055286+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-05-08T12:57:19.055354+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Umm
Thx
huh
nani nani
hmm will copy again then 😂
yeah i edited it like 3 times
ohhh
maybe you copied the wrong revision
yea xd
not it still doesn't work, but who says your output gets displayed the way you want in Discord?
come again
what are you trying to do?
sending things with multiple ` in single-line code @grizzled raven
yes but it doesn't work
what
wait maybe it's my code
yeah probably
aww no u
now I can replace everything where I need it 🙂
glad i could help
I wonder if I'm the first one who wanted to solve something like this (it's saying a role name in the code block)
oh i just realized
since the new code replaces both beginning and ending with ` ` you can shorten the code with
"````hi````".replace(/^`|`$/g, "` `")
now we're talking
@nocturne grove
haha thanks, that's nicer!
@grizzled raven I wanted to send things like this: ```test```
(I can now because we figured out)
hi, I'm using eslint with rallycoding (which I like)
but I have the one issue on my discord.js bot's "index.js" file
I'm having the issue of "Error while running ESLint: Cannot read property 'range' of null." because of that error it doesn't show any issues I have with my index.js file
I have tried to google it, but nothing comes useful or it is not related to my exact scenario
I use eslint with Atom and have latest version of eslint-config-rallycoding, eslint and all other necessary npm packages
@pale vessel now the var will only be placed in between this when the var itself contains a `, right? (can't test it now cause db is offline). If so, can you change it?
i would suggest making a function
@nocturne grove here's my implementation:
function codeWrap(text) {
return "`" + text.replace(/^`/, " `").replace(/`$/, "` ") + "`";
}
console.log(codeWrap("hi")); // ` hi `
console.log(codeWrap("```hi```")); // ` ```hi``` `
(no codeblock for clarity, sorry)
okay thank you! will try it when I can
hmm
looks like this method won't work on text that is wrapped with single `
both of the side needs to have at least two
are you guys still trying to figure that out?
no we're done
lol that's the other way around
i mean if you don't look closely
hmm
that's all i can think of
````\u200B${message.content}\u200B\```` doesn't this just work fine?
it does for me
no it doesn't
I'm trying to create a logs system for my bot, but I don't know what is the best way to let the user configure it (like enable/disable logs, the logs that he desire [i.e. message deletion, role update...])
maybe like an enable/disable command like: -logs enable join leave message_edit role_update I think that's how I would do it
2 keywords
I think that's a good idea, thanks
my music is being buggy and Im not sure why? https://prnt.sc/sd874y (guessing its the end event) could someone help me https://hastebin.com/onicikamob.js
@pale vessel wait... I can also just prevent my bot from using that markdown. But then I need a way to disable all Discord formatting, so afaik `, *, _ and ~ (maybe I'm missing some). Is there a way to create a short regEx for that?
so no code blocks?
yes
I started to use the code blocks so * etc. are displayed as *. But now it's easier to do that in another way
If you are on discord.js, I believe there is a .cleanContent property or something similar which is just the text without markdown
actually it's just for mentions
oh
The message contents with all mentions replaced by the equivalent text. If mentions cannot be resolved to a name, the relevant mention in the message content will not be converted.
yeah
message.content.cleanContent doesn't work when content = *
const {Util} = require("discord.js");
Util.escapeMarkdown(text...)
you can also use the base
Discord.escapeMarkdown(message.content) works too
like Discord.escapeMarkdown()
(shouldn't it be Discord.Util.escapeMarkdown()?)
what @pale vessel said worked
yes but like i said it's available on the base object too
oh didn't know that
These functions are also available on the base Discord object.
what is the event for .premiumSubscriptionCount (when new boost, the bot do action)
and what should I put inside this event if:
- A new boost
And do action if: - One less boost
I was thinking guildUpdate?
Oh wait
no
its not
This information is available in the messageCreate event with the various types of Nitro boost. https://discord.js.org/#/docs/main/master/class/Message?scrollTo=type
Can those be disabled?
anyone know how i can put the amount of servers my bot is in the status?
With a POST request to https://top.gg/api/bots/stats or you can use a wrapper for the API
anyone know how i can put the amount of servers my bot is in the status?
Can anyone help?
I just answered your question
well make your question more clear then 🙂
sorry
I get what you mean maybe I misunderstood
maybe...
anyways
can you help?
ok, but in guildUpdate event, How to make the bot do an action when there is a new boost and when there is a less boost?
@delicate zephyr
const {Util} = require("discord.js");
Util.escapeMarkdown(text...)
um can you help? @cinder patio
@earnest phoenix ???
@earnest phoenix I mean, you quite literally have to use the message
You cant get a user from the new guild in guildUpdate
I don't know discord.py sorry but I can give you a link to the discord.py documentation
but you can check the old guild / new guild and check guildPremiumSupscriptionCount and see if its gone up
@cinder patio what do you use to code your bot?
@earnest phoenix
yes but how to check if gone up?
ah yes, reading. hard to master.
???? @pale vessel
please ignore me
Jerry, that's node.js/javascript if that's what you're asking
I'm making a message collector class and I have two ways of possibly watching for new messages:
- Use the single
messageevent my bot always has and just listen for messages from them. - Create a new event listener on the client instance to watch for messages.
Is there an advantage between the two of them? I've asked this question in the past, but sadly got no response.
event listeners probably take up memory so you should stick with one event if possible
I mean... why? Does the library you are using not have a utility function like that?
nope
Then I guess the first one sounds better? Although I am not sure how you'd implement it
I'm using Eris so no. Discord.js handles it by adding a new event listener (because that's all it can do) but I never see anyone doing it in a single message listener.
have you tried eris-additions?
Nah I don't want to use that.
I've already implemented it, but was wondering which one was preferred
i've never used it too
If I really wanted it I'd take properties from the library make my own and call it unique
you can always create a new listener and look for performance drop
having more than one listener for each event is bad practice and prone to problems
a lot of people I know that do this tend to have memory leaks and stuff
like luca's repo lmao
if it's not as worse as this
it’s still bad practice
Just depends on how you handle it 
anything you can do with multiple listeners you can do with one
That's true, unless you don't want to mix up your logic
sometimes people just prefer to have a separate one just for aesthetics
just make separate functions for each thing you’re doing
and call them in listener
saves memory
Like attaching an extra message listener for like a minute and then removing the event after the minute is up is perfectly fine imo
What if you want it to be in a function, like discord.js' await messages?
just attach it to your listener
you can probably do that with setTimeout
push listener to array and handle it in the event function or something idk
it’s not hard
I found you can have a bot send emojis either by sending the shortcode (:grinning:) or by sending the 'raw' unicode string
now I wonder, is there any disadvantage to sending emojis as the unicode string?
I'm worried that not using shortcodes might be unsupported, or frowned upon
shorter strings
well uh no
I think it's the same, what I meant is that less data gets sent
in most cases
if it's not as worse as this
@pale vessel that code looks like something I'd actually see in this channel
when you have something like ":regional_indicator_d:" you can't fit many of those shortcodes into a 2000 char message
there actually was
using the Unicode string instead, you can put more into one message
i remember that one dude
Discord has a limit of 198 emojis per message I found out, whyever that specific number






