#development
1 messages ยท Page 1829 of 1
can you please not send a screenshot
and copy paste the code on Discord
It helps us to see
oh sure
@client.command()
async def equip(ctx, *,item_name:str):
cnx, cursor = make_connection()
item = item_name.lower().replace(' ','_')
query1 = 'SELECT %s FROM inventory where user_id = %s'
cursor.execute(query1,(item,ctx.author.id))
result = cursor.fetchone()
if result[0] == 1:
query2 = 'UPDATE economy_data SET equi_item = %s'
cursor.execute(query2,(item_name.lower().replace(' ','_'),))
cnx.close()
else:
await ctx.send("You don't have {} in your inventory.".format(item_name))
cnx.close()
@near stratus
did you mean the typo in equi_item
there isnt a typo in equi_item
not that i know of
the entire problem is that instead of getting the result as a 0 or a 1, iget it as the column name
i see
How would I go about sending a user a message for upvoting my bot.
I have a webserver detecting the upvote webhook but it's not linked to the bot, and the bot is also sharded.
How would I send them a thank you message for upvoting?
I mean
event
is there
eh
oh, im not on about upvoting on this servers website btw
on about another one lmao
events
is your issue from the fact that your bot is sharded
take it or leave it
Well yes, because I would have logged in using the token in the webserver and i'd have access to the client then.
Can you use node-fetch ?
But since it's sharded, I cannot do that
i see
for each instance of your bot you should be able to make it listen for the upvote webhook
broadcast that to your bot instances and have each one search for the user in their cache
if a match is found try to dm them
thats what im thinking
Also, since it's sharded, if the user is in multiple servers across different shards, I don't want the message being sent twice
hmm this is also a valid concern
yeah
I could cache incoming votes, like so:
[
{
"discord_id": "DISCORD-ID",
"type": "upvote"
},
{
"discord_id": "DISCORD-ID",
"type": "donation"
}
]
Create a DM by sending POST to
discord.com/api/users/@me/channels

also is it not possible to call this directly from the library hes using
has to be node-fetch?
id think if its a wrapper this would have been the first thing he looked at
there should be a function that covers that
node-fetch, axios, request all should work
node-superfetch idk
including unirest?
is that a tennis ball
never heard of that
Pretty much does what they do lmao
does it send POST request ?
Yup, so i'm assuming it'll work lmao
with headers ?
what library are you using btw
then it'll work
djs
Create a post request
url: "https://discord.com/api/users/@me/channels"
method: "POST"
headers: [
"authorization": "Bot YOUR_BOT_TOKEN"
]
value: {
"recipient_id": "THE_USER_ID"
}
no url parameters?
it says there is on the site
/channels/{channel.id}/messages
or am i looking at the wrong one lol
and if it is that one, then would channel.id be replaced with the users ID?
you can send message after the dm has been created
First do this and create a DM
Then send message to /channels/ID/messages like a normal message
Okay
Thanks
How would I check if the DM creation is a success?
before sending the message
Then create another post request to /channels/{channel.id}/messages
url: "https://discord.com/api/channels/{channel.id}/messages"
method: "POST"
headers: [
"authorization": "Bot BOT_TOKEN_HERE"
]
value: {
content: "Pooooooooooooooog"
}
thanks
np
Would channel.id be the ID i receive from the last request?
it should be the user id
not sure tho
Hello how to send embeds in inline replies? I'm using raw api. I assume we need to create a embed and
client.api.channels(message.channel.id).messages.post({
type: 1,
data: {
content: embed,
message_reference: { message_id: message.id }
}
})```
Correct?
Text for what?
so dont add content
yes
ty
why doesnt this code remove the muted role and send a dm while i dont get any error? https://srcb.in/3JBgKKMP25
that code is generating an infinite amount of timers lol
oh shoot
what did i do wrong
also this is not a thing (await guild.members.fetch()).get(userId)
the fetched member is already a member
there is no member.get()
wait, you're fetching ALL members?
why?
but how is it generating infinite timers
you have this
is this better? (await guild.members.cache.fetch(userID))
setInterval(() => {
function abc() {
setTimeout(abc, 600000)
}
abc();
}, 30000)
the interval calls abc every 30 seconds
then abc itself calls itself every 60000 seconds
oooh
member = await guild.members.fetch(userID)
.get() only works if the member is cached
oh k
@quartz kindle will everything in this ready event work? https://srcb.in/y7GdQCWZoz
cuz it still doesnt update the mutes
you're not waiting for mongo to connect
async () => {
await mongoose.connect();
// do stuff
}
or
() => {
mongoose.connect().then(() => {
// do stuff
}).catch()
}
.cache.fetch doesnt exist
its either .cache.get() or .fetch()
can someone help, when i add a .js file to my commands folder then do node . to run it in the terminal i get a err.
well, what error?
thx
your props variable does not have a help property
@quartz kindle https://srcb.in/ckvhJr74t7 still doesnt work :(
interaction.reply({
content: connectFour.toString(),
components: [
{
components: Array.from(Array(5), (_, i) =>
new MessageButton()
.setCustomId(`col_${i}`)
.setLabel((i + 1).toString())
.setStyle("PRIMARY")
),
},
],
})
Why im getting this error, for above code
Does someone know how to create multiple command files like commands/mod/kick.js
commands/music/play.js
const commands = readdirSync(join(__dirname, `commands`)).filter(file =>
file.endsWith(".js")
);
for (const file of commands) {
const command = require(join(__dirname, `commands`, `${file}`));
if (typeof command.name === "object") {
command.name.forEach(x => {
client.commands.set(x, command);
});
} else {
client.commands.set(command.name, command);
}
}
its my command handler
the issue is you're filtering out all your sub folders/categories
well that is your issue at hand
you first read all the files and directories in commands
then you filter them out so only .js files remain
then you try finding all commands in the category
see the issue
your categories were filtered out
try like this
@earnest phoenix
export async function getFiles(
directory: string,
extension: string,
subdirectories = true
): Promise<Array<string>> {
if (subdirectories) {
const dirents: Array<fs.Dirent> = await new Promise((resolve, reject) => {
fs.readdir(
directory,
{ withFileTypes: true },
(error: Error | null, dirents: Array<fs.Dirent>) => {
if (error) {
reject(error)
} else {
resolve(dirents)
}
}
)
})
const names: Array<string> = []
for (let folder of dirents.filter((dirent) => dirent.isDirectory())) {
const files = await getFiles(`${directory}/${folder.name}`, extension, subdirectories)
for (let name of files) {
if (name.endsWith(extension)) names.push(`${folder.name}/${name}`)
}
}
for (let file of dirents.filter((dirent) => dirent.isFile())) {
if (file.name.endsWith(extension)) names.push(file.name)
}
return names
} else {
const names: Array<string> = await new Promise((resolve, reject) => {
fs.readdir(directory, (error: Error | null, files: Array<string>) => {
if (error) {
reject(error)
} else {
resolve(files.filter((file) => file.endsWith(extension)))
}
})
})
return names
}
}```
its shit but it works
unless music is also paired with a file like music.js
that's some massive spoonfeeding
why is this not working, it creates string[] but i cant access any values
it logs empty line
split(" "), seems to hv 2 spaces? No?
are your logs being redirected elsewhere
This is so confused me
And that one too
its very basic but if (command_file.js) matches command_name
it loads file and executes main() from command_file
Can i use like that const cmdFiles = ["mod","music"]
Join dirname, cmdFiles.forEach(x => x.filter
nooooooooooo
something like this?
cmdFiles.forEach(x => {
require(x).function(something, bruh);
});
^^^^
I really dont understand this command collector
you cant add buttons directly to the message
you have to add an action row
then add buttons to the action row
const commands = readdirSync(join(__dirname, `commands/${cmdDirs}`)).filter(file =>
file.endsWith(".js")
);
for (const file of commands) {
const command = require(join(__dirname, `commands/${cmdDirs}`, `${file}`));
if (typeof command.name === "object") {
command.name.forEach(x => {
client.commands.set(x, command);
});
} else {
client.commands.set(command.name, command);
}
}
I want to do like this
are u getting any errors or
I get error on this
No such a file or dir not found commands/music,mod
I need to use foreach for queue them but dont know how to use on it

try to make your own command handler so u can do wtf u want ๐ณ
I am using this
Actually it works like i want
I need to duplicate it for each folder
maybe make 2 commands
commandsMusic = readdirsync..
commands = readdirsync...
then u can easily separate em
for(const folder of folders) {
const files = fs.readdirSync(folder);
for(const file of files) {
const command = require(`${folder}/${file}`);
}
}
https://srcb.in/ckvhJr74t7 this code still doesnโt work, no error just doesnt work
you're still doing infinite timeouts
remove setTimeout(checkMutes, 1000 * 60 * 10)
did you check if your variables are correct?
add some console.logs to see if the code is working as expected
for example put a console.log inside the if(results && results.length)
to see if there are any actual results
@quartz kindle Got around to trying if a different user agent worked for requesting googlevideo urls and it didn't, so. Still left clueless
Not asking you to do anything about it, just letting you know
well rip
I'm currently using
message.channel.send('Long code snippet', {code:'xl'})
How would I go ahead and use that when I use interaction.reply()? Sending it like above will just send it as regular text, not wrapped into code tags
Adding ` could be an option but is there a way to use {code:'xl'} in interaction replies?
it was removed altogether in v13
just insert the codeblock directly into your string
You could just make a function that inserts ``` before and after the string you pass in, if you're worried about readability
I prefer doing js message.channel.send( '``\`js\n' + code + '\n' + '``\`' )
damn it I hate code blocks in code blocks
hey! How would i save all the messages from a textchannel to a txt file?
practically, you can't
theoretically, keep fetching all messages in the channel until you hit the beginning on the channel and then just format and save
this is often going to lead to ratelimits, api bans etc.
can take a day or more to finish
it's possible, not advisable
just pass ur command's foldername to the function. You'll get all the files in all nested folders
const cmdF = ["mod", "music"]
cmdF.forEach(x => {
const commands = readdirSync(join(__dirname, `commands/${x}`)).filter(file =>
file.endsWith(".js")
);
for (const file of commands) {
const command = require(join(__dirname, `commands/${x}`, `${file}`));
if (typeof command.name === "object") {
command.name.forEach(x => {
client.commands.set(x, command);
});
} else {
client.commands.set(command.name, command);
}
}
});
I did that
Thanks for whoever tried to help
aww sad, tyvm for the answer tho
Then can anyone show an example using the raw api in python ?
which api
oh whoops wrong channel haha
Yoo.
I have this !buy command code whereas it would take from this array of objects called items...
module.exports = [
{
id: "attitudecoin",
aliases: ["coin"]
},
]
const embedError = new MessageEmbed()
.setColor(red)
const itemToBuy = args[0];
if (!itemToBuy) {
embedError.setDescription(":x: Please mention the item ID that you want to buy from the shop.");
return await message.channel.send(embedError);
};
const validItem = !!items.find((val) => val.id.toLowerCase() === itemToBuy);
if (!validItem) {
embedError.setDescription(":x: The item ID you entered is invalid.");
return await message.channel.send(embedError);
};
You see up.. I made it return a boolean whereas if the item is not valid.. then it would return by checking for its id.. but what tip do you guys give me for checking its aliases as well?
I've seen .includes() work.. meaning to check for aliases in this code. items.find((val) => val.aliases === itemToBuy)
.. not sure how to check for the aliases as well.. little help.
do you also need to use the item later, or do you only need to validate and nothing else?
It's a buy command.. just checks if the item is valid.. if not return.. or else it would do the rest of the code (purchasing, incrementing, etc)
My only concern is how to merge aliases.
I know checking aliases first is the first step or else it would just return from the very beginning.
val => [val.id, ...val.aliases].includes(itemToBuy)
only works if all items have aliases, or at least [] if they have no alias
First time seeing this.. what exactly does this do.. and why the commas?
if you have items with no aliased field at all, you can do val => val.aliases ? [val.id, ...val.aliases].includes(item) : val.id === item
the commas are the spread operator
they "spread" the items in the array
for example
[1,2,3, ...[5,6,7]] = [1,2,3,4,5,6]
Yup.. rest operator and spread operator.
yes, they have two names, because they do different things in different situations
Merging multiple values in an array and spreading an array into multiple values.
ye
^^^
This basically checks if the id or the list of the aliases array includes the items I mentioned to buy, right?
yes
Works only if all items have aliases.. so by using the ternary operator to check if the item has alias.. I can apply the code or else I would check for the ID only, right?
yup
Sweet sweet.. thanks! ๐
and for the case check, its better to convert the case of the user input
so itemToBuy.toLowerCase()
Yup.
const validItem = !!items.find((val) => val.id.toLowerCase() === itemToBuy);
..toLowerCase()
val => val.aliases ? [val.id, ...val.aliases].includes(item).toLowerCase() : val.id.toLowerCase() === item
if val.id is made by you, then you can guarantee all of them are lowercase, so you dont need to case check them
unless the vals can be created by users
.. no, created by me.
not like this
I did something wrong?
you case check the item that the user gave you
not your items
val.id === item.toLowerCase()
.includes(item.toLowerCase())
Oh.
Wait..
.. my bad. ๐ I've been making the ID in the object lowercased instead of the input of the ID made by the user.
ye xd
๐
hey
so i have an array ["a", "b", "c"]
I want to make a switch statement whereas those cases are those elements in the array
is it possible?
based on the index of the elements?
Im trying to speed the process
instead of writing
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
I do an array
I can't have 26 of them in a row. ๐
you could try chunking the elements in the array every x elements?
so what are you trying to do exactly
a bit more detail
there is definitely a better way to do whatever you're trying to do
I have this code.
instead of doing it like those.. I want to put the cases in an array and make a case whereas if this case is one of the elements in the array, then it would execute the code I specified
you can try
if you do it faster than me:)
actually
fuck i need to test the code before i say something
If you switch to one case with 26 possible matches as you said youโre probably doing something wrong.
well the array of 26 indexes are the cases ...
instead of writing 26 cases.. i make one case which this case is considered as one of the element in the array
What does the array store and in which form?
i want to do something like this
yeah there is no clean way to do it with switch statements
instead of case a, case b, case c, I do case [either a, or b, or c]
really sucks.
Sad side of Javascript. ๐
Still dunno why you would check 26 possibles cases.
What does the array store and in which form?
yeah we need more context
FakE, i appreciate the help.. turns out it doesnt work
Well tbh I canโt help. I missed the context or you havenโt told us what I wanna know yet.
Can you give us an example of your array with some accurate items it stores?
Well..
what exactly do you mean with a switch case here?
Nobody knows 
what is the connection with each value in the array?
what is the switch case supposed to with each of those values?
You see in switch statements how you do something like..
switch (val) { case "a": case "b": case "c": case "d": case "e": }
This can sometimes get very unorganised especially when having a lot of cases.. like 30 or 40.. so he's trying to see a way whereas instead of doing this.. he would check with one case and this case checks in the array if it equals to one of the indexes like case ["a", "b", "c"]
myth: js developers can read peoples minds
Is this what you mean, Chill?
["a", "b", "c"].includes(item) is an option.
yes yes yes.. ^^^
yes but... what does each case do?
He meant in cases in switch statements.
Probably all the cases does one code.
when simplifying code, you have to look into repeated patterns, so you can join them and reuse them
if each case is doing something completely unrelated, you cant simplify
so it depends what each case does
Instead of checking 26 similar cases, check all others and use default as case
.. all the cases does something equal.
Meaning case "a", "b", etc.. does the same code.
If a, b, c does the same, then check d, e, f as case and use default: for the rest
hamood's example, this. ```js
switch (val) {
case "a":
case "b":
case "c":
case "d":
case "e":
console.log("Successful.")
};
as in easy
.. but the half of the entire alphabets
Weโre still missing an example with accurate items the array will store
Yeah.. 13 cases is kind-of too much.
so basically if val matches any of those, run something?
Yup.
yes
if(["a","b","c"].includes(val)) { run something }
doesnt work for switch statements?
wdym doesnt work for switch statements
Who says you have to use a switch statement lol?
No it does not as it iterates through the array
switch (val) { case ["a","b","c"].includes(val): console.log("Succeed"); }
doesnt work like that?
no that doesnt work
Makes no sense
it works if you do switch(true)
If your case isnโt another array
very confusing
nope
works for if statements but not for switch, makes sense now
if you do switch(true) you can override the cases with your own logic
but at that point its just a glorified if else
No it does not as it iterates through the array
alright
the way a switch works is that the case is compared to the value you put in the switch
switch(123) {
case (is this 123?):
case (is this 123?):
case (is this 123?):
}
so if you use true, it becomes more flexible
switch(true) {
case (is this true?):
case (is this true?):
case (is this true?):
}
meaning you can put anything in there, as long as it evaluates to true
Hi
Which is probably the ugliest form you can use
yes, its just a glorified if else
but with very long and completely unrelated conditions, it can be better than if else
more organized
I want code when bot enter for a server kicked
Imagine putting an extra line for each case for the break
I did not enjoy an achievement
@earnest phoenixwhat? i did not understand anything you said
He said he wants code, so give him code! 
yes, gimme all you are py code
You will get exactly 0 lines as nobody uses python eww
(I (only (have (parentheses (for (you))))))
though I have some python for you, but you can't see it
I use dynox rn to host my bot on there Free VPS option i want to switch to a place that is really cheap but cheap enough for a good amount of memory ect any suggestions
https://contabo.com/en/ maybe
though i dont know what kind of tactics they use to keep prices low
would rather not know
plot twist they use sd cards
capable of 100mbps+
you could actually do that
i wanna do that now
the smallest wannabe ram
with good enough ssds you get near-ram speeds
the problem is randomness
ssds are not good at that
you can get ssds working at 2-3gbps, ram works at 20-30gbps
put 4 ssds in a 4-way raid, you're already at 10-15gbps
not too far
but thats mostly sequential speed
once ssds start doing random access like ram does, the speed crumbles
lol the amount of IO will kill it very fast anyway
actually wont that be more expensive than just directly buying huge amounts of ram
lmao
since you're having to replace ssds
in the long run probably
but in the short run, you can sell petabytes of ram in vpses
xD
lmao
seamless ssd rollover
Yeah probablyโฆ
Recently upgraded my ECC RAM in my server which was expensive 
random access memory more like direct access memory
put all your ssds as ram, and run the entire system in a ramdisk
sell a vps wth 10gb ram and 0 disk
lol
damn
that rw head be dancing up inside there
its amazing how reliable hdds are considering their architecture
Also depends on the architecture and cache
Good NAS HDDs can last 2 decades or more
At least my HDD do
thats a long time
at this point im just waiting for my hdd to either fail or a smart alert to pop up
Yeah and still a RAID1
usual commercial hdds apparently last around 2-6 years or longer
*but
if you dont spend too much
For reasons
Yeah I only trust Seagates Ironwolfs
WD Red is a good Choice as well
Expensive but reliable and up to 10y of warranty depending on the package you buy
hdds these days ship with 1 year warranty
absolutely terrible
i've had great results with WD Reds tho
terrible results with Seagate barracudas
blah man
Thatโs what I heard, too
Thatโs the reason Iโm using the Ironwolfs for a lot of years already
why I can not
make muen MessageOption
did you mean .setLabel
MessageMenu doesnt have a .setLabel?
Does anyone have an idea if per-guild avatars on the discord api are finalized, or still being worked on
There is a pr on the discord api docs repo highlighting this change but they noted that they want to wait until it's stable
It's still in A/B testing but it doesn't look like there's anything else for them to add
Everything is there (endpoint wise)
if (await bot.users.fetch(bUser).then((user) => {user.send(embed).then(message.channel.send(":white_check_mark: Successfully to **send message** to user."))})) {
}
else if (await bot.users.fetch(bUser).then((user) => {user.send(embed).catch(error => { message.channel.send(`By **user setting** or **(some ERROR:) ${error} (s)**, the message can not be sent directly to the banned user, very sorry to say that :(`) })
})){
}
}```
why the bot run both cases?
=(((
Yup I am fixing
it should be something like
const user = await bot.users.fetch(bUser).catch(() => null);
if (user) {
user.send(embed).catch(error => {
// send dm cannot be send
});
}
if i understood
ok
I can only send a max of 5 buttons per row, right?
How do I interact with Discord's API on a website?
and a max of 5 rows i think
you can use some library or make api calls with fetch or something
like a dashboard or something?
but anything to do with discord api is best done server side
I was going to make it so that when they want to verify into the server, they go to the website, complete a captcha and then get access to the server
cant u just do that on discord
like message collectors or something 
instead of making a website where u can just request an api for a captcha then complete the captcha in bot's dms or something
yeah I already have that
but like
there are no faults with it
just like
yeah
Look into oauth
that could work as well ig?
oauth is a blanket term
not so much getting data from Discord, but a flow to authenticate a session
uff may ik the commands for Your Manager BOT
what bot?
Yourmanager bot
also this is development channel
ok sry mb
I mean I could probably keep my current verification system
anyone know steam API well?
One message removed from a suspended account.
@quartz kindle I figured out my error. new URL(string).pathname does not include query string

def addUpvoteRecord(userid):
with open("vote.json") as f:
vote_list = json.load(f)
if not userid in vote_list:
vote_list[userid] = []
with open("vote.json", "w+") as f:
json.dump(vote_list, f)
@client.event
async def on_message(message) :
if message.channel.id == 870147153706750022 :
data = message.content.split(" ")
user = re.sub("\D", "", data[5])
addUpvoteRecord(user)
await client.process_commands(message) ```
i am getting this error
> TypeError: list indices must be integers or slices, not str
can anyone help me??
Isn't userid a string?
yes but how to convert it into int??
ya
does anyone know why my output in console is the playercount but in the embed it displays as [object Object]
No idea, google "python str to int"
Although keep in mind ids are actually long/bigint
Idk if it makes difference in python
can I edit and change <Message>.components = [] directly?
Because it doesn't know how to structure your object for output. You have to manually add each field for the player.
so do like const players = response ['result.data'] ?
No. You want to add a new embed field for each part of the player object.
oh so instead of doing value: result.data i would put players?
you literally forgot to add the []
const ownerid2 = "744578635780063293"; //Drix
if ((message.author.id == ownerid1 && ownerid2)) {
this work with ownerid1 , why
anyone have solution ?
So this is saying
if message.author.id IS EQUAL TO ownerid1 AND if ownerid2 has value```
It does NOT say
if message.author.id IS EQUAL TO ownerid1 OR IF EQUAL TO ownerid2```
^^
What you have to do is have it compare the value of message.author.id to BOTH ownerid1 and ownerid2
That's not how that works.
Is my brain dead
Yes
Hold up
if ((message.author.id === ownerid1) || (message.author.id === ownerid2)) {
// code
}```
Shoot
My brain lmao
been awake for far too long at this point
However what my brain is certain about is that it's likely far easier to use an array and just use Array.includes()
thank you guys
yes
let owners = ["id1", "id2"]
if (owners.includes(message.author.id)) {
// do amazing stuff
}```
I think the best improvement in that version is that you can now do amazing stuff inside that if statement
not const 
Number(Userid)
with userid being the thing you want
not var 
so im making a bot list and im working on webhooks, why do u need to provide a Webhook Authorization? for example, if a user votes on a bot, my frontend would send a POST request to the webhook given by the user who submitted by their bot, no Webhook Authorization needed
How the hell do decorators work in typescript.
I am trying to experiment with them and make one to use on a class when you are making slash commands, to provide metadata, such as the command name, description, and even options.
TypeScript Decorators overview
Already read it
Doesn't make much sense to me
I get what they do but not how to make it useful to me
For example typeorm uses decorators to declare a class an entity
And to declare columns
wdym by "right place"? aren't they the ones who provide the URL?
decorators ๐
is this correct?
const app = require("express").Router()
const {Webhook} = require("@top-gg/sdk")
const wh = new Webhook(process.env.voteWhPass)
app.post("/vote",wh.listener((vote)=>{
console.log(vote)
}))
app.get("/vote",(req,res)=>{
res.send("a")
})
module.exports = app
ping me when reply
You can test it yourself and see 
I copied some emojies from discord and tried to check the length
some emojis use more than 1 character
top.gg keeps saying there was an error 
idk whats wrong
im even using like a get request with the same path
and it works
what error?
And what's the URL to your webhook?
do i send it here?
why not
wrong mention
why pong
wdym by what did i do with the router?
The route does nothing by itself
? i dont understand what u mesn
Why don't you use the actual example from the lib's readme?
because clearly you don't know express
just use the example
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('topggauth123') // add your Top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen(3000) // your port
const express = require("express")
const app = express()
const {Webhook} = require("@top-gg/sdk")
const wh = new Webhook(process.env.whPass)
app.post("/vote",wh.listener((vote)=>{
console.log(vote)
}))
app.get("/",(req,res)=>{
res.send("yo")
})
app.listen(2000)
this is now what i use
updated my code
...and it still errors?
u mean the code?
if so no
this is the error that i was talking about
Okay so do you still get the error?
??
you are not having errors on your side? like in your console
you can try it with postman or insomnia
if it works there, it should be an issue on topgg side
Can someone tell me whats the different between the user and the member?
let user = msg.mentions.users.first()
let member = await msg.guild.members.fetch(user);
Well member will be the guild member
and user will be the user object
A user is basically them not associated with the guild
You'd only get basic info like their username, avatar, discrim, id, etc
My question is why are you fetching the user?
Why not just get the mention as a member
and then bam you already have their info
thx :)
thats an example lul
not my code
Oh
Well whoever did that idk what they were thinking
You can get the member by mention as well
and iirc it caches them
is there a way in discord.js to get the user who invited the bot in a server?
nope you cant
k, thanks
hey! I have a react to the moji to create a ticket system, however how would i remove the reactions (except the bot's one)?
You can remove the user's reaction (only) by using reaction.users.remove(user)
That'll keep the bot's reaction
mhmm, alright.
And i assume that reaction needs to be changed to something else?
ah wait nvm
Why does the bot still throw an error when the part is into a try catch block?
try {
user.send("You were kick because: " + reason.toString())
} catch { msg.channel.send("I could not send a message to this user") }
error: ```
DiscordAPIError: Cannot send messages to this user
because you didnt await it
First for fetches all users(if they share same guild with bot) in discord second fetches members in guild
the bot is blocked by the user
You can use members instead users
Then the bot should send the message "I could not send a message to this user"
Yes
because you didnt await it
thx it worked
try catch can only catch promises if they are awaited
You can try send you were kicked msg before kick code
Then it send message to user and kick him , but if bot cant kick him it causes wrong warn
let collector = channel.createMessageCollector(m => m.author.id === member.id)
collector.on("collect", m => {
if(m.content.toUpperCase() === captcha.value) {
m.delete()
verifycode.delete()
member.roles.add(vrole)
channel.send(`:white_check_mark: Correct code. **Congratulations ${member}. You have been verified!**`)
} else if(m.content.toUpperCase() !== captcha.value) {
warns[member.id].warns++;
fs.writeFile("./warnings.json", JSON.stringify(warns), (err) => {
if (err) console.log(err)
});
member.send(`:x: Wrong code. You supplied the wrong code. Please try again ${member}.`)
verifycode.delete()
m.delete()
} else {
verifycode.delete()
}
```how do i make sure that this code runs 2 times? (to give the users 2 shots to verify)
i can literally copy and paste this whole snippet in my vsc ofc, but is there any other better way to do it
make a function, and call the function twice?
yeah i just figured. I am dumb sometimes lol
lol
i dont really understand why i am getting interaction error
i mean whats the error
when i click either rock, paper or scissors it should give me an output
but instead its just interaction error
so i tried to make a simple interaction button and i got the same issue
add an event
Are you responding to the interaction?
idk the event name for py
i should be
Did you code something to respond to it? In an event like economy said.
Otherwise discords just sending the event to you and your not responding with anything so it fails.
also, is the event name the same for all language?
its rock paper scissors 
No idea tbh. I would expect so, but wouldn't assume so
what package are u using?
discord-components
ok
The example shows how to wait for a button click and respond to the interaction.
https://pypi.org/project/discord-components/
literally reading
searching for an event name
@earnest mural welp
uh
ok event name is button_click but I guess just search yt vids
i think just waiting for discord.py 2.0 to be released is a better idea
yeah
You have this part right?
interaction = await bot.wait_for("select_option", check = lambda i: i.component[0].value == "A") await interaction.respond(content = f"{interaction.component[0].label} selected!") ```
Shoot I copied wrong part
oof
That part just for buttons 
lol
lmao
interaction = await bot.wait_for("button_click", check = lambda i: i.component.label.startswith("WOW"))
await interaction.respond(content = "Button clicked!")
``` this part is prob the event
ยฏ_(ใ)_/ยฏ
but i doubt it

๐ what's the issue with the underlines.
I dont know the meanings of py issues ๐
Looks like it might be a spacing issue from the copy paste.
;-; where
oh
it's a full line, not 2 lines
that's prob the warning
the thing got sqaushed
not sure tho
yup I'm dumb gg e_s you failed
So why the green underline? Typically signifies a problem or something that needs addressing.
from this i think
oh
improvable
suggestions?
this is too much for my js brain ;-;
but its python
I know
ay guys
?
is there a way to see if a user has upvoted the bot
?
i mean
u can use api
but idk how to use

Docs cover how to use it
it says this
Anyone know which modules are requred for spotify links that can play music???
hm
keyv seems to be used a lot at least
i dunno i looked through google and people saying sequelize is good
i dunno
usually its best to use the most used one
true
keyv is kinda like
map api but support for stuff like mongodb
and promise based
lol
lol
keyv unable to be installed on v16 for some ppl, though I can install it on my linux ubuntu iirc and got vulnerability last time I installed it
some injection stuff. forgot
Corona injection
if(message.Member.roles.highest.position <= Member.roles.highest.position)
help me pls
Member in undefined in your code
module.exports = {
name: 'messageDelete',
async execute(messageDelete) {
try {
let user = messageDelete.author
let logEmbed = new Discord.MessageEmbed()
.setAuthor(`${user.tag}`, user.avatarURL({ dynamic: true }))
}
}
}
TypeError: Cannot read property 'tag' of null
Does anybody know why there comes this error when a message will be deleted and the event gets triggered?
lol
Hello
I use node v15
Can I get help
I need help with a bot
so I can easily adjust the nodejs version if I want to
That is noumenon bot how to invite it
topggpy is the new lib
client.on('messageDelete', async messageDelete=> {
try {
let user = messageDelete.author
let logEmbed = new Discord.MessageEmbed()
.setAuthor(`${user.tag}`, user.avatarURL({ dynamic: true }))
}
}
TypeError: Cannot read property 'tag' of null
Does anybody know why there comes this error when a message will be deleted and the event gets triggered?
sry I wrote it myself to discord lol
How can I scroll the user to the top when switching to another page?(react-router-dom)
messageDelete.author is null
let user = messageDelete.author is null
user is not defined
ah
Is sharding on heroku count as a app
Perfect
Why is the image not attaching ?
const emb = new Discord.MessageEmbed()
.setTitle("Sowwy... ยฐ ^ ยฐ")
.setDescription(`Put a looong text here`)
.setColor('RANDOM')
.setImage("https://i.imgur.com/SV4cFKe.jpg")
message.channel.send(emb);
Everything else is working but not the image.
And the image link works too (I guess)
https://i.imgur.com/SV4cFKe.jpg
seems fine to me
oh nvm It was cached I guess
yes and how can I get the author of the message which gots deleted?
It's fixed now
one reason the author may not be available:
there not cached
or message isnt cached
<Message>.fetch() - fetching a message if its partial
<Message>.author.fetch() - fetching the author if its not cached
try those methods 
null.fetch()
then fetch the message first
wait check the message type actually

check if its a default message by:
if (<Message>.type!=="DEFAULT") return
dunno if the message types r different in stable cuz i use master 
so ur code should be
const m = await <Message>.fetch()
if (m.type!=="DEFAULT") return
const user = await m.author.fetch()
How do I get the author of a message which gots deleted?
client.on('messageDelete', message => {
console.log(`A message by ${message.author.tag} was deleted`)
});
doesnt work
Also no since the message is deleted lul
yes
What's the output?
author is null
The whole message, not just the author
should I show it here?
Yeah
Yeah so it's a partial
Only the ID exists
You can't do anything about it; Discord.js relies on cache and the deleted message isn't cached
Just do if (message.partial) return; to prevent errors I suppose
how can I make then this log embed like Dyno?
That only works if the deleted message was cached
Try sending a new message and delete it
It should log that one fine
yes true
Someone can help
But if you send a message, restart your bot (where cache will be invalidated) and delete the message after your bot restarts it'll emit a partial instead
I'am new on discord.js is I don't know how start I have a lot error 
so what do I have to do to prevent that error?
thx
You can add that on top of your code before accessing any properties in message
It'll simply ignore the deleted message
Thank you
root@STGSecurity:~/stgverifier# sudo npm install canvas
sudo: unable to resolve host STGSecurity: Name or service not known
> canvas@2.8.0 install /root/stgverifier/node_modules/canvas
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm WARN verifierbot@1.1.0 No repository field.
npm WARN verifierbot@1.1.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! canvas@2.8.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the canvas@2.8.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-08-02T14_37_24_519Z-debug.log
``` what is happening again?
Install node-pre-gyp
Event handler: ```js
for (const file of eventFiles) {
const event = require(./events/${file});
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
event file:
```js
module.exports = {
name: 'messageDelete',
async execute(messageDelete) {
try {
const fetchedLogs = await messageDelete.guild.fetchAuditLogs({
limit: 1,
type: 'MESSAGE_DELETE',
});
} catch(e) { console.log(e) }
Error:
SyntaxError: await is only valid in async functions and the top level bodies of modules
Do you have the full stack trace?
did v13 already go released official?
nope
but why did they update .guide to v13
Soonโข๏ธ
so my bot was working fine then out of nowhere this bad boy shows up with a fat error
heroku probably can't even run a sharded bot
free dynos and specs just aren't enough
It can be enough
only if you're tim
no actually I know someone running 4k guilds on heroku
cacheless?
neither
Is there a limit on extends when extending class?
nope
limit for what?
at least as far as I know
weird, I tried on 2 and it works as soon I add the third Class , it doesnt let me show
what kind of limits are we talking about?
that's cursed
the Classes, which is in the ( )
doesn't js have implements? because extending more than 1 class is so fckd up
extending more than 1 class is fine tbh
js is weird
we extend and implement numerous classes and interfaces all the time in PHP
it's purposefully meant to be done like that to keep class instances modular
class Pog extends (Number, String, Array, Map, Date, Math) {
}
although we do it like this
like ?
class giveAnimePng
extends Request, Database
implements Struct\giveAnimePng
{}
thanks I hate php
it looks fine to me
This looks weird

How would I go about creating a command that bulk deletes every message in a server that includes a specific word? All I have right now is an array with the words lmao.
you don't
we do it that way so that we don't get those long extend tuples
like you have there in JS
Also where are the $
They should be everywhere in PHP right
is there something wrong here?
doing so would be heavy api abuse
Wait really
unless you're fine with week-long bulk deletes
no
I used to have some neon theme in vsc
and the $s would literally give me cringe
ok
this.message is null
this.interaction is null
There's no chance that code will run
I didnt run the function, as soon I added the class, it was not working
i have no clue why im still getting this error
what error ?
if it was typescript it was understable
when I add it, this error occurs .
When I removed the Class,this.reply works fine
here
what is this in this.reply ?
One odd thing about PHP is that the && and || operator actually gives you boolean, instead of last evaluated expression, unlike other programming languages. You'd have to resort to using ternary/elvis operator for a fallback value
Which is well, Idrm
its the Response Class
class Responses {
constructor(data) {
this.interaction = data.interaction;
this.message = data.message;
this.client = data.client;
this.args = data.args;
this.settings = data.settings
}
async reply(content) {
if(this.interaction){
return this.interaction.reply(content)
}
return this.message.reply(content)
}
...
When I do not extend Collector , this.reply works fine. When I extend it, it doesnt work anymore
It's still a nice language
I added the function in the Class Responses and it works fine
what?
I always thought &&/|| passed a boolean to the next check
The if statement turns the value to a boolean
> and < turns a boolean naturally though
wdym then?
"" || "a" will be true instead of "a" in PHP
tbf, I never heard of a programming lang except JS that allows that
Any ideas?
what
Python does it too
but its such a nice feature
Yeah I agree
perfect for defaulting shit
It is what it is
It's more about being dynamic.
You can still do $value ?: "Fallback" as a "shortcut" to $value ? $value : "Fallback"
But the ?: operator evaluates it once
python treating empty lists as falsely triggers me
that would be nice for js
trust me it's awful
hello, I want to do a custom embed command example! embed random ${message.author.username} the problem is that it sends me the embed with '${message.author.username}' and not the name of the user how to do?
If you could do that arbitrarily you'd be in trouble.
You can't
You could replace it manually, or make a list of valid identifiers to represent values. For example, embed random $user and replace $user for message.author.username
I know, but that's not what I want to do x)
they gave me a solution tho
https://esdiscuss.org/topic/symbol-for-modifying-property-lookup
Then what do you want to do?
use ` not '
as I explained it is that if in the command I specify ${message.author.username} that sends me the user that I do not have to add in the code .replace('$user', `${message.author.username}`)
So someone says
Hi $user
and you want it to be shown as
Hi $akio
??
also why are you using `` in the first place
you can just use
.replace(`$user`, message.author.username)
no no no, I explain again if I do! embed $ {message.author.user} that answers me Tony Kun I do not want! embed $ user and in the code a replace of $ user
Lemme be clear
someone does
!embed ${message.author.username}
and you show the embed with
Tony Kun
yes !
and .replace isn't working ?
since message.content = of the string I can't do what I want
message.content.replace('${message.author.username}', message.author.username)
like this ?
the problem is that the person is not necessarily going to do $ {message.author.username} that would make me do a lot of replacing it would be endless
oh it's a good idea if i evaluate the code it will necessarily send me the username?
yes yes don't worry about that thanks
eval commands should likely be owner only
It just prevents a lot of the things users can do to exploit it
that's not what I'm going to do, I explained it like that to make it easier to explain
Like !embed ${process.exit}
Etc
Something like that
Idk if that would work in an embed but it technically should
You better have a list if things you can share with user
Like
- username
- discriminator
- guild.id
- guild.name
- joinedAt
.setDescription(eval('${message.author.name} cc'))```
SyntaxError: Unexpected token '{'```
You need to use ` to start your string in order to use interpolation
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
message.content = 'string'
eval(message.content.split('${')[1].split('}')[0])
(not using regex)
what the fuck are you trying to do?
he's tryna give his token to users
One message removed from a suspended account.
.setDescription(client.token)
with an eval command
One message removed from a suspended account.
*mean
One message removed from a suspended account.
most people do
One message removed from a suspended account.
prevents accidental evals like @pale vessel does
One message removed from a suspended account.
well doing eval client will show the token
just giv eval power to everyone


