#development
1 messages · Page 1403 of 1
isnt is .settimestamp?
Could be needed to use the attributes on the img tag
im a full stack dev
well in fs we have readFileSync which stops code execution and in readFile it registers a callback but wht if we want dn't want to stop code execution and dn't want undefined
My picture is transparent in cases yours isn't
please dm me
@proper dome wrap it in a promise or promisify it
My server has over 10k+ members and I am trying to check if the user has the role Active Server Staff, if not kick the user from a different server that has less than 100 members. - discord.js v12
let user = await member.client.guilds.cache.get(`611881570202025986`).fetch(member.id);
if(!user.roles.cache.find(r => r.name === "Active Server Staff")) {
await console.log(`[ Staff Server Kick ] ${member.user.tag} (${member.id}) was kicked from the staff server!`)
await member.kick();
return;
}
It just doesnt kick the user ...
you're doing guild.fetch() which returns a guild, not a user
.members.cache.get Instead of .fetch
if you add .members.cache.get it will return a member found in the guild
does anyone know what goes into the txt requirments file for discloud hosting?
the support dont know
for discord.py?
yes
let user = await member.client.guilds.cache.get(`611881570202025986`).members.cache.get(member.id);
if(!user.roles.cache.find(r => r.name === "Active Server Staff")) {
await console.log(`[ Staff Server Kick ] ${member.user.tag} (${member.id}) was kicked from the staff server!`)
await member.kick();
return;
}
Like this?
Yeah ik but i thought of registering a call back which will then run when readFile call back executes or use fs/promise
await 
Yes.
You await everything, holy
readFile gives you a callback already
oh wait didnt u get anything on their website?
i cant read the docs...
if it doesn’t-work change user to this: client.guilds not member.client.guilds
Bot.
wait let me help u
??
What docs are you trying to read?
The main file of your bot, that is, the location of bot.run (). GENERAL is main.py
@safe creek
This means:
I don't see any python around here ngl
i do
Oh God I see
I recommend do if(args[0] == "help" || !args.join(" ")) {
shiv is the python
owo
mmmk so what about my eco, moderation etc files insde my bots folder
Tim is the JS
lmao
Oh the easy one to learn I see
oh yeah
mmk
oh
The hell is different about discloud even
what is discloud
You need to specify packages in requirements.txt?
discord bot hosting
what is dis
its a bot hosting service
america explain!!!
what is di
di z nuts
they use digital ocean
DO
DO HAST
@safe creek btw if u want an advice
and u are looking for free hosting on discloud
u wont be able to do
cuz their free ram is jst 50mb
use repl and uptime
the best free host there is, is google compute engine, but it requires a credit card to register
Is there a way to have a bot, which is sharded, And then host shard 1 on a server and shard 2 on a another server?

My music bot is kinda lagging every now and then, this because of network?
ram
could be network, could be cpu
#development message @quartz kindle u have the most experience xD
yes
yes
Hm, ill try transfering my bot to a faster node/location
how , do it manual?
what lib? discord.js?
yes 
// client1.js
let client = new Discord.Client({
shards: 0,
shardCount: 2
})
// client2.js
let client = new Discord.Client({
shards: 1,
shardCount: 2
})
because my bot is hitting 2k , and I do not have any server, rather had the idea to spilt it up in many free servers xD
not a bad idea tbh
just note that you wont be able to use discord.js's sharding functions, like broadcastEval
anywhere from 50mb to 1gb
50 mb xD, my uses after a day 1 gb
it could be as low as 5mb if you use a custom lib and cache nothing
Is there a way to free it from cache ram
without restarting it?
is there one?
how to remove them?
whats the error?
all collections have a .sweep() method
for example client.users.cache.sweep(user => user.id !== client.user.id) will remove all users except your bot
You can use .page nav
.page nav {
color: red;
}``` @stoic girder ?
because of high volume
@harsh blade
background-color I assume @earnest phoenix
I may have to use Bot Designer For Discord to create more commands
yeah try that
Volume is at 100%
Its not volume lag, just lag spikes
Might be from my wifi
@earnest phoenix actually you need !important after the color or it wont work
😂
it is there
what is amethyste-api
but i do not why this is coming
.page nav {
background-color: red !important;
}
@earnest phoenix
ok
@earnest phoenix you're using a module called amethyste-api and this module requires a token to use
you know how to get it
?
i dont know what amethyste-api is, just google it
yes, thx
u need a valid ame token
const ameClient = require("amethyste-api")
const ameApi = new ameClient("token")
again googling for others
you need a token for that thing
don't ask me, you're the one using the api
How to see if a mentioned channel is in the guild?
ok, but
let channel = msg.mentions.channels.first();
let inGuild = msg.guild.channels.cache.has(channel.id);
something like this?
^^^
yeah angelo looks fine to me
how to get DBL API KEY ?
especially with the contrast on hover
looks ugly
you can't tell me this navbar doesn't look good https://cdn.hopefuls.de/1GGY
maybe different "accent" of red
but do u know how to change button colors to white?
my eyes
get your bot approved
thx , want to be sure
THX BRO
#menu .menu ul li a:hover { background: whatever }
Note that you might need !important here as well, and you may want to force only dark or light more in your bot edit page.
ok
top.gg bot page, inverted https://cdn.hopefuls.de/nBLK
has a certain vibe to it 
ikr
Any idea why this isn't triggeren when I react to the message?
this.on("messageReactionAdd", this.reactionHandler);
async reactionHandler(reaction, user) {
console.log(1)
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message: ', error);
return;
}
}
console.log(2)
if(reaction.message.id === "780471746918481940") {
console.log(3)
if(reaction._emoji.name === "📩") {
reaction.message.channel.send("Received")
}
}
}
im still trying to figure out how to run multiple py files at once ffs
@earnest phoenix collected.first() - ain't this a message object? How are you trying to find users from it?
in vsc
async def on_dbl_vote(self, data):
id=int(data["user"])
member = self.bot.fetch_user(id)
result = self.config.find_one({"id": id})
print(id)
if result is not None:
try:
await member.send(f"Thank you for voting for the bot you have recieved {self.coin}1500.")
except:
pass
self.config.update_one({"id": id}, {
"$inc": {"bank": 1500}})``` it didnt event print `id`
so the events not running maybe?
shouldn't it always run when someone reacts to a message?
@tulip ledge is that Eris or? Unfamiliar syntax idk
can someone help me
that's discord.js ;-;
@cerulean ingot maybe you should go to #topgg-api with this.
then just some more fancy code lol
yup
ok
nope
@tulip ledge https://stackoverflow.com/questions/53093266/why-messagereactionadd-do-nothing-discord-js
Message caching thing
hehe stackoverflow for the win
should I put it in my ready event?
i hope i can figure out my problem
#menu .menu ul li a:hover { background: whatever } {
background-color: white;
}``` like this?
Defected
in your style tag
@tulip ledge put what? client.channels.get(CHANNELID).fetchMessage(MESSAGEID); Can't you just cache the message like this before adding the reaction event?
#menu .menu ul li a:hover {
background-color: white;
}```
@earnest phoenix
yeah nvm
I need to make a raw event forgot those existed
channel.fetchMessage is not a function, channel is a valid channel object, did this change in v12?
yep
channel.messages.fetch()
ok ty
mmmmmh, I noticed an issue and have no clue how to fix it atm. When I remove the reaction and then add again it triggers the reaction remove event but when adding again it doesn't trigger the add event
@commands.Cog.listener()
async def on_dbl_vote(self, data):
id = int(data["user"])
member = self.bot.fetch_user(id)
result = self.config.find_one({"id": id})
print(id)
print(data)
print(data['user'])
if result is not None:
try:
print('A')
await member.send(f"Thank you for voting for the bot you have recieved {self.coin}1500.")
except:
print('B')
pass
print('C')
self.config.update_one({"id": id}, {
"$inc": {"bank": 1500}})``` isnt printing anything on vote
I think this is #topgg-api
I’m trying to have it log my id [ As a test ] and it isn’t working.
Code: let me = message.guild.members.cache.get('737918277866487928')
console.log(me.id)
Output:
undefined
@agile lance do console.log(me)
Still returned undefined
console.log(message)
Logging the message wouldnt work
why not
returned undefined -.-
Thats ur issue
u need to do it in ur message event
or u won't be able to get any other properties of the message object
as for you @earnest phoenix console.log(collected)
its not my issue considering it returned undefined no matter what
Is there a guild
:/
Yep
@agile lance Alright, listen here
Lets say you get a basket with apples inside, now you want to count how many apples there are in there but you don't have the basker, how do you do that?
thats not related to anything im asking lmfao
Yes it is
You want to log your ID
You're getting the user object from the members object from the guild object from the message object
the bot has me cached considering it let me add roles to me in the server and everything
@pulsar perch you can use inspect element to get class names
so should i try
if the message object doesn't exist you can't get the guild object, therefor you can't get the message object and therefor you can access the get method
@stoic girder any help with this?
have no clue
client.guilds.cache.get(`Guild ID`).members.cache.get(`My ID`)
Should that work then?
AH
that should work yes
Yes
not really
using inspect element you can find the class names, using these class names you can change the css
collected.first().message.channel.send(`${message.author.username} ha ganado!`)
collected.first() doesnt have the message.channel.send() function
^^^
doubt
you can just do
message.channel.send(`${collected.first().user (not sure about this)} ha ganado!`)
Oh Lite
Now ur here
you proably meant .first().channel and then the rest
U might know how to fix
why cant i use h3?
my issue
what's your issue
this is my issue
async raw(packet) {
// We don't want this to run on unrelated packets
if (!['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)) return;
// Grab the channel to check the message from
const channel = this.channels.cache.get(packet.d.channel_id);
// There's no need to emit if the message is cached, because the event will fire anyway for that
if (channel.messages.cache.has(packet.d.message_id)) return;
channel.messages.fetch(packet.d.message_id).then(message => {
console.log(0)
console.log(packet.t)
const emoji = packet.d.emoji.id ? `${packet.d.emoji.name}:${packet.d.emoji.id}` : packet.d.emoji.name;
const reaction = message.reactions.cache.get(emoji);
console.log(reaction.users)
if (reaction) reaction.users.cache.set(packet.d.user_id, this.users.cache.get(packet.d.user_id));
console.log(reaction.users)
if (packet.t === 'MESSAGE_REACTION_ADD') {
console.log(1)
this.emit('messageReactionAdd', reaction, this.users.cache.get(packet.d.user_id));
}
if (packet.t === 'MESSAGE_REACTION_REMOVE') {
this.emit('messageReactionRemove', reaction, this.users.cache.get(packet.d.user_id));
}
});
}
Here's the code
Code: let me = client.guilds.cache.get("746140615116325005").members.cache.get("737918277866487928") let g = client.guilds.cache.get("746140615116325005") me.roles.remove(g.roles.get(`779647031265329193`))
Error: g.roles.get is not a function
roles.cache also.
Ah, Thanks
Everything is hidden in the cache
Completely forgot about cache there
why are u pinging alina?
its in
collected.first()
and Vigintillion already typed the answer...
@earnest phoenix if u need to find a property just log collected.first() and look for it yourself
I'm not sure the property is user
I'm not gonna write a whole reaction collecter just to find what property you need
We're here to guide you, not to give you the code
its was .author i think
So you're saying,
Remove -> add ✅
Add -> ❌
yeah the author that reacted
So what it's doing is when the message is uncached and gets cached again, then I react to the message the addreaction event fires but if the message is cached and I remove my reaction the removereaction event fires but then when I react to it again the addreaction event doesn't fire
bruh just log collected.first() and look for the property it's literally just english
like I've said multiple times already
So it likely has something to do with if (channel.messages.cache.has(packet.d.message_id)) return
oh its not .author | author is Bot
you get users collection
mmmh yeah could be
but
then it should fire the normal reactionadd event right
and it doesn't
how can I check if a user has a role?
@earnest phoenix add !important after white
ок
can that be in an if?
yes, both of then worked
but you wanted the user
and that's what I was saying
log collected.first() to find the user object
so, no one knows my issue I guess?
Hey- I want to remove every value in an array from a map. How could I do that in JS? (For example, I have a map called users, and I want to remove all users from that map whose ID is stored in the failedUsers array.)
@earnest phoenix whats the code for that?
@buoyant aspen what do you mean
loop over failedUsers and delete each user
How could I do that?
I'm new to maps.
map.delete(key)
you know how to loop over an array?
Yes, I do
then loop over the array and do what flazepe said for each item in the array
what is the issue
so
what exactly is a key? I have (discord) user IDs stored in the array, and I want to delete them from the map. Would the user ID work as a key?
Yes
I have this raw class wich emites to a reactionAdd event, but if the message is already cached and when I remove the reaction it fires the reactionremove event but then when I add the reaction again it doesn't fire any event
It's what you used to set something to the map (map.set(key, value))
Key would most likely be the id
async raw(packet) {
if (!['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)) return;
const channel = this.channels.cache.get(packet.d.channel_id);
if (channel.messages.cache.has(packet.d.message_id)) return;
channel.messages.fetch(packet.d.message_id).then(message => {
const emoji = packet.d.emoji.id ? `${packet.d.emoji.name}:${packet.d.emoji.id}` : packet.d.emoji.name;
const reaction = message.reactions.cache.get(emoji);
if (reaction) reaction.users.cache.set(packet.d.user_id, this.users.cache.get(packet.d.user_id));
if (packet.t === 'MESSAGE_REACTION_ADD') {
this.emit('messageReactionAdd', reaction, this.users.cache.get(packet.d.user_id));
}
if (packet.t === 'MESSAGE_REACTION_REMOVE') {
this.emit('messageReactionRemove', reaction, this.users.cache.get(packet.d.user_id));
}
});
}
We already found out it's due to if (channel.messages.cache.has(packet.d.message_id)) return; but the issue is that when it's already cached it should just emot the reactionadd event but it doesn't
did you update djs to 12.5.0?
they fixed a bug with reaction events in 12.5.0
not sure it applies to your issue but worth a try
I am getting this error on discord.js v12 ```js
(node:11) UnhandledPromiseRejectionWarning: ReferenceError: Cannot access 'member' before initialization
at Client.<anonymous> (/home/container/events/guildMemberRemove.js:10:1)
at Client.emit (events.js:315:20)
Here is that code
```js
client.on("guildMemberRemove", async (member) => {
//Staff Server
if(member.guild.id == `700441653139472394`) {
if(member.user.bot) return;
await client.channels.cache.get(`700457110776971264`).send(`:outbox_tray: \`${member.user.tag}\` has left the staff team!`);
let guildA = client.guilds.cache.get(`700441653139472394`);
let guildB = client.guilds.cache.get(`611881570202025986`);
read it
at Client.<anonymous> (/home/container/events/guildMemberRemove.js:10:1)
is this line here
if(member.user.bot) return;
but I dont get why its not initialization
no its not
okay
@heavy marsh show the full file
const { client, config } = require("../bot.js");
const discord = require('discord.js');
const moment = require('moment');
client.on("guildMemberRemove", async (member) => {
//Staff Server
if(member.guild.id == `700441653139472394`) {
if(member.user.bot) return;
await client.channels.cache.get(`700457110776971264`).send(`:outbox_tray: \`${member.user.tag}\` has left the staff team!`);
let guildA = client.guilds.cache.get(`700441653139472394`);
let guildB = client.guilds.cache.get(`611881570202025986`);
let rolesName = ["CEO - Server Owner", "Lead Operations Manager", "Server Management Team", "Lead Moderator", "Lead Partnership Manager", "Lead Event Manger", "Lead Developer", "Operations Management Team", "Senior Moderator", "Moderator", "Helper", "Server Moderation Team", "Senior Partnership Manager", "Partnership Manager", "Server Partnership Team", "Event Host", "Server Event Team", "Java Developer", "JavaScript Developer", "Python Developer", "Server Developer Team", "Active Server Staff", "Staff On Break"] //All The 23 Role Names
const member = guildA.member(member.user.id);
const xstaff = guildB.member(member.user.id);
const rolesToRemove = rolesName
.filter(n => member.roles.cache.find(r => r.name === n))
.map(n => xstaff.roles.cache.find(r => r.name === n))
.filter(Boolean)
.map(r => r.id);
await xstaff.roles.remove(rolesToRemove).catch(console.log);
console.log(`[Staff Member Leave] ${member.user.tag} (${member.user.id}) left ${member.guild.name} (${member.guild.id})!`);
return;
also, if thats the full file, its missing closing brackets
Nope its not the full file
tim smart
async reactionHandler(reaction, user) {
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message: ', error);
return;
}
}
if(reaction.message.id === "780490933497495583") {
if(reaction._emoji.name === "📩") {
let userData = this.db.ensureData(await this.db.get(`user-${user.id}`), this.config.userData, this.config)
if(!userData.uuid) {
try {
return user.send("Please verify first before applying.\nYou can do so by using `!verify <IGN>`")
}
catch(e) {}
}
console.log(reaction)
reaction.delete()
}
}
}
Why does reaction not have a delete method?
in game name
because it doesnt
how do I delete it then
reaction.remove()
yey
and another weird issue I came across
you need a gank? ask your jungler
Nooo
async raw(packet) {
if (!['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)) return;
const channel = this.channels.cache.get(packet.d.channel_id);
if (channel.messages.cache.has(packet.d.message_id)) return;
channel.messages.fetch(packet.d.message_id).then(message => {
const emoji = packet.d.emoji.id ? `${packet.d.emoji.name}:${packet.d.emoji.id}` : packet.d.emoji.name;
const reaction = message.reactions.cache.get(emoji);
if (reaction) reaction.users.cache.set(packet.d.user_id, this.users.cache.get(packet.d.user_id));
if (packet.t === 'MESSAGE_REACTION_ADD') {
this.emit('messageReactionAdd', reaction, this.users.cache.get(packet.d.user_id));
}
if (packet.t === 'MESSAGE_REACTION_REMOVE') {
this.emit('messageReactionRemove', reaction, this.users.cache.get(packet.d.user_id));
}
});
}
This works perfectly except, the first time I add a reaction it doesn't trigger the event, only after the first one.
It says x
there's no client id
When I make my invite link
@earnest phoenix Did you consider putting your client ID
Wdym?
...
reread the documentation on discord
My client id is 778466457495404586
Can i use Bot Designer For Discord????
then put that in where it says to put your client ID
Technically yes, but please never do.
Why
Still don't work
bcs thats your id?
you did it wrong
Tim, do u know a fix to my issue?
Because if you want to code, then you should learn how to do it rather than use software to do it for you.
Wait
you removed stuff
yes homo
Bro?
reaction.remove() removes all reactions, and not the one from the user
Well, since i only have a mobile device, its the only way to code my bot. But sometimes it will not work correctly.
Example
z!ban @user reason here
Bot
Thumbnail is invalid.
lmao
if you want to remove a single reaction its reaction.users.remove(id)
That made absolutely no sense.
(╯°□°)╯︵ ┻━┻
To start with, I have no clue what the Bot is supposed to represent and what is "Thumbnail"?
they are using bot designer
how does the webhook api work?
@quartz kindle Thank you - It worked now
oooof
$nomention $onlyForIDs[753097781182201906;] $setVar[Ban;true;$mentioned[1]] I have banned $username[$mentioned[1]] from using this bot!
ew
Tim do u also know a solution to why the first time I react to it it doesn't emit to the event?
Im banned from that server
then you're out of luck lol
okay mate
but didn't work
i tried to do "JOINTOCREATECHANNEL": ["id1", "id2"]
that still doesnt make sense to me
uhh
look
that script is temp voice channel
u join a channel it detect that and then make new one and move u to it
but when i try on mutiple servers it dont work
if(newState.channelID !== config.JOINTOCREATECHANNEL) return; //if its not the jointocreatechannel skip
you only allow it to run if it matches a specific id
have you thought about using discord.js's partials instead of the raw event?
mmmh no I haven't
didnt understand
your code says "if the id of the voice channel is not equal to config.JOINTOCREATECHANNEL then do nothing and exit"
yee
so if you want it to work on other channels you have to remove that
can explain why please
isnt it self explanatory?
you only allow the function to run if the user joins a specific voice channel
any other voice channel the function will just exit
Im now in the server
@quartz kindle did not work
you dont need a vpn for that lol
@quartz kindle there was a problem
what problem
u didnt understand me right
perhaps you didnt explain right?
ah so you want specific channel ids
yee
i didnt mean that
to have multiple ids, do what you did before in the config file, with ["id1","id2"] etc
but change the code to includes
if(config.BLA.includes(state.channelID))
hmmm
if(config.JOINTOCREATECHANNEL.includes(state.channelID))
u mean this
hmm state is not declared
I dont know, how to start my discord.js bot automaticly on boot on debian 10. Help would be nice
do you use a process manager like pm2 or nodemon?
no,
i tried it with using init.d and a service, but it wownt work
there are many different ways to set it up, try googling it
@quartz kindle man am dum af
im googling it 6 hours
Cannot read property 'channelID' of undefined
show the code you had before, and the code you have now
just the user joined part
i was googling it 6 hours... but nothing worked
did you try everything on here? https://medium.com/@jsakov/linux-start-an-application-automatically-at-boot-2b6fb61524d7
// JOINED V12
if (!oldState.channelID && newState.channelID) {
if(!config.JOINTOCREATECHANNEL.includes(state.channelID)) return; //if its not the jointocreatechannel skip
jointocreatechannel(newState); //load the function
}
i just changed this
the problem that i did
was your old line
nvm
i was doing other shit on the top
that why it didnt work
@quartz kindle thanks for ur help
is there any way to see console out put
how can i make timestamps like discord? e.g today at time but when its been like 2 days it says the date e.g 12/25/2020
should i use moment to do like Today at ${moment(.....)} and use an if statement to check if the date has been 2 days
will i need to make a cog to have my bot to be able to run multiple py files in visual studio code?
vscode doesn't run anything, it's the terminal executing it
also u can't have more than 1 py file being ran per terminal
what you can have is a file calling another file
can someone help me on how to use exec, im trying to make a -eval console.log("test") command so it will output the console.log or whatever code is specified.. but idk how to get exec to works
JS?
yeah
what does eval have to do with exec?
Hi i'm re-doing my bot, and when I used the node init command following the discord.js guide I have much less node_modules in my bot's folder would that be an issue? using d.js library
npm init is for creating new projects. Run npm install to install libraries.
If it looks like less but still works, it's probably expected behavior.
You'll know if it's wrong if you get an error.
ah, sweet thanks, if it's gonna work with less libraries might as well go with that tbh
you can attach a .then after .send(message) i think
depends on your language
oh completely ignored the fact that it does depend on your language lol
create a callback or assign the send method to a variable then .delete({ timeout: time })
no
wait no
I need to do this for an embed
@earnest phoenix
they both dont rlly explain callbacks
this is the one
@earnest phoenix
Can I do .delete after I've already done .bulkDelete and .then
if you did bulkDelete, then the message you want to delete is already deleted
let winner = msg.reactions.cache.get('🎉').users.cache.filter(u => !u.bot).random();
TypeError: Cannot read property 'users' of undefined
Sa
Help plz
const eval = exec('eval.js', 'args=${evalString}');
eval.process.on('message', (returned) => console.log(returned)) ```

lmao
wouldnt you do something similar for a VM eval?
assuming you could do something like that and spawn a node process inside it like that
cuz your filter is only filtering for a reaction
awaitMessage()
you do know just that wont fix the issue right?
you want to start getting messages, but your filter and your collector are for reactions
also why async?
also also
first() may not always return something
cuz u set a timer
if the timer runs out first it will error
so, its wrong as is
also also also
embed builder = bad
also also also also probably a good idea to add a command handler
Hi, I'm trying to remove the reaction of the user who clicked on it.
my code ```js
msg.react("⏭️")
collectorR.on('collect', async (reaction, user) => {
console.log(msg.reactions)
await msg.reactions.cache.get("⏭️").remove(user);
console.log(`Collected ${reaction.emoji.name} from ${user.tag}`);
});```
what should it do : remove the reaction of the user who clicked.
what does it actually do : removing the bot + user that clicked reaction
Did I make a mistake ?
yes, now there are other 4 things i pointed out that you might wanna fix/improve
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send.discord.Embed(
title = "Command Invalid",
description = "Command not found, Please make sure it exists and try again.")``` It should send an embedded error but it doesnt send it, it doesnt show any errors neither...
or did i miss something?
what in the fuck
ctx.send(embed=your_embed_object_here)
ive never used the embeds before...
You are creating one there already
oh
but you somehow managed to do ctx.send.discord.Embed
oh i see
it works just doesnt send a message into the chat lol
is that a but with what i did?
bug*
Yes
I use fs.readdirSync for my bot commands, could I possibly do the same for the events? d.js library
send is a method of a messageable object (member, user, text channel, group DM)
now where to do that
ctx supports using it as it is a shortcut for ctx.channel.send
i see
in that method's parameters, you provide an embed keyword argument, value of which will be a discord.Embed instance
where should i send the bug report and what should i put?
i seee
so is discord.embed like ctx.send but more fancy
or
...no
oh
ctx.send literally just sends a message
ahh ok
be it an embed or a simple message with content
so you basically fucked up
never did
oh thiught you did
how can i load the html with with checkboxes already checked?
refer to this as an example
pls ping me if you do respond
object/instance meaning the same thing here
so should i put the discord.embed behind the brackets
new discord.embed()
im so confused man
but is that a bug because there was no error while coding so i assumed it was normal xd
it's very highly possible that the error was literally consumed
aka "handled" improperly
well, it's a bug... created by you
yay
I was there myself and had to learn it the hard way
should I log my bot's errors directly into a discord channel or do I read the error-log file and then output that into the discord channel whenever a new error gets added?
It's your choice, but if I were to do it, I'd have a logs/ directory then store the logs of the standard output (console.log) and the standard error (console.error) in the file.
Report what where who why
the bug yuo said i made
It's you not handling your exceptions properly that an error happened without any output
You don't "report" it. You debug your program, see what the fuck you diddly voodoo'd and why it's doing a fucky wucky
wee woo bug created wee woo must debug wee woo brrrrrr must fix
bug made go bbbbbbbbbbbbbbrrrrrrrrrrrrrrrrrrrr
because .has cant have a array what do i use
if you want to match any premium role, use array.some()
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send(embed=discord.Embed(
title = "Command Invalid",
description = "Command not found, Please make sure it exists and try again."))``` so that somehow didnt work....
unless i fucked up the embed 
PREMIUM.some(id => member.roles.cache.has(id))
what doesn't work about it
const express = require("express")
const app = express();
const config = require('./config.json');
const port = "4444";
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/public'));
app.set('views', __dirname + '/public/views');
app.set('view engine', 'html');
app.get("/", function(req, res){
res.render("index.html")
});
app.get('/login', (req, res) =>
res.redirect(`https://api.instagram.com/oauth/authorize?client_id=${config.app.id}&redirect_uri=${config.redirect.uri}&scope=user_profile,user_media&response_type=code`));
app.use(function(req, res, next) {
res.status(404).send({ message: "Yikes bro wtf!" });
});
app.listen(port, function(){
console.log(`Server is live in localhost port ${port}, good luck :D`);
});```
it throws cannot find module "html"
ping if anyone can help
would throw the same error without it
even if you remove the view engine line?
i gotta double check 1 sec
doesnt send the message
should send as an embedded error
but nothing sends
no errors neither
yup it still throws that error
i think i will just start over with a clean project tomorrow step by step and not gonna bother to fix this one
lol
?
i made an app
and i have everything set up
but i dont remember the next step
with the dyno
Hey
nvm im dumb
How do I call off the GuildMemberRemove event when the bot detects a ban event
for filename in os.listdir('') do i have to list an folder or can i just list an file also can i list multiple files insde the listdir?
It depends on the order of events received, which I don't think are in a fixed order. One workaround would be to request the audit logs and see if the removal was last due to a ban (and check the time of course).
do i have to list an folder or can i just list an file
Do you want to list only files or folders, or something else?
also can i list multiple files insde the listdir?
So you want to read all the directories recursively?
Like, are you looking to match a pattern or something? Could you reiterate what you want.
How do I call off the GuildMemberRemove event when the bot detects a ban event
for it to run code in other files as im pretty sure its possible using cogs if im correct
It depends on the order of events received, which I don't think are in a fixed order. One workaround would be to request the audit logs and see if the removal was last due to a ban (and check the time of course).
what if the result is null
if the audit hasnt loaded
how would i know if i should mark it as a ban or leave
cause sometimes the bot returns null cause though it was a ban the audit didnt load when bot queried
You could use __import__(path) to import a file by a string. However, if you're using cogs (or extensions, better choice), all you need to do is pass the path to the file as a string and discord.py will handle the loading for you.
You could keep using os.listdir, but there's a more cross-platform approach. From the pathlib module, import Path, initialize it, and use the glob method to return a list of files and directories. For example: ```py
from pathlib import Path
for ext in Path().glob("cogs/*.py"):
...
It's just an approach I came up on the top of my head. Really, I don't think there's a good way of canceling one event when I don't know if it'll be guaranteed for one event to always be called before the second one (and I don't think it is). I'd personally handle both events or have a condition where I see if one of the two events has already been called and ignore the second one.
Yea the question im asking is how to call off or ignore the second
Because my bot will have an antinuke feature but i need the executor for it lol
oh, then you could have some local variable to record when the first one has been fired, then ignore the second one. For example, having an array of guildid-userid, see if the array has the element. If it doesn't, add it. If it does, remove it from the array and ignore second event.
hmk thanks
so is that better than ```class Moderation(commands.Cog):
def __init__(self, client):
self.client = client
def setup(client):
client.add_cog(Moderation(client))``` each file defining the name etc and instead just making it import?
or am i getting something wrong here
its late and im not thinking dtraight
now inside your loader, read the directory where you store the cogs and call bot.load_extension(...) where ... is the name but with / replaced for .
what do you do for this now message.guild.roles.find
how can i make my bot display the users o servers count
?
Users of all servers that he's in
Going back on my example: ```py
from pathlib import Path
for ext in Path().glob("cogs/*.py"):
...```
This is what your loader could look like. It basically reads all the files in the cogs/ directory, which is where we'll be loading the extensions.
Now, in the for iteration, it could look like: ```py
cog_name = ".".join(part for part in ext.parts)
bot.load_extension(cog_name[:-3])```
".".join(part for part in ext.parts) forms the cog name to load it by. cogs/Moderation.py will look like cogs.Moderation.py
bot.load_extension(cog_name[:-3]) will load the cog, but cog_name[:-3] will remove the .py postfix because it shouldn't be included.
In conclusion, this loads it by cogs.Moderation.
over engineering™️
ahhhh i see
what library
discord.js
You can use .reduce to total up the number of users across all guilds and get the total user guild with <Guild>.memberCount
how?
what does this mean
Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes.
async def load(ctx, extention):
client.load_extension(f'cogs.{extention}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')``` so should i modifiy this too then?
its in my file that runs the bot
In code, you'll use <Client>.guilds.cache.reduce and work from there. Read up on the reduce method here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
lite
what does Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes. mean
it means what it says lol
does it mean it isnt a role?
yes
It means your input is not a:
Roleinstance- Snowflake (role ID)
- Array or collection containing the two things I said above
Use ```
```
You probably shouldn't be loading every cog in there as you've already loaded them at that point and will lead to errors. You probably only want to load one of the files, which is the user input.
role.create?
hmmm i see
message.guild.roles.create()
i am trying to grt it to load the commands inside the files so i ca then use them which is every file inside the folder but idfk
are you trying to create a role? or what are you trying to do?
creating a role?
message.member.roles.add(message.guild.roles.cache.find(r => r.name == "Verified"))
this will error if their isn't a role called Verified
can I add like a catch?
you dont need a catch for that, you just need an if check
checking for???
@sudden geyser im confised do you want to see the code via screen share and you can help me from there
we can do it via dms
let role = message.guild.roles.cache.find(r => r.name == "Verified");
if(!role) return message.channel.send("role doesnt exist, please create one")
so
let role = message.guild.roles.cache.find(r => r.name == "Verified");
if(!role) return message.channel.send("role doesnt exist, please create one")
message.member.roles.add(role).catch()
the catch there will handle errors on the discord side, like failing to add the role because of a permission issue
ok
it doesn't help enough ;-;
do I need the color data for roles.create?
@safe creek 
should be optional
ugh my head hurts 
With python?
js
@earnest phoenix .reduce works by you passing a function, and the .reduce method calling your function repeatedly until it's able to produce a final output.
The function you pass should have two parameters: accumulator and element. accumulator represents what's being accumulated. In this case, it'll be the total number of users across all guilds. element represents the current element we're iterating on. In this case, the current guild. To better understand it, we'll be calling them total and guild.
.reduce takes a second argument, which is the initial value total should be at the start. Since we want the total user count, this will be 0.
Now, your call probably looks like this: ```js
<Client>.guilds.cache.reduce((total, guild) => {...}, 0);
Now, how do we get the total user count? Simple. We need to add the accumulator with the guild's member count. To get the member count, do `guild.memberCount`.
Now, it looks like this: ```js
<Client>.guilds.cache.reduce((total, guild) => total + guild.memberCount, 0);
If you run it, it should be the total number of users.
Thx
anyone know which hosts properly support tensorflow prebuilt libs for python
galaxygate cpus dont support the instruction set tf uses
So when you think about it, java is just heavy js?
nah
Hey
hmm
quick: how long is a server id? is the length always the same?
sometimes 1-2 number shorter/longer
alrighty
what would be a good database to save a users ign
any of them?
like space wise
either way it's not going to matter
so quick.db would be fine?
i mean yeah..
help?
unless you're storing a ton of igns
a little help?
100k
yeah i mean..if you're not storing any other data you should be fine with any DB
for python?
js
how do I change channel permissions to give someone with MANAGE_MESSAGES Permission to look at the channel
dont know how to do it with ID
permissions.Overwrtie
For?
to get the author's id
it display some errors
how can i add that to the status
@sudden geyser
resolve the errors?
how can i like make the switch background a specific color?
like i did the for first one?
i cant get it working for the second one
like how can i set the circle pill thing's background
?
like the background color
css
look for its id or class
ive been trying for an hour
is this your own website?
you can just use element.style.background-color = #000000
like if i do background color
this happens
it makes it work
but it leaves the other thingy too
you know wat i mean?
wdym
where?
like i dont know anything about js
so sorry lol
i only want this small part to be the color
hey i need help adding async to my command handler, can someone help?
whenever they click the switch
you could just add an onclick
in the element
like how you would add style by element
nope
i already tried
well what is the error
leave?
just dm me if you can help
like close the page
no lol
like regarless of the state
so i got it working for toggled on
idont know
but i did
just mark it as an async function and handle errors the async way
yeah im having some trouble with this
@sudden geyser
that's a lot of errors
it doesnt need to be dynamic
you mistook something
<Client> is a placeholder for your instance of the class Client
If you named it bot, you'd put bot
If you named it client, you'd put client
Of course, it must be in scope.
HM
Second of all, the message in your terminal is not an error. It's a warning. You have too many message event listeners (<Client>.on("message", ...)).
code for,on 24 hours?
Barnie it's the name of a variable
sorry, that's not what I meant by dynamic
essentially what you need to do is get the value of the button and use if statements to change the background-color
no
i want the same
like regardless of the button
like this is da switch
if u unlcick it
i want the keep the dark blue thing
ok then just change the background color when it's toggled on and not when it's off
yes i understand
so just check if it's toggled on when you click it??
it's a button right?
same idea
but i dont want it to change
just check if it's checked
like i wanto have the background
YES IK
regardless of the state


