#development
1 messages · Page 1925 of 1
eh
it's easy for you cuz you're a discord api god
well i made it easy for you peeps
How can I restrict my bot to send 18+ reddit memes
Python
usually the api returns whether the result is flagged as nsfw or not
for nsfw posts jsonResponse.data.over_18 === true
@earnest phoenix hey help
that's another guy
Ok
I made a command for my bot to join vc but have problems will make command for disconnect
Help me
i just got pinged here
I think I know who did it
Hello 👋 //djs v12 btw
Anybody knows what is meant by those "lines of communication" between master and child process that the docs mention? Is it the broadcast/fetch methods?
Those methods unfortunately fail with rejection while shards are still being spawned so I thought I'd make a centralized object for server side cooldown check on that (hopefully shared?) index file with ShardingManager 
Can't figure out how to reach it from the individual shards tho 
how would i make my bot have j! and J! as prefix?
try prefix.toUpperCase();
right under where my lower case prefix is?
can you show the code
Isn't it just IPC?
I'd just look at the djs github tbh
convert message to lower case or something and then compare it to prefix
also u dont need the interval thing "on ready"
seems like a good lead, I'll look into those, thanks! 😄
k
eh they're setting their bot activity in the ready event
but why the interval 😄
maybe they want to set their guild count
which changes frequently
why is this happening..
when embeds.js is called from console, it works
but calling it from another file, say main.js gives this error
var commands = funcs.getCommands();
TypeError: funcs.getCommands is not a function
Its a function btw
check embeds.js module.exports
check for what.. funcs.getCommands() is a function and it works
but funcs.getCommands() cant be called in embeds.js from another file
exports are just embeds
show the funcs file
other lines are just exports
it works when logged, but only when called from console ;d
https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-roleCreate
https://discord.js.org/#/docs/main/stable/class/Role?scrollTo=setColor
yes
var
also, always prefer for (e of elements) { instead of forEach(e => {
https://discord.js.org/#/docs/main/stable/typedef/CreateRoleOptions
https://discord.js.org/#/docs/main/stable/class/RoleManager?scrollTo=create
<Guild>.roles.create(Role)
npm -v install module ?
> let
Just pass in props from these, should be able to do it
?
do you know what npm is?
npm -v install <module>
Idk
I am
Thinking
To learn
Java
Also
: (
Ok
wrong, don't call javascript java
*Short
it's not
java is an entire different language
it's like car and carpet
java is java
Java is nothing like javascript except in maybe naming conventions
😂
maven, gradle, spring, sbt, etc etc
I told u to replace ALL var with let
you didn't
in embeds and main
show where u define funcs
show ur whole file
I have a problem, the log return me undefined, but idk why...
Code:
const channels = [interaction.guild.channels.cache.filter(channel => channel.type === 'GUILD_TEXT').values()];
backupData.channels = {};
for (const TextChannel in channels) {
const channelData = channels[TextChannel];
console.log(channelData.name)
};```
channelData object :
```json
[Map Iterator] {
<ref *1> TextChannel {
type: 'GUILD_TEXT',
deleted: false,
guild: Guild {
id: '910856243709620284',
name: 'backup test',
icon: null,
features: [],
commands: [GuildApplicationCommandManager],
members: [GuildMemberManager],
channels: [GuildChannelManager],
bans: [GuildBanManager],
roles: [RoleManager],
presences: PresenceManager {},
voiceStates: [VoiceStateManager],
stageInstances: [StageInstanceManager],
invites: [GuildInviteManager],
deleted: false,
available: true,
shardId: 0,
splash: null,
banner: null,
description: null,
verificationLevel: 'NONE',
vanityURLCode: null,
nsfwLevel: 'DEFAULT',
discoverySplash: null,
memberCount: 3,
large: false,
applicationId: null,
afkTimeout: 300,
afkChannelId: null,
systemChannelId: '910856243709620287',
premiumTier: 'NONE',
premiumSubscriptionCount: 0,
explicitContentFilter: 'DISABLED',
mfaLevel: 'NONE',
joinedTimestamp: 1637235486191,
defaultMessageNotifications: 'ALL_MESSAGES',
systemChannelFlags: [SystemChannelFlags],
maximumMembers: 250000,
maximumPresences: null,
approximateMemberCount: null,
approximatePresenceCount: null,
vanityURLUses: null,
rulesChannelId: null,
publicUpdatesChannelId: null,
preferredLocale: 'en-US',
ownerId: '605371484046884865',
emojis: [GuildEmojiManager],
stickers: [GuildStickerManager]
},
guildId: '910856243709620284',
parentId: '910856243709620285',
permissionOverwrites: PermissionOverwriteManager { channel: [Circular *1] },
messages: MessageManager { channel: [Circular *1] },
threads: ThreadManager { channel: [Circular *1] },
nsfw: false,
id: '910856243709620287',
name: 'général',
rawPosition: 0,
topic: null,
lastMessageId: '911288282153881640',
rateLimitPerUser: 0
}
}```
He return me undefined, why
channelData["name"]
try that
ok
undefined @earnest phoenix
what is message pls ?
instead of for (... in ...) use for (... of ...)
mh ok
channelData["guild"]["name"];
in returns the index, of returns the object itself
idk what ur even logging
we never know
so u have the error bc your are in DM
i know
and dm != guild
ok
i declare war on javascript, fuck you
Don't ask for help, I bring solutions
This is not wrong because you did not give your code, just the error, so when you ask for help make a full request. Thank you
try```js
if (message?.guild?.id !== "840225836028395520") return;
It was therefore irrelevant, if guild is not defined, go back to the root, either message and see what you defined
but, np
undefined
return to require, console.log what funcs is
also change the bottom part
const channels = [interaction.guild.channels.cache.filter(channel => channel.type === 'GUILD_TEXT').values()];
backupData.channels = {};
for (const channelData of channels) {
console.log(channelData.name)
}
channelData or name?
channelData,
i try log TextChannel and it's return log me json [Map Iterator] { <ref *1> TextChannel { type: 'GUILD_TEXT', deleted: false, guild: Guild { id: '910856243709620284', name: 'backup test', icon: null, features: [], commands: [GuildApplicationCommandManager], members: [GuildMemberManager], channels: [GuildChannelManager], bans: [GuildBanManager], roles: [RoleManager], presences: PresenceManager {}, voiceStates: [VoiceStateManager], stageInstances: [StageInstanceManager], invites: [GuildInviteManager], deleted: false, available: true, shardId: 0, splash: null, banner: null, description: null, verificationLevel: 'NONE', vanityURLCode: null, nsfwLevel: 'DEFAULT', discoverySplash: null, memberCount: 3, large: false, applicationId: null, afkTimeout: 300, afkChannelId: null, systemChannelId: '910856243709620287', premiumTier: 'NONE', premiumSubscriptionCount: 0, explicitContentFilter: 'DISABLED', mfaLevel: 'NONE', joinedTimestamp: 1637235486191, defaultMessageNotifications: 'ALL_MESSAGES', systemChannelFlags: [SystemChannelFlags], maximumMembers: 250000, maximumPresences: null, approximateMemberCount: null, approximatePresenceCount: null, vanityURLUses: null, rulesChannelId: null, publicUpdatesChannelId: null, preferredLocale: 'en-US', ownerId: '605371484046884865', emojis: [GuildEmojiManager], stickers: [GuildStickerManager] }, guildId: '910856243709620284', parentId: '910856243709620285', permissionOverwrites: PermissionOverwriteManager { channel: [Circular *1] }, messages: MessageManager { channel: [Circular *1] }, threads: ThreadManager { channel: [Circular *1] }, nsfw: false, id: '910856243709620287', name: 'général', rawPosition: 0, topic: null, lastMessageId: '911288282153881640', rateLimitPerUser: 0 } }
show current code
then you're trying to use the function in the wrong place
and TextChannel return the Map Iterator
how... it literally works
and .name undefined
but doesnt work when called from another file 😄
if u try to use it where u shouldn't it might be called before even importing the function
actually, I just noticed ur issue
its literally called after import
u defined channels as an array with arrays
that's the thing
when embeds is required from another file it shows that
where would u use that function?
its perfect, it works btw xd
its not the problem
defining commands = funcs.getCommands() is the problem
Object.keys(commands).forEach(command => {
const obj = Object(commands)[command];
cmdForm+=`${obj["admin"] === true ? "*" : ""}\`${command}\` ${ obj["usage"] !== null ? obj["usage"] : ""}\n`;
});
be gentle
regex
Wtf is this monstrosity
Bro if you’re doing that from C# then you’re smoking the good C#
The worst thing I’ve written for my bot so far is like
export enum AnimalTypes {
'capybara',
'bird',
'cat',
'dog',
'lizard',
}
export function animalPayload() {
return (value: string): string | null => {
const result = Object.values(AnimalTypes)
.find(x => x === value)
?.toString();
if (result) {
return result;
} else {
return null;
}
};
}
And that’s overcomplicating it
for (const [name, command] of Object.entries(commands)) {
cmdForm += `${command.admin ? "*" : ""}\`${name}\` ${command.usage ?? ""}\n`
}
here, a bit better
my guess is that you have a scope issue
const [name, command]
yk, you could always work with a class-based structure if u hate functional programming that much
since u said u came from c#
imo classes were always easier to work with than functions
well, yeah since that'll lock anything below
if true return else return
there's no chance the runtime will ever get to the next line since both true and false return
also, you could just convert string to int using base 16
Regex is cringe
parseInt(<character>, 16)
very, very bad
redis was not created with long term storage as a goal
while it might be fast it stores the whole thing in memory
if going for in-memo database just use sqlite which barely weights anything
I think I'm yeeting Typescript
Yoo.
My domain is expired, we shall celebrate.
(story: host doesn't have website license anymore, i can't transfer, problem for both of us)
what tld?
here we can see, ben acquiring another domain
pretty sure you cant
I do not want to say nonsense, but it seems to me that this is not possible, unless you have stored before in a database or the like
I am using d.js v12
I am trying to find if a user has a role from a diffrent server I keep getting the error cache of undefined
client.on("guildMemberAdd", async (member) => {
if(member.guild.id == `864550299590983730`) {
let StaffRole = client.guilds.cache.get(`611881570202025986`).roles.cache.find(r => r.name === "Crew Member");
if(client.guilds.cache.get(`611881570202025986`).member.roles.cache.some(StaffRole)) { console.log(`Passed!`) }
return;
}
})
On which line is the error occurring?
if(client.guilds.cache.get(`611881570202025986`).member.roles.cache.some(StaffRole)) { console.log(`Passed!`) }```
says here
TypeError: Cannot read property 'cache' of undefined
at Client.<anonymous> (/home/container/events/guildMemberAdd.js:14:62)
at Client.emit (node:events:394:28)
at Object.module.exports [as GUILD_MEMBER_ADD] (/home/container/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_ADD.js:16:14)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (node:events:394:28)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:983:20)
at Receiver.emit (node:events:394:28)
@solemn latch^
Does the member have a role? Roles can be empty
Yes in the main server
Like I am checking if the user a the x role in the main server
Op, seems the property member of a guild doesn't exist
The guild is aviable
Sure, but it doesn't seem to have .member
Is there another way to do this
Just to clarify, you want to check on guild member add if someone's in a specific guild, and if they have a specific role right?
Event guildMemberAdd
Yes
You can drop most of this line and do member.roles.cache then
Or well depending on how you want it to work specifically
If you want it to be if they join any guild check the original guild you'll need to perform a get of that guild
member.roles.cache how can i use this to check from a diffrent server
Ah OK then no to the previous question
You'll want to get the guild like you are doing, then get the member using Guild.members.cache.get
https://discord.js.org/#/docs/main/12.5.3/class/Guild?scrollTo=members
You'll probably actually want to fetch it just incase they are not cached
if(client.guilds.cache.get(`611881570202025986`).members.fetch(member.user.id).roles.cache.some(r => r.name === "Crew Member"))) { console.log(`Passed!`) }
Yep, I would suggest using variables and some basic checks to make sure they are actually in the server and have roles there so it doesn't error/fail. I'd also suggest fetching the member if possible
fetching the member the member here right #development message
Ah fetch is a promise so you need to await that
F forgot
let StaffMember = await client.guilds.cache.get(`611881570202025986`).members.fetch(member.user.id);
if(!StaffMember) member.kick(`Not a staff member!`);
if(StaffMember.roles.cache.some(r => r.name === "Crew Member")) { console.log(`Passed!`) }
@solemn latch ^ Will this work to check if the user is in the server or not
Yep should do, but just a note your kicking every member that joins any server the bots in that isn't in the staff server
not I did a check
Ok
Do you known how to make the wait 10 - 30 seconds before running the code
on member join
setTimeout(function(){
}, 30000);
Yeah
if(member.guild.id == `864550299590983730`) {
setTimeout(function(){
let StaffMember = await client.guilds.cache.get(`611881570202025986`).members.fetch(member.user.id);
if(!StaffMember) member.kick(`Member is not a staff member!`);
if(StaffMember.roles.cache.some(r => r.name === "Crew Member")) {
member.roles.add(`910942702219173908`);
member.guild.channels.cache.get(`911228262489931797`).send(`**Welcome to the staff server ${member}!**`);
return;
} else {
member.kick(`Member is not a staff member!`);
return;
}
}, 30000);
return;
}
Looks good?
Yep
Thank you!
https://discord.js.org/#/docs/main/stable/class/MessageActionRow
Having a Issue, the Docs say it accepts multiply Components
Although I tried as documentated:
buttons.push(new Discord.MessageButton().setLabel(`⬅️`).setStyle(`PRIMARY`).setCustomId(`l|pe`));
buttons.push(new Discord.MessageButton().setLabel(`➡️`).setStyle(`PRIMARY`).setCustomId(`r|pe`));
const row1 = new Discord.MessageActionRow().addComponents(buttons);
But it errors with the following Error:
uh thx for reminding, I didn't receive the ping for the message or over saw it,let me check it.
But that's using React, I'm using EJS ._.
ig time to rewrite everything in react then
express has its own body-parser
yes
What sites can you find .xyz domains?
literally every domain provider
Someone is having a hard time seeing their Dashboard when their bot is down. Is this normal?
does their dashboard depend on the bot?
if so, yes
Ideally it would be independent in the event of the bot being offline
How do you become a Auctions Tester?
damn 
And what is that xD
Hey! I get this error (https://sourceb.in/M8dGp7payd) when using discord-canvas and canvacord, and i dont understand why. I googled it and tried what i found, but nothing helped. Does anyone know how to fix it?
I only get this error on repl.it and i use node v16.6.
did you try running the command on the error?
it says it's using MERN though: MongoDB, Express, React, Node.js
If you go further in the article you can see he's using ejs, the person who wrote it probs doesn't know what MERN stands for
ah, was confused by the embed desc then
yes, both
try deleting your whole node modules folder and then running npm install
usually fixes things like that
go to the shell and type in rm -rf node_modules
then npm install
Still the same error
oh wait i just seen the error
the node version is very outdated and mostly needs to be updated
i dont know too much about updating node on repl.it but @quartz kindle does
did you confirm by running node --version
hmmm
that says its v12.22.6
but thats not possible
cus then djs v13 wouldnt work
wait
imma try to clear npm cache
console.log(process.version)
yeah with these weird hacks i dont imagine thats a reliable way of checking
In discord eris how do I setup gateway intents
my boy, if u didn't do [ T I M ' S H A C K]™️ then you're most likely running v12
Im big dumb
Ive never used eris :/
i tried dozens of things, and it says both in shell and console that its v16.13, so i just dropped using canvacord and canvas
canvas isnt an easy library to work with
very weak and error prone node bindings
especially in a limited environment such as repl
isn't canvas incompatible with repl?
like, I read somewhere that it's blocked there
shell and console dont mean much in replit
what matters is what the actual process is running on
there it comes
so run console.log(process.version) in your code
its the only surefire way to see which version your code is running on
also depends how you installed your packages
depending on how you run your node, the way to install packages is also different
its a long one
npm init -y && npm i --save-dev node@16.13.0 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH
ok, so first thing is that PATH is not persistent in replit, no matter how you set it up it will always reset after a while
so if you want to use that method, you have to also install all dependencies at the same time in that code
Simple question ... What is this wrong
if(message.channel.id !== `611882154065920020` || message.channel.id !== `611882231820058624`)
oh
then how should i do it?
currently the easiest method is to create a nix project
...
if message.channel is not equal to this or if message.channel is not equal to this ...
if(message.channel.id !== `611882154065920020` || message.channel.id !== `611882231820058624`)
``` - This is incorrect
It will always evaluate to true, you can’t satisfy both conditions to evaluate otherwise
u ignored my answer
NOT OR NOT is logically invalid
NON for short 
True
Ahh that explains
why i get them mixed up
So doing this is also wrong ```js
if(message.channel.id == 611882154065920020 || message.channel.id == 611882231820058624)
No that should be fine
that is correct if you want the channel id to be one of those two
If you want to block those channels then use this and just return if it matches either
So there is nothing to do to return if these 2 are not the channel ids
you're looking for NOT AND NOT
Like I am trying to onlt be able to run the commands on these 2 ids
exactly
Then you should use NOT AND NOT
if id is NOT this one, AND also NOT this one, return
booleans are fun
oor so use &&
did you fork that repl?
!condition && !condition
huh?
the one i sent
if(message.channel.id !== `611882154065920020` && message.channel.id !== `611882231820058624`)
i did that, yues
👍
yes
what?
what did it log?
it logged error
it didnt log anything because of the error
@wheat mesa@quartz kindle@lyric mountain - Thank you! 
again, did you fork the repl and created a new one?
i didnt create a new one
or are you just trying to add those files to your existing one
now run it to confirm that the node version is correct
v12.22.6
im very sure
@earnest phoenix yet another issue is that both examples use passport-local and passport-local-mongoose .-.
2 sec
https://replit.com/talk/learn/How-to-get-V16-in-replit/143868 this might help, @tribal crow
it works for me like that, so maybe it does for you (idk if this has been tried yet)
that method tries to update the PATH variable, which on replit is not persistent, it will always reset
so you have to run that again everytime it resets
i even created a new repl...
still says v12
it auto-updates on the run function
when you created a new repl, what type of repl did you chose?
node.js
oh
thats why i told you to fork lol
but i dont get that option when forking?
- with my example you can choose node
the run function just calls node
it should stop working if the PATH variable gets reset
idk how repl works ¯_(ツ)_/¯
because it reverts to the default node
it works for me without issues so c:
well, as long as it keeps running, it wont reset
but if you stop your bot and leave it for like a day, it will likely not work when you start it again
but the chance that you stop your bot for a day is slim
well yes
anyways, now you should be able to install stuff from npm using the shell and a package.json file
hawk
the nix method is pretty much the "official" way to run node 16 on replit at the moment
dont do that
node_modules always have to be reinstalled
ik
you cant copy and paste them between different node versions
ik
npm init and npm i?
yes
Error: libuuid.so.1: cannot open shared object file: No such file or directory
whats the full error
try adding pkgs.libuuid in your nix file deps
no changes
try npm install canvas --build-from-source
.
whats the log for that
the same
i mean the npm install log
up to date, audited 159 packages in 3s
16 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
i did
then wheres the install log
install log?
Hey!
Could anyone help me with a method how i can find links/apis/endpoints on a site to easily scrape?
https://www.solanadrops.art for example this site. How would i exactly get to scrape it
yeah i tried inspecting element + network inspecting
they don't use an api and completely hide the info's in the cache using hummingbird
you're welcome
i think that this website doesn't work?
{ pkgs }: {
deps = [
pkgs.nodejs-16_x
pkgs.python39
pkgs.pkg-config
pkgs.pixman
pkgs.cairo
pkgs.pango
pkgs.libpng
pkgs.libjpeg
pkgs.librsvg
pkgs.giflib
pkgs.fontconfig
];
}
npm i canvas --build-from-source
could anyone help me find a way to scrape this website? I tried finding it's api or XHR requests, nothing found...
its in the html itself
just fetch the page and scrape it from the text
didnt get that log
html scraping is easy
Well in that case, could you tell me the easier methods to scrape html?
With axios for example
It's the same with any http lib. The scraping is done with regular expressions
You would regex the elements you want and retrieve their value
you dont even need regex
just string searching with str.indexOf and str.slice, or str.split for example
hi i would have a question whether it is worth writing slash commands or unnecessary?
Huh?
let clay = message.guild.users.cache.find('694367588464984095')
const currentDate = new Date();
const on_status = new Discord.MessageEmbed()
.setAuthor(message.guild.name, message.guild.iconURL())
.setAuthor(`Bot Locked; Emergency Enabled.`)
.setDescription(`Bot was locked at ${currentDate} by ${message.author.tag}.\n\n> \`\`\`Use **nah emergency off** to disable it.\`\`\` `)
clay.send({ embed:[on_status] })

djs v13 btw
Guild doesn’t have a cache
guild doesnt have .users
It has .members
message.guild.members.find?
.cache.find
also
you have an id
so
.cache.get
not find
also
that only works if the member is cached
it wont work with offline members for example
Doesn’t the guild object automatically have all members?
no
Odd
if it did, everyone's bot would be using gbs of ram
Why am I getting thie error on Mozilla Firefox
{
"name": "YT Dislikes viewer",
"description": "Show the dislike count on YouTube videos.",
"version": "1.5",
"manifest_version": 2,
"background": {
"scripts": ["service.js"]
},
"browser_action": {
"default_icon": {
"16": "/icons/get_started16.png",
"32": "/icons/get_started32.png",
"48": "/icons/get_started48.png",
"128": "/icons/get_started128.png"
},
"default_title": "Home Page",
"default_popup": "popup/index.html"
},
"permissions": [
"tabs",
"webNavigation", "storage", "all_urls"
],
"host_permissions": ["*://*.youtube.com/watch?*"],
"icons": {
"16": "/icons/get_started16.png",
"32": "/icons/get_started32.png",
"48": "/icons/get_started48.png",
"128": "/icons/get_started128.png"
}
}
my manifest
I hate people who send screenshots of errors
Anyway what exactly are you doing tf I've never encountered an error like that
Can anyone gelp
I am trying to access the youtube.com url
a single embed is limited to 25 fields right?
VoiceClient.disconnect()
I try that
It say client user don't have atterbute disconnect
@quartz kindle
Ok
Let me try
@quartz kindle it say name voiceclient not defined
Any package need for it?
If need tell name
I will install
no
you just need to find it
when you do VoiceChannel.connect()
the returned value is a VoiceClient object
Ok
you can also access it through guild.voice_client
can a message have unlimited embeds?
i believe the limit is 10 embeds
dang
But the sad part is that even with 10 embeds the max character count for all the 10 embeds in total is still 6k
Character limits hit hard tho
all embed fields across all embeds must not exceed 6000 characters iirc
anyone see why this isn't working? i'm getting a 404 error
One message removed from a suspended account.
it does exist
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i made it
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i'm using the id returned from this call
how is it malformed? that is just the path part of the url
One message removed from a suspended account.
maybe it exists but they just cant find it
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
oh, do i need to use the same token from the original request?
that's wouldn't be good because the token expires after 15 minutes
How to see my bot vote link?
dang
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
this will do it
Where to coding the bot?
Huh
const x = {abc:123, def:456}
const {abc, ...y} = x; // const {["abc"], ...y} = x; ???
console.log(y)```
is it possible to do this destructing with a dynamic value passed in?
const x = {abc:123, def:456};
const {["abc"]:z, ...y} = x;
console.log(y)
figured it out
is it possible to use the http interactions endpoint to host a bot on vercel? ikr bad idea but what goes in trying
yes
isAuthorized
const isValidSig = require("./isValidSig");
const keyMap = {
"APPLICATION ID": "PUBLIC KEY"
}
module.exports = (req) => {
const signature = req.headers["x-signature-ed25519"];
const timestamp = req.headers["x-signature-timestamp"];
if (!signature || !timestamp) {
return false;
}
const key = keyMap[req.body.application_id];
return isValidSig(key, JSON.stringify(req.body), timestamp, signature);
}
isValidSig
const {createPublicKey, verify} = require("crypto");
const isValidSig = (key, body, timestamp, signature) => {
const keyDer = createPublicKey({
key: Buffer.concat([Buffer.from("MCowBQYDK2VwAyEA", 'base64'), Buffer.from(key, "hex")]),
format: 'der',
type: 'spki'
});
const data = Buffer.from(timestamp + body);
const sig = Buffer.from(signature, "hex");
return verify(null, data, keyDer, sig);
}
module.exports = isValidSig;```
that might help
ok
use export default instead of module.exports =
yup
Tim helped me with the authorization part
that was tricky stuff
const keyDer = createPublicKey({
key: Buffer.concat([Buffer.from("MCowBQYDK2VwAyEA", 'base64'), Buffer.from(key, "hex")]),
format: 'der',
type: 'spki'
});
oof
why discord
if only the discord docs weren't written in the worst language the universe has ever seen
aka python
forced indentation sums it up
yeah
that's a mistake
if (!isAuthorized(req)) {
return res.status(401).send();
}
if (req.body.type === 1) {
return res.json({type: 1});
}```
you need these two conditions to get the webhook setup
the interpreter benefits from not having to parse extra {} but it makes it less human readable, especially with word wrap
application languages shouldn't worry about small optimizations like that
I have this script (kind of command manager but for redirects) and I want to make a script if it couldn't find anything with the same 'file.name'.
Is this possible and how would I have to do that?
Thanks in advance
Can anyone tell me, How can I add Elements in the list so they are linked to each other, I mean
marks = int(input("Enter Marks")```
Now if I enter name = john & marks = 78, I want that when I lookup for John, his marks should appear
like - list = ["name" : marks]
Do you have guild member intent specified?
Also make sure to turn on the member intents in developer portal
i don't think member mention requires guild member intent
hey, i tried html scraping this website
but it sadly does not work at all:
ar fetchUrl = require("fetch").fetchUrl;
const cheerio = require('cheerio');
fetchUrl('https://www.solanadrops.art/', function(error, meta, body){
let result = body.toString()
const $ = cheerio.load(result);
let m = $.html()
console.log(m)
})
it just logs me its hummingbird cache file
ya look at that site
i am trying to scrape that fokcing site but it seems like they are hiding their info
bad design has its advantages ¯_(ツ)_/¯
read that again
what
Is it possible to run top.gg related servercount stuff when your using a discord.py fork? I'm using Disnake and running into some issues
Like this issue
ModuleNotFoundError: No module named 'discord.ext.commands.bot'```
Oops
Currently working on it so that it doesn't depend on any Discord API wrapper
But yeah, you can totally make raw requests yourself
Oh okay
Ok so In nginx
Is there a way to add a subdomain as a proxy pass?
To another application?
Or the same even
What I'm asking is, HOW DO I CREATE A SUBDOMAIN
subdomains are created in your registrar's dns settings
were you bought the domain
or the thing that manages your domain
Cuz the member is not cached
and without the intent being turned on, i dont think your bot will get the member cache upon starting up
if u use .users it would work perfectly fine without the member intent
afaik that is the problem
remember user object wont contain many properties which a member object does, like the nicknames, member's roles and stuffs
use first()?.id
guess you did not specify a mention?
@bot.command()
@commands.has_permissions(administrator=True)
async def gcreate(ctx):
giveaway_questions = ['Which channel will I host the giveaway in?', 'What is the prize?', 'How long should the giveaway run for (in seconds)?\n**Note:** 1hr = 3600s | 1day = 86,400s | 1week = 604,800s',]
giveaway_answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for question in giveaway_questions:
await ctx.send(question)
try:
message = await bot.wait_for('message', timeout= 30.0, check= check)
except asyncio.TimeoutError:
await ctx.send('You didn\'t answer in time. Please try again and be sure to send your answer within 30 seconds of the question.')
return
else:
giveaway_answers.append(message.content)
try:
c_id = int(giveaway_answers[0][2:-1])
except:
await ctx.send(f'You failed to mention the channel correctly. Please do it like this: {ctx.channel.mention}')
return
channel = bot.get_channel(c_id)
prize = str(giveaway_answers[1])
time = int(giveaway_answers[2])
await ctx.send(f'The giveaway for {prize} will begin shortly.\nPlease direct your attention to {channel.mention}, this giveaway will end in {time} seconds.')
give = discord.Embed(title=f'{prize}', description=f'React with 🎉 to enter!\n Ends: {round(time/60/60/24)} Days!\nHosted by: {ctx.author.mention}', color = 0x37b2cb, timestamp=datetime.datetime.utcnow())
give.set_footer(text = f'Winners: 1 | Hosted at')
my_message = await channel.send(f":tada: **GIVEAWAY** :tada:", embed = give)```
How to make time in `<t:{}:R>` - Discord Epoch format?

did you turn your intents on?
Math.floor(time in ms / 1000);
???
sorry. I responded in js when you're python
💀
Yeah :(
idk py
Oh ok
just whatever method it is to floor a float to an int
then im sure there is something else wrong, try to console log message.mentions and see what it is
Your best bet is googling it lol
Doesn't help
D24 👀
ive seen this guy somewhere
the time format just has to be the current date represented as seconds as an integer.
well members is null idk if that's supposed to happen
Usually, its represented as ms which would mean you'd have to floor it since dividing by 1000 could return a float
Where tho 
like where you create your client
Clicky's beach iirc
Or i could be wrong
wait, @carmine topaz are you running the command in the bot's dms by any chance?
https://www.npmjs.com/package/@top-gg/sdk <-- This is the package to interact with the top.gg api, Right?
Ok thanks
members return null only if the message object doesnt have a guild
this is really weird 
Guild members intent maybe? Idrk
hey guys
how can I scrape Youtube's HTML page?
I have the Query Selector's ID
I want to get the value
py?
js
If you're using Node you could use jQuery/Cheerio
I am using vanilla js
Ah
Query selectors?
I mean document.querySelector()
You can fetch the HTML using fetch and parse the result using DOMParser
const likeLabel = document.querySelector(selector)
const value = likeLabel.text // ?
i am confused about the const value
Otherwise innerHTML
const fetchedLogs = await oldChannel.guild.fetchAuditLogs({
limit: 1,
type: 'CHANNEL_UPDATE',
});
// Since there's only 1 audit log entry in this collection, grab the first one
const channelLog = fetchedLogs.entries.first();
const { executor, type, id, name } = channelLog;
how to get the permissions that changed
Log channelLog and see the available properties
hey guys
Or well, check the documentation
ok
Link?
<yt-formatted-string id="text" class="style-scope ytd-toggle-button-renderer style-text" aria-label="71,725 likes">71K</yt-formatted-string>
this is html for
like count
what is the query selector here, can I get it by using class as the query selector
Should be in changes
You could probably just copy the whole class .style-scope .ytd-toggle-button-renderer .style-text, assuming it's unique
Otherwise, I have no idea
oh okay
thanks
for dislikes I am using ``` ytd-menu-renderer.ytd-video-primary-info-renderer > div > :nth-child(2) yt-formatted-string;
which surprisingly worked
I found this on the internet
Ah lol
Then use document.querySelector("ytd-menu-renderer.ytd-video-primary-info-renderer > div > :nth-child(1) yt-formatted-string").innerText;
Works for me
Just pick the previous child which is the like count
thanks!
Description doesn't have 2 values like that
Oh wait
Read wrong
Timestamp doesn't have custom stuff like that iirc
shouldnt there be a new line between member_count and discord.Embed?
or is that bugged?
Py probably logged it weird
that still wouldnt throw invalid syntax
Strange
the slash command also can be used without the permission when invited?
client.on("messageCreate", async msg => {
if(msg.content === "!ping") {
bot.commands.others.ping({
client: client,
type: msg,
content: 'hello'
})
}
})
I wanna make this object is optional
you are trying to use object destructuring for function parameters, i suggest you research a bit how they work
meh my joke was ruined by formatting
i have your bot token. you have 24 hours to send me 1 btc or i will hack your bot
lol
I
Is there a way to check scopes the bot currently has in a guild?
Want to send a message to reauthorize if the bot cannot show its slash commands in a guild and that seems like the easiest (if possible) way
Not that I know of
Hmm
So after discord forces message intents my bot won't function in any servers unless someone manually reauthorizes it w/ the command scope?
Is my understanding but I might be wrong
My friend passed away last week and I want to carry his code with me. How do i add a Status to this code for my bot (like DND or Idle or Streaming):
const config = require('../config.json');
const chalk = require("chalk");
module.exports = (client) => {
console.log(chalk.magenta.bold(`✅ Ready As the Bot: ${client.user.tag}\n📃 CHANNELS THE BOT IS IN: ${client.channels.cache.size}\n📅 SERVERS THE BOT IS IN: ${client.guilds.cache.size}\n👤 TOTAL USERS DETECTED FROM BOT: ${client.users.cache.size}`));
client.user.setActivity(`${config.prefix}help ¦ Loading Backups In: ${client.guilds.cache.size} servers For ${client.channels.cache.size} channels!`);
};
Can someone help me again im getting this error
Just help me
you can start by showing us your code
xD
@split hazel ^^^
It is fuzzy
Click the dam photo
sorry for your loss
client.user.setStatus('dnd');
place it somewhere inside the function
if i remember correctly it might take a while for the status to visually update
So like this?
const config = require('../config.json');
const chalk = require("chalk");
module.exports = (client) => {
console.log(chalk.magenta.bold(`✅ Ready As the Bot: ${client.user.tag}\n📃 CHANNELS THE BOT IS IN: ${client.channels.cache.size}\n📅 SERVERS THE BOT IS IN: ${client.guilds.cache.size}\n👤 TOTAL USERS DETECTED FROM BOT: ${client.users.cache.size}`));
client.user.setActivity(`${config.prefix}help ¦ Loading Backups In: ${client.guilds.cache.size} servers For ${client.channels.cache.size} channels!`);
client.user.setStatus('dnd');
};
yep
Thanks!
it would be better if you copy pasted it into something like https://hastebin.com
Wth is my bot having this issue I used this exact code before and did not get this error
K
because i can easily plop it inside of an ide instead of trying to find the exact colon you missed for example
What are the most common Status for Bots?
well online
Not DND or whatever?
you dont see many bots with statuses other than online
@split hazel how do i send my hastebin code?
copy the link and paste it here
it should save
there should also be a save icon on the top right
just view it there instead
How th
@spark flint HOW DID YOU GET THAT?
lol
you left it in a ss
Oh I did
at least it uses .env 
Im a idiot
that is gold
I protect all tokens with envs
you missed quite a bit of colons
fun fact: their friends Gocrix#1989 and Lighting Sploits I Utilities#6140
Lighting sploits is one of my bots
you havent set an interval here
what should the interval be
like what time delay between each interval
Uhh
its a forked bot
nice
My friend gave me his code
anyways heres the code you can just copy paste it https://www.toptal.com/developers/hastebin/ocabunezed.js
well if you look at all the forks of your own bot it seems eventually leads to a generic github bot
not your friends code
main reason why im sending it whole back is because i beautified it
Bruh what did my friend lie to me
i think you just destroyed a friendship
I HATE HIM
@spark flinti think you should keep quiet about forks next time
true, my bad
it was all an illusion
the code is your friends
@fresh bluff what is your friends replit name
I can’t say bc I forgot
ok
We haven’t talked in a while
@fresh bluff You are Lying.
If you summit this to top.gg, then you will be denied because of it being Forked.
@stray seal how am I lying
Next Time, try to hide the GitHubs :D
lmao what have we started
@covert gale did you make Hycord? xD
also ithundxr:
LEAVE MY FUCKING CODE KNOW @spark flint AND @split hazel AND @stray seal
christ
Lol
tw rblx: asks for help
us: gives help
him: LEAVE MY FUCKING CODE
xD
i only fixed, beautified it and sent it back
He just mad that he got caught
lol
Is anyone good with using Watchbot? I need some help...
@quartz kindle yo tim, you messed with slash commands much? nvm I figured it out
What are some good Free Domain Places?
choose one
1 - good
2 - free
ssl certs are free anyway 👀
these days scripts do them in a line of code
i host sites for free and ssl is automatic
and adding manual is easy af
my hosting provider?
any decent host these days
Discord does not exist inside discord.js
thats why { Discord } = require("discord.js") is undefined
because thats the same as doing require("discord.js").Discord
anyway to send a message with just buttons
send a message with a dummy embed and the button and then edit it with the SUPPRESS_EMBEDS flags. I believe the bitwise is 1 << 2
Yup
ok thanks
is there a way to send a new webhook url automatically from my bot? 
idk
Like creating a discord webhook from your bot?
Can we also do gif manipulation in pillow ?
Tbh didnt understand anything from examples
I think that’s what they mean
why is this happening when i am trying to input my unicode character of 👾
that whole focking unicode is not fitting for some reason
almost all emojis have a five lettered unicoe
how can i ever use them then?
not a possibility as my vps encodes all emojis to ??
as i am using winscp, which uses a ddifferent encoding type
\👾 just use this?
no my cleint converts everything to ??
.
hey is it possible that when someone vote the bot it give him voter role automatically and after 24 it removes it till the time he votes back
Yeah, using webhooks
https://docs.top.gg/resources/webhooks/
ok
tho i have read multiple time each and every line but nothing got in my mind
Then use vote tracker bot
hm?
can an interaction fetch messages on a channel?
Yes.
how doe
What do you mean, how doe?
how
There's no How?
You need to fetch the message once the interaction/slash command is run.
not that
What?
client.channels.cache.get(channelid).fetchMessage(messageid)```
i want to do something similar to this but inside an interaction
Unfortunately, I don't understand the meaning of interaction, are you talking about slash commands?
Not sure why this response, but oh well. 
I was being specific? 
I find it pain, too. 
ii thought u meant to like fetch the message that me as an author just sent to trigger the slash command
but what i am trying to do is
inside the slash command which is on a command handler
get a id of a message and fetch the message
in this case it's a bot that gets a message u send and embeds it
with message collections
for example
/slashcommand embed 911982832518307840
Well, the method of FetchMessage() can only be used in the Webhook class and not in the Message class; you could use the fetch() method, instead.
According to your code, you could do the following and achieve the following result.
await client.channels.cache.get(channelid).messages.fetch(messageid); // Returns the "Message" class.
client isn't defined inside this thing and idek how to
interaction.client
OH
Where are you inputting this code, at?
Or if you want to use the current channel, why not interaction.channel.messages.fetch(id)?
I would agree more to this if you're fetching for the message in the same channel. 👍
the message could be on another channel
Use my method, instead, then.
Switch Used to use.
You should use it, interaction is defined.
yeah used it on the past
...what
now using the new one

L
Yikes, which one?
Yeah I dunno what's wrong with him
hold onnn
How do you know which channel it should fetch the message from?
It can, indeed.
if not that might be why i keep on getting errors
It needs to know which channel the message was from
Otherwise you have to rely on cache
the id here is supposed to be the id of the message or the channel
What are you going to do with just the channel ID?
so it's supposed to be the message
.messages, yes.
it logs a big list of messages
You refer to the Message object, correct?
As per what I said, here.
TypeError: Cannot read properties of undefined (reading 'cache')
What? Send full error, please.
using ```js
interaction.channels.cache.get
also here is how interaction is created on the main file
client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
if (error) console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
client =/= interaction
i think channels is not a thing
console.log(await interaction.client.channels.cache.get(751178350945280091).messages.fetch(911984533635785468))
^
TypeError: Cannot read properties of undefined (reading 'messages')
Did you use number for IDs?
