#development
1 messages · Page 1269 of 1
indeed, and i ignored cuz i dont have the answer for it
@modest smelt did you check docs?
i saw it
which is why during raids here a lot of bans dont get picked up and display ???
im doing ban command only work for people with perms to ban ```python
@commands.has_permissions(Ban=True)
@violet mesa python @command.has_permissions(ban_members=True)
though the duration of that loop is up in the air
For discord.js.. is there a way to only update a certain permission without removing all the others
ok thx @modest smelt
setting timeouts and retries for every ban/leave event can be quite pricey
If you're talking to me I havent found something
.overwritePermissions(overwrites, [reason])
Replaces the permission overwrites in this channel.
This doesnt work for me
try for 30 minutes every 5 minutes, if nothing, => display normal leave message
i COULD edit the message afterwards with kick/ban payload tbh
@earnest phoenix Do you mean CI/CD
please check docs first
@misty sigil just one question, where do i search up and find this. IK how to the docs, but how do i know where to search?
thats one option
user
Js
because its checking if user is bot
Node.js
Are you talking about CI/CD Perry?
Dm me how I gotta go
It’s for a discord bot
Oh..
JavaScript
Hmmm i might try it that way tbh, then i dont hinge the notification gauge
I’m running it and it needs to be latest of node
I think we're clear on it being a nodejs bot
you don't update node on github
you update it on your host
Or just come back when you have the time 😛
so i needa send an embed each hour whats the best way to loop
setInterval would be one way, but it resets if the bot reboots
then you should use node schedule
you might want to look into node-schedule (I'm assuming nodejs, here)
if you really need it to be accurate
Just thought about a way that'd be doable speedy
@modest smelt no work
smart but not flawless
there is no permission called "Bans"
but should work fine in this case i'd assume
got it
It's BAN_MEMBER
yes
@violet mesa prolly cuz u dont have the perms
BAN_MEMBERS , not ban_members
if the user who ran the command prolly don't have those perms
or is MEMBERS_BAN?
nah it's BAN_MEMBERS
discord needs to get their shit together and give people what they want and beg for on their github page instead of turning on "contributors chat only" and leaving it there to rot for years (cough being able to see which invite a user used straight from the event) @opal plank
@violet mesa @has_permissions(ban_members=True)
@split hazel Tbf the amount of shit PR's i see there is insane too, so on one hand i get you but at the other hand i understand them too
cough being able to know when a user was last seen online cough
but you should listen to highly requested features and if you don't want it to be implemented, leaving a reason why not or simply saying "no" instead of leaving it there with no update
fair point
one of the reasons why so many people resort to client mods for example
tbh as a company resources like that are too little benefitial
while client mods are a thing, they are STILL using discord
company wise they are the same
I'm still waiting for custom slash commands, it was literally the only reason I was using a selfbot back in the day.
the user still using their platform
some also want to use client mods maliciously like sending embeds or seeing deleted messages but they're a minority
its mainly css and themes
tbh they arent malicious but considering the tos
IDK RLY
even tos is fine regarding to that
themes was a requested feature since day one im surprised they didnt add anything yet
yeah, Discord likes to ban people for doing things they dont want to do instead of just implementing features the people want
i personally like the current one, non distracting and plain colour but i know a lot do
check this @split hazel
https://github.com/joe27g/EnhancedDiscord/issues/143
https://github.com/leovoel/BeautifulDiscord/issues/94
https://github.com/rauenzi/BetterDiscordApp/issues/442
i ve even seen dev's alts into those server(likely monitoring), and nothing is ever done. Unless you specifically get reported for harmful stuff(and even then) you dont get any repercurssions whatsoever
they are very well aware of where those things are, but as a company there isnt any reason to stop it(apart from caring about the user potentially getting harmed with malicious plugins)

its not like its hard to just google either of those and join their discord to see what goes on behind the scenes
@silent cloud how about you just, like, repost your problem, nobody wants to scroll up for days trying to see what your question is
const fs = require('fs');
client.commands = new Collection()
client.aliases = new Collection();
Error:
PS C:\Users\admin\apemodicus> node .
C:\Users\admin\apemodicus\index.js:11
client.commands = new Collection()
^
ReferenceError: Collection is not defined
at Object.<anonymous> (C:\Users\admin\apemodicus\index.js:11:23)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Anyone help?
const { Collection, Client } = require("discord.js"); or just use Discord.Collection instead
Extend the collection class from discord.js
Code:
const fs = require('fs'); client.commands = new Collection() client.aliases = new Collection();Error:
PS C:\Users\admin\apemodicus> node . C:\Users\admin\apemodicus\index.js:11 client.commands = new Collection() ^ ReferenceError: Collection is not defined at Object.<anonymous> (C:\Users\admin\apemodicus\index.js:11:23) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47Anyone help?
@umbral zealot
const queuer = message.guild.id;
const queue = message.get(queuer);
Whats wrong with queue const
@autumn aspen dude don't repost a second later, I already answered you
Wtf
I dunno, what is wrong with your queue const?
What i need placce message.....get
can you describe the problem
what?
How do I make a command with discord.py that allows a role to use certain commands?
message.get is not a thing at the first place?
const { Collection, Client } = require("discord.js");or just useDiscord.Collectioninstead
@autumn aspen literally right after your message
@silent cloud What are trying to make
Thats music bot
@autumn aspen literally right after your message
@umbral zealot thx
message.get isn't a thing
I don't know what it's supposed to be, but that's invalid.
Thats from github
const queue = message.client.queue.get(message.guild.id);
But wtf...
You literally showed 2 different kind of codes, so which one is it
But what's wrong with it exactly
ok well give us the code
not just the warning
Please give us your real code
If you give us partial code, we can only provide a partial answer.
If you give us pseudo code, we can only provide a pseudo answer.
If you give us fake code, we can only provide a fake answer.
queue manager bound to the collection didn't have a channel property basically
yeah ok
so?
either the github is wrong or you're not copying the whole thing or you're copying it wrong
reminder: we cannot see your screen, so we have no idea what your code looks like or how it works
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I can give github
Have you installed the right version of node / discord.js?
Yes
How's even queue constructed is the question
did you add this line https://github.com/eritislami/evobot/blob/master/index.js#L14
Because the problem here is that it didn't have a TextChannel property in the queue manager
Look index.js at dirname
Maybe have? Idk
Because the problem here is that it didn't have a TextChannel property in the queue manager
@earnest phoenix ???
I mean look, you need to have a way to add stuff in that queue
and you need to verify whether the queue exists, and create it if it doesn't
@earnest phoenix ???
@silent cloud "queue.channel.leave()" channel here doesn't exist on the queue object returned
if (command === 'say') {
let emb = new Discord.MessageEmbed()
.setColor("#f025e9")
.setDescription(`you have to put something after .say!`)
message.channel.send(emb)
} else {
if(!message.member.hasPermission("ADMINISTRATOR")) return message.reply("You need `ADMINISTRATOR` Permission to use this")
}
if(!message.guild.me.hasPermission("ADMINISTRATOR")) {
return message.channel.send(`**${message.author.username}**, I do not have ADMINISTRATOR Perms!`)
}
{
const sayMessage = args.join(" ");
message.delete().catch(O_o=>{});
message.channel.send(sayMessage);
}});
Right and do you have this line, https://github.com/eritislami/evobot/blob/master/commands/play.js#L16 , @silent cloud ?
@peak osprey That.... would clearly not work. that logic is wrong.
Wait i check
so whats wrong with it
"if the command is say , reply that you need to put something after say"
"if the command is NOT say, then check if the user is admin"
that's... very wrong logic
@umbral zealot what's worse, this channel or djs server?
they're both equally horrifying
lol
Im stumped
so what do i change?
Check if the command starts with say
Not completely equal to say
what's worse, this channel or djs server?
djs is worse cuz they tryin to flex on each other and show who has the most skill ;-;
well and djs doesnt help at all
@earnest phoenix if they're following the arg builder that I know, command === 'say' is valid, that's only the first word in a message without the prefix
In djs server you also get muted for invalid support but not in here
and args would be an array of every word after that command
I can give you my say command
I can give you my say command
The blind leading the blind

lol
has either of you considered learning javascript instead of just shoveling random code into your bots
@earnest phoenix if they're following the arg builder that I know,
command === 'say'is valid, that's only the first word in a message without the prefix
@umbral zealot it can be but we don't know how he handles his commands and args
Im rly dont understand
You would if you knew javascript. 
put message in a array and slice 1 done u have args
||FUCK it all, fuck the bot, fuck it all, I'm sleeping, I don't understand this shit||
lol

oh that's why. I get it.
Learn the programming language you're using to make something before actually attempting to make that thing
Tired Programmers are Dumbass Programmers.
LOL
you should use this time to get through codecademy.com
taking breaks is equally as important as improvement in my opinion:)
you would hate it less if you knew what you were doing
u can sit 24/7 but depends what u actually do
Non stop coding is something that you should not do, refrain from it and take breaks for your mind to refresh itself
Non stop coding is something that you should not do, refrain from it and take breaks for your mind to refresh itself
i can't stop
Or you will end up making more errors
i love it
Or you will end up making more errors
@earnest phoenix NOT WORKING!!!
The moment when you're so tired that you open a new file and no code in it, and you type a single letter, 59 errors, amazing
whats problem?
If I code for 2 hours straight I get tired and start writing lazy code.
Ohhh
whats problem?
lmao hows is the copying from tutorial doing?
@autumn aspen Obviously, no closing curly bracket
HAHAHAHAH
Syntax errors are something you should be aware of not us
Booze and an all-nighter is the peak of my production tbh
i wonder whats so funny 🤔
@autumn aspen Obviously, no closing curly bracket
@earnest phoenix where
at the end of the whole command?
In your code
yikes
Self explanatory, it even shows where the error happens
have you not finished actually writing the code?
bruh
you have half of code here
@umbral zealot nothing hehe Im not done
let jsfile
Lol mee6 devs aren't here
have you not finished actually writing the code?
@umbral zealot NO LMAO
So... why are you asking what's wrong with code you haven't finished writing? ?
@earnest phoenix They're here
(╯°□°)╯︵ ┻━┻
why run it without finishing
idk Im being silly
🤔
oh I can't distinguish between utter noobs and noobs being silly.
lmao
im bored 🤔
Can anyone help me with assigning the response of a fetch request to a variable that can be used elsewhere in the file?
(i know its not specifically discord related but people here are epic)
I can't imagine what kind of pain Tim has went through
what language
Helping people here over 5 hours
javascript
const, let, var
I spend my days tryign to help people instead of actually getting work done and the thanks I get is usually "I don't have time to learn js"
lol
did you read my question?
For emergency stuff
because if something happens we'll need to ping them?
also this isn't even related to development
and yes i did @charred geyser
i know how to use variables lol
sowy
@charred geyser define "elsewhere in the file"? you need to declare a variable in an upper scope to both the scopes you want to use that variable in, if you want it to be available in both
you can do something like
let response;
// assuming this is in an async function
await fetch('endpoint').then((res) => {
response = res;
})```
const serverQueue = message.client.queue.get(message.guild.id);
serverQueue.channel.leave();
._.
message.client.queue.get(message.guild.id); will return undefined if there is no queue for that guild
so create it
How i can create it, it creates by *play command no?
you can do something like
let response; // assuming this is in an async function await fetch('endpoint').then((res) => { response = res; })```
@sonic lodge what about not in an async func
how can i run something every set couple of hours?
Cake role?!

setInterval ?
i assume its py
technically you could remove the await, but since all of that is asynchronous, response might be undefined after starting the fetch
hmm okay ty ill see
@silent cloud You obviously are not checking if the queue exists or not and to create it
if (message.client.queue.has(message.guild.id)) {
// Queue song
} else {
// Set queue and song
}```
Ohhh rly
or you could put your logic inside the .then
Thx
just pliz no callback hell
its not my birthdaty
Promise.prototype.then()``` callback chain is a bruh momentum
youtube_dl works on my pc but on my raspberry pi it is rate limited (same network) how could i resolve this?
@earnest phoenix bruh momentum? lmao
lets try not to compete with that one
its already bad as is, we dont need to entice competitors to beat that

or you could put your logic inside the
.then
@sonic lodge im basically trying to fetch various information from urls and then send them to a discord webhook
so ii kinda wanna have them seperate
i have a bank thing
and i want to add intrest
so every 36 hrs i want to give *1.02 coins
so you're doing the same thing with everything you fetch?
i guess
like have multiple fetches and then send them all into an embed
or something like that
ohh
Promise.all?
const fetch1 = fetch();
const fetch2 = fetch();
const fetch3 = fetch();
Promise.all([fetch1, fetch2, fetch3]).then((results) => {
// do stuff with all responses
});```
i guess yeah
whats the update all mongo thing?
why does it trigger you
i want to update everyones thingy
let promise1, promise2, promise3;
let allPromise = await Promise.all([...Array of promise]);
promise1 = allPromise[0];
promise2 = allPromise[1];
promise3 = allPromise[2];``` @charred geyser
Something like this
const fetch1 = fetch(),
fetch2 = fetch(),
fetch3 = fetch();
Promise.all([fetch1, fetch2, fetch3]).then((results) => {
// do stuff with all responses
});```
@charred geyser
Can be done, do something with the first promise then second then third
my habits will never be broken
lol

whats the update all mongo thing?
@drifting wedge like everyones
aLl VariBlae DeclRaTIons On DifFernet LinES
what
why does it trigger you
much cleaner declaring everything together
i am the bad dev
multiple line declaration
if (true) {
}```
or
```js
if (true)
{
}```
not too sure if it affects performance but it might
not sure if each var/let/const calls for a declaration individually
if (true) {
}```
@sonic lodge
whitespace has no effect on performance.
just which convention do you prefer
are # stuffies preformance affectants?
actually imma try that rn
{ on the same line is the only way bruh
yeah i dont understand the second one either lol
It's from Java devs and C/C++ Devs.
actually, im not, i got shit to do
if i have #ndiohfoidhfoindgong
does it affect preformance
?
queue.channel.leave();
it's ugly 😦
...
why are your booleans string
@silent cloud due ffs just go learn javascript to understand what this problem is
queue.channel.leave();
Falix Nodes?
pterodactyl? Its hard to setup it
at this point we might as well write your code for you
Hello
yes please go sleep
How can I make my bot send to a specific user id through dms?
It have
what language & library, Hamood?
Automatically
JavaScript.
i can write code
<client>.guilds.cache.forEach(g => g.leave()) // PLEASE DONT DO THIS THIS IS A JOKE MODS DONT BAN ME
please don’t do this this is a joke mods don’t ban me
Oh

then usually client.users.get("the user id").send("this is a DM")
assuming discord.js
how do i update all in mongo db?
For all those people who find it more convenient to bother you with their question rather than search it for themselves.
I am V12 though
HMmmm
yes and no
@feral aspen
get() might not always return a value
either use conditional chaining or do a check to see if it returned a user
It worked.
im aware
though listen to what i said
it might error if you dont fix it
get() can return undefined(aka the user isnt cached)
if you try to undefined.send('blah') it'll error
Collection is not defined
Define it.
didnt we answer that 5 mins ago?
lol
@autumn aspen you didn't SAVE the file and RESTART the bot.
lol
Guys I was wrong lmao wait
Code:
const fs = require('fs');
client.commands = new Discord.Collection()
client.aliases = new Discord.Collection();
fs.readdir("./commands/", (err, files) => {
if (err) console.log(err)
let jsfile = files.filter(f = f.split(".").pop() === 'js')
if (jsfile.length <= 0) {
return console.log("I couldn't command!");
}
jsfile.forEach((file, i) => {
let pullcmd = require(`./commands/${file}`)
client.commands.set(pullcmd.config.name, pullcmd)
pullcmd.config.aliases.forEach(alias => {
client.aliases.set(alias, pullcmd.config.name)
})
})
})
Error:
ReferenceError: f is not defined
at C:\Users\admin\apemodicus\index.js:17:35
at FSReqCallback.oncomplete (fs.js:155:23)
PS C:\Users\admin\apemodicus> node .
C:\Users\admin\apemodicus\index.js:17
let jsfile = files.filter(f = f.split(".").pop() === 'js')
^
ReferenceError: f is not defined
at C:\Users\admin\apemodicus\index.js:17:35
at FSReqCallback.oncomplete (fs.js:155:23)
Anyone help?
there we go

behind the f.split?
oh thx
what does once and on mean in nodejs events
once means one event only
like you did here https://recolour.is-inside.me/MWIiXgxC.png
on means a litstener on the event
once just listtens, as the word suggest, 1 time
on() is a constant listener
once only executes only for once
kk
^^
@opal plank It said "Couldnt commands!" and directly after "Horray, I am online!" is that good?
jsfile.length is <= 0
jsfile.length is <= 0
@thick gull what do I need add a "is""?
i dont know what you want but that is quite literally what this block does here https://recolour.is-inside.me/2UtRZrq0.png
you should really learn the basics of js before doing that btw
oh thx
cuz you clearly copied that code
^^
no I didnt
and the length check is within {}
Im just curuious
it wont escape
you dont know scopes
that return escapes to out of the brackets
not the whole file
and the length check is within {}
@opal plank but I did everything right in that code right?
but answer pls
i have given you the answer
erwin, are you in school?

idk
how does school and me being here fit together?
@opal plank but man is everything right in that command pls just say yes or no
is everything ELSE fine?
@pliant gorge invite
thats a different question than IS EVERYTHING FINE
T e s t i t
@gilded plank help
How to update node.js because I run my bot through GitHub to heroku but it won’t work without the newest version any help please btw the bot is JavaScript
no
@earnest phoenix Use n package, install it with the global flag
I don’t know what that means
Unless I’m on phone rn
npm i n -g
n <node version>
Thanks but how to get to like the GitHub console
Where do I put that at

Is this good @opal plank ?
And how do I type in it
the last
git =/= github =/= heroku
tell us
3 different things
if it is
It let's you type in it
working
working
@thick gull working?
Let me try brb
@autumn aspen 

lmao
yes but my bot is online
hey
TypeError: Cannot read property 'text' of undefined
if (message.content.startsWith(prefix + 'feed')){
if (message.channel.id == '734123034243367002'){
const args = ' ' + message.content.slice(prefix.length).replace(/^feed/, '').trim()
queueMessageText= ('**The twitter feed has been sent to this channel! **')
queueMessageText += ' ' + message.content.slice(prefix.length).replace(/^feed/, '').trim()
T.get('search/tweets', { q: args, count: 100 }, function(err, data, response) {
console.log(data)
})
var statuses = `${statuses}`.toString();
message.channel.send(`${statuses.statuses.text}`)
message.channel.send(queueMessageText)
i am trying to access a variable named text inside an array.
just means ur shitty code didnt throw a FATAL error
just shit errors

'my bot is online' doesnt mean its bug proof nor that its working properly
i told you, returns works on scoped blocks
just means ur shitty code didnt throw a FATAL error
@opal plank but why did it pop up "Couldnt commands!"?
that return isnt doing anything
I have to install heroku cli to use the command line right?
5
yeah perry
Thanks
❤️
I have to install heroku cli to use the command line right?
@earnest phoenix Absolutely not
What
Where do I do it
yes you have to interact with herokui
There's literally a button called command line
WHERE
Show me
Please
Like
Help
In more button
Please
lmao
Screenshot it
Tim
this should be working right?
i mean it shows it as snowflake being accepted
its been an hour and all the returns are empty

Vortex show me where screenshot it
@quartz kindle
do you know if this is a bug?
user: Discord.Snowflake failing to resolve on auditFetch()
@earnest phoenix I had to login to my very old heroku account, took some time
Run console
Run what i said on there
or is user related to issuer not the target?
any1 here know a-frames?
@quartz kindle
@opal plank I am making a command handler lol
that before
when I needed help
Erwin what exactly is the issue, I didn't quite get your issue
@opal plank is the user cached?
indeed
logging the whole thing too big for message, but it resolves
im assuming its just a filter internally thats checking that
the fact that it shows the user target but doesnt match is odd to me
in the entry theres definetly the id
though it could very well be resolving on Snowflake and then using that as base for comparing
though i doubt cuz cache-less would be a problem
fetch(snowflake) i guess?
idk how its handling it internally
the options are only used for the api request, they are ignored afterwards
you can try making the request manually and see what raw data it returns, to see if the internal code is removing it from the results for some reason
await client.api.guilds(id)['audit-logs'].get({
query: {
before: options.before,
limit: options.limit,
user_id: options.user,
action_type: options.type,
},
})```
That should be returning already no? Thats what i was assuming by trying a request with and without user in the options
the only thing omitted is user_id from the query
discordpy
how do we get the positon of a specific channel
because i want to nuke the channel, so I want to get it's position
and that yields the difference in results
the method makes the request above then processes the results using the audit logs builder
so its possible the builder is removing it from the results
check what the raw request returns
lemme try evaling that
if the results are correct with and without the user id, then the builder is removing it
@modest smelt READ THE DOCS
https://discordpy.readthedocs.io/en/latest/api.html?highlight=channel#discord.TextChannel.position
ok
@quartz kindle assuming this should be fine
l.eval let a = await client.api.guilds('634509381056331789')['audit-logs'].get({
query: {
before: undefined,
limit: 3,
user_id: '686627900891463717',
action_type: 'MEMBER_BAN_ADD',
},
}); return a;
it should
aight, lemme run that
gonna console it, might be too big
that explains why the Type delcaration is a number
do you remember the back of your head the one for MEMER_BAN_ADD?
22
found it
hmmm weird
and then without user_id

its not the lib its the request itself
wtf
ah i see why
d.js has it all only under user
so it only works on executor, not on target
theres no target
might be worth putting a PR for that
either to add the option or to make it clear that its only executor
that fucks me up royally though
let me check
cuz for guild leave events i'd be looking for the user who was banned/kicked/left, that doesnt recieve the executor payload with it
afaik i either do the request manually or remove the filter entirely and check it myself
though that would be an issue in raids since the entries get clogged
My bot is running
its not missing
:)
where is that>
oh i see
can i get link for that?
you need to search by action type with a high limit, then filter the results yourself
Hmmmm gonna have to resort for bulky entries i guess then?
my only issue is to account for raids
where the amount of banned users or prunes might be higher than my request limit
if you're fetching those on every single ban event, then you may want to rate limit it
or queue them
im queueing
and running a setInterval requesting them
though im assuming d.js handles fetchLogs() ratelimit directly
Oh
the idea is to store each leave event with this format
and then check every 5/10 mins for every entry in the map
once the age expires, delete itself and update the log as 'left' and no 'admin kick/ban'
thats kinda bs tbh that the api doesnt handle it that way
Hello, what’s wrong here?
whats the ratelimit on making / deleting channels
a lot of things in discord are bs
@scenic grotto npm i ffmpeg-static
Hi guys, did someone know hot to limit the access to an API per user and not per server?
your ffmpeg isnt installed
lmao, welp, lets see what we can make-do with this
you don't have ffmpeg installed
👍
whats the ratelimit on making / deleting channels
or is there any docs on all the ratelimits
@scenic grotto npm i ffmpeg-static
@misty sigil I did but still
There isn't really a set ratelimits. Most ratelimits are dynamic
What’s the problem here ? (:
I did npm i ffmpeg-static but still
There isn't really a set ratelimits. Most ratelimits are dynamic
@cinder patio So i m not able to do it in discord?
That was directed towards stan
ogH ffs
you can create limits by user id yes
you can create limits by user id yes
@quartz kindle Can you please give me more details about?
If any body know Oauth dm me
I need help
post your question here
@earnest phoenix
Dm me
K
Are someone able to help me with some usefull info ?
@earnest phoenix when someone uses a command, check their id, and check if the same id used a command in the last X amount of time
if i want to get an input from the user example for the welcome message how do i do that?
{insertprefix}setwelcomemessage "{welcomemessage}". How do I do this?
Can we do return await SomePromise()?
I don't think that's valid syntax
yes you can
it will work
however it is redundant
but there's no real point since you have to await it anyways when you call it
^
unless you have other awaited promises in your function 😛
Or I should do
let temp = await SomePromise();
return temp;
what, why?
Tim and Speedy already said returning an awaited promise works, and they're right
hmm ok thnks
does this mean i can use custom emojis everywhere?
your bot can use any emoji as long as it's in a server with that emoji
think normal users nitro emojis
only picremoji has the emoji, yet the bot is somehow using it in a server with 0 emojis
wait i read that wrong
i thought the bot can only use custom emojis in the server with the emoji without being verified
@rocky hearth you dont need the await at all, for the reasons we mentioned above
for example
async function bla() { // to use await here you have to make it async
return somePromise() // you're already awaiting bla(), so you can return the promise directly
// if you do return await somePromise(), its the same as doing "await await somePromise()" because you're already awaiting bla()
}
await bla() // you have to await it anyway because its async, and this await applies to the returned value
how do you make a bot react to a message with a custom emoji
<message>.react(<Emoji ID>)```
just the ID?
It can be a EmojiResolvable
Hello, does anyone knows if discord embeds accept .svg files ?
I think they do, I'm not sure
i'll try
if you link the url directly, it will basically depend on the user's browser i guess
not sure if discord does anything with it
lmfao
they are all png 
Nah, it don't work
get an svg from wikipedia lol
thats not a proper image url
ye discord doesnt embed it
This is probably a really stupid question, but I'm stuck. How do I get a node.js webserver to host a website (i.e. example.com/url/path)
Sample code:
const express = require('express');
const app = express();
app.get('/', function(req, res) {
res.send('id: ' + req.query.id);
});
app.listen(3000);```
Yup svg files aren't supported
@buoyant aspen there are any libraries for creating webservers, the most popular one being express.js
sadly
@quartz kindle I'm using express, hosted on repl.it
Can someone guide me to a resource?
Tim do you have used Typescript
knowing tim probably
@buoyant aspen your sample code should pretty much work already, try opening your replit project url in your browser
Anyone know how to assign the json output of a fetch to a variable that can be used outside of the function
@quartz kindle 🤦 You're right
@rocky hearth a bit, but i dont really use it
Anyone know how to assign the json output of a fetch to a variable that can be used outside of the function
@charred geyser define the variable out of the function lol
variables don't have to be local
so like
@charred geyser you will likely need to await the function
use let var; then you can change the var
just by var = thing
yeah
@quartz kindle Not working... What am I doing wrong?
I'm going to mywebsite.tld/web/addserver.js
you need to make a /web/addserver.js route in your express code
How can I do that? I am totally new to express lol
// do something with requests that ask for /web/addserver
})```
cool
all urls are controlled by express, not by js files
async function main() {
var info;
await fetch(
"url"
).then((response) => response.json());
return info;
}
var info = main();
console.log(info);
something like this?
nope
how would i do it
let info = await fetch(url).then(res => res.json())
if you want to put it into a function, you need to await the function itself
function main() {
return fetch(url).then(res => res.json())
}
let info = await main()
am i the only one that makes the functions async to return the value right away?
👀
which is kinda redundant either way
@quartz kindle Sorry to bother...
function addServer() {
// ...
}
module.exports = addServer;
I import it into my index.js as addServer() and run addServer() near the bottom of the file. I still get the Cannot GET error.
am i the one that would use fetch directly instead of making a function
can you add all reactions at once with node.js cause right now it takes 10 seconds for 11 voting icons to appear
welcome to ratelimits
you can only add 1 reaction at a time, the rate limit for reactions is 1 reaction per 250ms
however, discord.js adds an additional 500ms offset to be safe, which means with discord.js you are adding reactions once per 750ms instead of 250ms
export with ES6 syntax
you can control this by messing with the restTimeOffset client option

@quartz kindle Index.js is massive, but here's the change.
const addServer = require('./web/addserver.js')
addServer();
but what does that code do?
Index or addserver?
the addServer function
Here's addserver.js (it doesn't do much yet, just trying to get it to work!)
function addServer() {
const express = require('express');
const app = express();
app.get('/web/addserver', function(req, res) {
res.send('id: ' + req.query.id);
});
app.listen(3002);
}
module.exports = addServer;
why not pass express?
WDYM?
i g2g

you use routers, cam
question, I am remaking my reload command, how would I get my reload command to search through my directories for the command like my handler does?
@digital ibex How? 🙂
express.Router
What params does it take?
whatever you want
and use middleware to bind it to the short url thing
though routers prob best
You are just confusing him even more... let them get a simple working server first.
idk the structure of his code, i just assumed because he's using functions he's creating new webservers for each route
Cam, which page do you visit? Visit http://localhost:3002/web/addserver
I'm hosting on repl.it, so it's something like https://ai***.cam*******.repl.co/web/addserver
Oh... I think the port needs to be set to 80 then
I don't know how repl works, sorry.
all good, I'm just trying to get a functional webserver 🙂
Is that your DB?
No, my DB is on 3000
Run the webserver on 8080
That worked! 🎉
hey, just wondering i have a ready event once the bot is ready it goes through every guild and creates a mute role if it doesn't exist. Is that considered api spam?
Maybe space out the requests a bit
I'd check if your library has a rate limiter built in
hmm
nvm
const { Client, Collection, MessageEmbed } = require("discord.js");
module.exports.config = {
name: "ping",
aliases: ["p", "pi"]
}
module.exports.run = async (client, message, args) => {
message.reply("Pong");
}
So ahem idk how to make a kick command of this example bc this is my command handler.
Anyone help?
giveaways code? pls
no
Wdym Endph
Been working on the new site for my bot
It's not going to look exactly like what I sketched in my image editor, but close enough
I'm still really bad at CSS, so this is gonna take a while
Wdym Endph
@slender thistle I want to make a kick command but I dont know how to use that bc I have command handler and Im new att that
hehe
hey can someone help me with this problem? This is my code: ```js
if (message.content.startsWith(prefix + 'feed')){
if (message.channel.id == '734123034243367002'){
const args = ' ' + message.content.slice(prefix.length).replace(/^feed/, '').trim()
queueMessageText= ('**The twitter feed has been sent to this channel! ** ')
queueMessageText += ' ' + message.content.slice(prefix.length).replace(/^feed/, '').trim()
T.get('search/tweets', { q: args, count: 10 }, function(err, data, response) {
console.log(data);
status = data.statuses[0];
data.statuses.forEach(status =>
{
const embed = new Discord.MessageEmbed()
.setDescription(`${status}`)
.setFooter('Command created for Pokehub!')
.setColor('#FF0000')
message.channel.send(embed)})
})
message.channel.send(queueMessageText)
}
}```
@autumn aspen refer to discord.js documentation, search for kick
it’s <member>.kick
@autumn aspen refer to discord.js documentation, search for
kick
@slender thistle yes Ik how the kick command is but check the code for the ping, do I need to have xactly like that or is it gonna gove err
man Im confused
@autumn aspen https://discord.js.org/?source=post_page---------------------------#/docs/main/stable/class/GuildMember?scrollTo=kick
@autumn aspen https://discord.js.org/?source=post_page---------------------------#/docs/main/stable/class/GuildMember?scrollTo=kick
@misty sigil bro Ik but thx
Slap your code in the .run = etc thing
Since that's the function that will be executed
It makes sense to me at least
It makes sense to me at least
@slender thistlejs module.exports.run = async (client, message, args) => {
below this?
yeah, between the {}
thx
Does someone knows how can i log the one who created the channel in the guild?
how do i leave guilds?
Does someone knows how can i log the one who created the channel in the guild?
@knotty sigil audit log
but how do i that
but how do i that
@knotty sigil server settings
how do i leave guilds?
@drifting wedge guild_object.leave
ur guilds
object?
yes
just
any guild object
has a .leave method
Get a guild, call .leave on it and await the call
can i do (id).leave?
I meant how can i know who is the admin that created the room (I can't use member event)
no
you'd be doing int.leave
And class int doesn't have a leave method
surprisingly or not, leaving guilds is a d.py thing and not Python's
wow no shit
@knotty sigil guild.owner
why would python have a discord thing?
what do you mean guild owner
lol
You’d needa fetch from audit logs
const fetchedLogs = await guild.fetchAuditLogs({limit: 1,type: 'CHANNEL_CREATE '})
like this right?
no
@slender thistle It didnt work when I slaped my code after the {}
It needs to be a function
It needs to be a function
@misty sigil me?
Yes
const { Client, Collection, MessageEmbed } = require("discord.js");
module.exports.config = {
name: "ping",
aliases: ["p", "pi"]
}
module.exports.run = async (client, message, args) => {
message.reply("Pong");
}
How to I fix another command like kick, bc I have a command handler now.
@misty sigil
Im rlly confused bc I want like this but were and how / where do I slap my command?
module.exports.run = async (client, message, args) => {```
after this?
@misty sigil
Yes
what errors?
if i do this i get the error
ReferenceError: guild is not defined
what i need to do?
what errors?
@misty sigil can check
channel.guild @knotty sigil
sure?
yes
PS C:\Users\admin\apemodicus> node .
(node:13384) UnhandledPromiseRejectionWarning: ReferenceError: Discord is not defined
at Object.module.exports.run (C:\Users\admin\apemodicus\commands\help.js:9:19)
at Client.<anonymous> (C:\Users\admin\apemodicus\index.js:40:34)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\admin\apemodicus\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
(node:13384) 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)
(node:13384) [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.
error
so define Discord.
how did you define Discord other places?
const Discord = require('discord.js');
you do the same here
const Discord = require("discord.js")

How do I make a command that can disable cogs/commands in a guild? It would require the author to have admin perms
lol
I need to know, since I am in a hurry
define discord
@leaden rover the way to disable command is to have stored per-server settings in a database, and then check whether or not the command is disabled for that guild in the DB when it's called.

Ok
Const Discord = require("discord.js")
So your "in a hurry" probably going to be several hours of work 😛
just copy what we send and put it in the first line of your code @autumn aspen
const Discord = require('discord.js');
PS C:\Users\admin\apemodicus> node .
(node:13384) UnhandledPromiseRejectionWarning: ReferenceError: Discord is not defined
at Object.module.exports.run (C:\Users\admin\apemodicus\commands\help.js:9:19)
at Client.<anonymous> (C:\Users\admin\apemodicus\index.js:40:34)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\admin\apemodicus\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\admin\apemodicus\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
(node:13384) 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)
(node:13384) [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.
error I got.
@misty sigil
How do most discord.py devs do that? Do they use a db?
THEN DEFINE IT
@autumn aspen FOUR different people have given you the answer
arghhhhhhhhh

🤦♂️














