#development
1 messages · Page 1823 of 1
pretty sure you can put any twitch url there
the stream doesnt need to be yours
i got error be like thius
- b.defer is not a function
- Unknown interaction
any one can tell me how can i solve
oowh that is awesome actually
or wait
noo
i need to have the streaming presence myself
not my bot
as i want my bot to be detecting me
then you cant. to put it on yourself you have to be streaming yourself
ah shit
don't really know whether this is the right channel
client.on("presenceUpdate", (oldPresence, newPresence) => {
if (!newPresence.activities) return false;
newPresence.activities.forEach(activity => {
if (activity.type == "STREAMING") {
const newid = newPresence.user.tag
const streamer = guild.members.fetch(newid)
const streamerlogs = streamer.roles.cache.array()
console.log(streamerlogs)
console.log(`${newPresence.user.tag} is streaming at ${activity.url}.`);
};
});
});```would this only be activated when someone changed their activity to streaming? So not people who are already streaming?
none channel here
when someone's streaming the status change automatically
but like, only if using the desktop client, not the browser one
i am going crazy, anyways heres my problem
(node:21976) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
triggering on line 72:28, which is
message.guild.id
i suspect this being DISCORD API BEING AN IDIOT but eek
this USED to work.
thats my code, is it because its literally at the top of the listener?
and yes, i need help because new commands dont get pushed for some reason 
if message is sent in DMs then the guild property will be null
so i should move the if statement if the message is in a dm to the top of the listener?
like this
yea something like that can work
tf well that fixed the error but
now my new commands arnt being seen in the help command
which is dynamic
and i cant execute that command for some reason
You might have messed up some properties in those new commands then
no? its the same thing lmao
i copied paste the code from another command, and i put them in a new command
grr this is weird
no? the properties look fine
and other commands still work
ill try logging the command in console if anything would work
one sec
Debug too
Log all the commands in your help command
Make sure the new commands are there
Hi guys
I need help
In my bot I wanna do something like this:
I need help in a script
Actually
exemple:
.hat
bot answer: message1
.hat
bot answers: message2
.hat
bot answers: meaage3
ect...
if statements?
...
@pale vessel i logged other commands, it worked perfectly
EXCEPT FOR THAT ONE STINKY COMMAND
Helloooo?
I need help in a script
Actually
exemple:
.hat
bot answer: message1
.hat
bot answers: message2
.hat
bot answers: meaage3
ect...
oh wait.
._.
im going to fking SMASH MY LAPTOP
HOLY FUCK
IVE BEEN DEBUGGING THIS SHIT PROBLEM FOR 4 HOURS STRAIGHT AND THAT WAS THE PROBLEM?
IM GOING TO FKING AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ok to the mods, im sorry :>
....
I need help in a script
Actually
exemple:
.hat
bot answer: message1
.hat
bot answers: message2
.hat
bot answers: meaage3
ect...
please
seriously just use args and if statements?
someone helps me
well I didn't developpe my bot for that
I use some other commands
not these
It's my first time trying to do this
can you DM me?
Yes
I'm the first official owner
I created the bot
and i started the idea of the bot
but the other owner, they code everything?
No
They are just helping me with the ideas
I just use one command that I copy and paste and just change the content
but who codes them?
I coded everything
the other owner helped me with the idea of the stories
for exemple
we have an embed code
I change its content
and use the same code everytime
uc?
and that is?
im sorry if i sound really angry rn, i just experienced the most shitty programming moment of my life
sorry no lol
my mind is melting and i might just throw a fit if i try to help lmao
thanks cya
if (activity.type == "STREAMING") {
const newid = newPresence.user.id
const streamer = await guild.members.fetch(newid)
const streamerlogs = streamer.roles.cache.array()
console.log(streamerlogs)
};```hey streamerlogs contains: [Role, Role, Role , Role]. So basically an array with 4 role properties. How would i loop through each one of them and get their name
i already tried: for (const names of streamerlogs){
console.log(streamerlogs.name)}
@pale vessel can you help me in this?
I need help in a script
Actually
exemple:
.hat
bot answer: message1
.hat
bot answers: message2
.hat
bot answers: meaage3
ect...
What do you code in?
node.js
How many messages, 3?
Or is it some sort of a counter?
3
Just three different messages, does it reset after the third one or what
I don't 
That should have worked I can't read
it gives you a gif
u write .hug again
it gives you another gif
you write it again it gives another one
ect
Wouldn't that just grab a random element from an array?
that's just a random reaction api
?
You defined it (the role) as names so use names.name instead (very confusing, fix your variable names I suppose)
streamerlogs.name would be undefined
you make a GET request to some reaction api, which will return a random gif
or you make an array wil many gifs, and get a random entry
When I react in a reaction, the bot does this: ```js
client.on('messageReactionAdd', (reaction, user) => {
console.log('a reaction has been added');
});
but the bot dosen't send the message :/
When I do that it gives me all the gifs together
Send what message?
me?
like array[Math.random() * array.length]
Yes
euhh not message bruh, when someone add a reaction in a message, there is nothing in the console
Can you dm me so you explain it more to me?
Do you have the GUILD_MESSAGE_REACTIONS intent?
yes
You need to enable partials to support that
how?
only reaction?
Sure, if that's all you need
er question
what are intents for in d.js?
i see, but can you give a docs link for d.js aswell?
thanks
Here's a nifty guide: https://discordjs.guide/popular-topics/intents.html
not works
I add a reaction in a message but not works
I click on a heart and actually I need to recieve a role
but nothing
@pale vesselwhat intents should i enable?
so i dont have to screw around them in d.js and not worry
How'd you enable it?
can i dm u?
GUILDS is needed and you can pick which one that includes the events that you need (like GUILD_MESSGES) here https://ziad87.net/intents/
rq
Naw, just send it here if you can
alr
are you sure you deconstructed the Intents constructor?
exactly
I'm using the embeds
and
let's take this as an exemple
else if (msg.content === ".hat"){
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('One Hat for you :D')
.setAuthor('Little Kiwi')
.setDescription('' )
.setImage('https://i0.wp.com/boingboing.net/wp-content/uploads/2020/02/ezgif-3-6fafa7091356.gif?fit=489%2C408&ssl=1') .setTimestamp()
.setFooter('');
msg.channel.send(exampleEmbed);
}
});
Alr
and as i said earlier
i wanna do something like
when they write .hat
they get this
But when they write it again
they get something else
See what I mean?
like ```js
const { Intents } = require('discord.js')
._.
so now, i could just enable GUILDS only? and d.js 13 can still use it
well nvm i give up
i do have a bunch of other commands tho
and i dont really know what intents should i enable or not.
You can use counters, like ```js
let counter = 0;
client.on("someMessageEvent", (...) => {
...
if (command === "someCommand") {
switch (counter) {
case 0:
// Send first image
break;
case 1:
// Send second image
break;
// and so on...
}
counter++; // Increment the counter or do something with it
}
});```
I do what so?
I'm sure you need others
Imma try
What about member presences, like online status, activities, etc.
That would need GUILD_PRESENCES
really, i have no idea what should i add
so now, ['GUILD' , 'GUILD_MESSAGES', 'GUILD_PRESENCES]
what does GUILD_BAN do?
makes the client ban people?

GUILD_BANS, the ban list
there is guild presences
ah so when unban command?
Yeah, but you can fetch it even if you don't have the intent
IIRC
Unless you need the intent to fetch it too
It worked
i see, i dont have the unban command so ill just put the intent whilst i still have it 
thanks
Look here and make sure all the events you use are present
Otherwise it just won't trigger
@umbral lake I'm not sure what's wrong, sorry
Enabling partials should make the client emit partial events
i see, so ['GUILD' , 'GUILD_MESSAGES', 'GUILD_PRESENCES, 'GUILD_BAN'] for now.
Sure
thanks for the advice 
You can pass the array directly to ClientOptions
Intents class isn't really needed
GUILD_BANS BTW
Just in case
?
yeah i know lmao

@pale vessel this correct?
const client = new Discord.Client({
presence: {
status: 'online',
activity: {
name: 't!help',
type: 'LISTENING',
},
},ws: {
intents: ['GUILD' , 'GUILD_MESSAGES', 'GUILD_PRESENCES', 'GUILD_BAN']
},
});
and it was GUILDS and not GUILD
lmao
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
Don't say I didn't warn you 
Ah, GUILD_BANS has nothing to do with fetching the ban list
It's for the GUILD_BAN_ADD and REMOVE events
If you need those for example logs then yeah
error is (node:31936) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'prefix' of null
im going to go crazy man how do you set properties again
fetchprefix = "t!"?
Ah wait but you need fetchprefix.prefix if it exists
So const fetchprefix = (await prefixSchema.findOne(...))?.prefix ?? "t!";
let fetchprefix = await prefixSchema.findOne({
guildID: message.guild.id
})?.prefix ?? "t!"```
?
Do you know what that does?
i actually have never encountered the ? and ?? operators before
You have to wrap the findOne() method with () since a Promise instance doesn't have the prefix property
then ?.prefix checks if that property exists
if not, it returns undefined
then the ?? operator kicks in
then it returns "t!" in return
? is optional chaining on an object if that property doesn't exist it returns undefined eg person?.name if person is undefined prefix is undefined
?? is the nullish operator which "triggers" when the left hand variable equals null or undefined

mf i learn shit for school? give me 10 years or more
shit for hobbies? give me 5 mins
Ikr
@pale vessel weird, i already did this and it dosnt return "t!" when i logged it
Did you use the exact same code?
fetchprefix.prefix still returns undefined
ohhh

one sec im sorry
and prefixSchema.findOne().prefix.prefix is also undefined
That'll never pass anyway
You're setting the variable "fetchPrefix" to the value of prefixSchema.findOne().prefix ?? "t!" aka there's never a property prefix on fetchPrefix
oh
wait
ok now it returned t!
wooh, it works
thanks guys
and TIL about ? and ??
TIL?
today i learnt/learned
Reddit
what is the max size of image in embed?
No i meant the size, similiar to user.avatarURL({ dynamic: true, format: "png", size: 1024 })
yes, resolution
I'm sure it depends on the file size than the resolution
You can also do some experiment I suppose
I think you'll hit the file size limit before you hit the resolution limit
embed.setImage(user.avatarURL({ size: 1024 })) - here what should be my max size
but embed looks similiar in both sizes
Are you on phone or desktop?
desktop
I think Discord resizes it anyway using the width and height query parameter
yeah thats what I'm asking, what is that width and height
or is it not a matter of concern, and I can go safely with max size of 4096?
Naw, as in Discord downscales it
4096 might be a bit too much
I'd say 1024 or 2048
don't think you can use query params to get anything bigger than 512
I think it's only for smaller resolutions (mainly for thumbnails)
It's the maximum width for mine
Guys help me find the original google play console site
Do you know a host that has a ping lower than 30ms?
After long studies
I discovered the script
of random messages
var cute = [ 'picture1idk', 'pic2', 'pic3', 'pig4' ] let cutepics = cute[Math.floor(Math.random() * cute.length)] msg.channel.send(cutepics)
And it works!
:D
ofc you add
else if (msg.content === " ")
const { value } = await this.client.db.collection("guilds").findOneAndUpdate({ id }, {
$set: {
[`settings.${clientID}.${data.key}`]: data.value,
[`settings.${clientID}.${data.key2}`]: data.value2,
[`settings.${clientID}.${data.key3}`]: data.value3,
}
},
{
upsert: true,
});
``` hey anyone has any idea like how I pass a object which will be directly updated to db rather than doing this
I'm trying to update key value data inside a object
Oh sorry I have no clue :|
const { prefix, appID } = require("../config.js");
module.exports = {
guilds: {
data: {
[appID]: {
prefix: prefix,
someKey: someValue
}
}
}
and this is my data structure
wait, what are you trying to do?
why is there a settings in here
yeah I noticed that and I fixed but still
I want to pass an object directly to db rather than using key2, key3
and then setting the value
is that mongodb?
yep
Assalamualaikum
I mean can't you just do
const object = { ... };
await findOneAndUpdate({ id }, { $set: object });
I'm storing data for multiple clients
look at this
I'm not following
what are you trying to do exactly?
You want to pass that object to the db?
yes
ye
(I don't use mongo)
Alright
Whats the key and whats the value?
appID.prefix: prefix
Like that?
yes
I wanted to make it like for multiple clients like obj inside obj
like one guild document for 3 of my bots
ok
yes
function insertIntoDB(object) {
const clientIDs = Object.keys(object.guilds.data)[0];
let output = {};
for (const clientID of clientIDs) {
for (const key of Object.keys(object.guilds.data[clientIDs]) {
output[`settings.${clientID}.${key}`] = object.guilds.data[clientIDs][key];
}
}
return output;
}
let object = insertIntoDB(YOUROBJECT);
await findOneAndUpdate({ id }, { $set: object });
Would this do?
I don't use mongodb so I may have miss interpreted something
hmm
can you like explain that function I'm understanding few things
const { value } = await this.client.db.collection(this.collection).findOneAndUpdate({ id },
{
$set: {
[`data.${this.client.id}.${obj.key}`]: obj.value
}
}, {
upsert: true,
returnOriginal: false,
projection: { _id: 0 }
});
``` even this is not working
Well I get the array of appID's (your client id's) then I'm looping over them so we can set the keys for each client, then we loop over the keys of the object to then set the key for each client to it's respective value which should return an object that you can then use
Well, what is obj?
obj = {
key: "prefix",
value: "-"
}
Can you like wait for few minutes. I'm taking my dinner now :/
Maybe
Thanks
It will just take few minutes I eat really fast tbh
Oh wait actually it will be this.client.user.id
Lol
It's wrong lmao
?
@tulip ledge
async update(id, obj) {
const { value } = await this.client.db.collection(this.collection).findOneAndUpdate({ id },
{
$set: {
[`data.${this.client.user.id}.${obj.key}`]: obj.value
}
}, {
upsert: true,
returnOriginal: false,
projection: { _id: 0 }
});
this.cache.set(id, mergeDefault(this.defaults, value));
console.log(this.cache.get(id))
return true;
}
if(streamer.roles.cache.has(role1.id)){
console.log('test')
streamer.roles.add(role15)
}else{
streamer.roles.remove(role15)
}```hey i basically have this function that adds a certain role to a user if it is streaming. How would i make sure that this else statement works? because right now it doesn't (probably because it is not being updated).
Should i use a setInterval on the else statement?
or something
no. I removed the role1 from the streamer, but no change in role removal.
i mean the else statement only works if the person doesn't have the role1 role
Yeah, I removed it after the user had the role.
So I first checked added role1, so that gave a certain role to the streamer. Then I removed tole1 and It should remove role15 again.
but it doesn’t.
Its because there is no event triggering it.
I will put an interval on that code for like a minute.
On the else statement
Or else if there is a more efficient way?
hello, I wanted to know how the verification of bots in discord works.
I have this:
I console.log this: const apresence = message.author.presence.activities
how to get the state?
Hey! I have a bot that adds a role to someone that is streaming. I also want to remove the role once someone stops streaming, but it doesn’t work. It logs nothing and doesn’t error:
it sadly still didn't delete the role15:```js
if (!newPresence.activities) return false;
newPresence.activities.forEach(async activity => {
if(oldPresence.activities.some(x => x.type == 'STREAMING') && !newPresence.activities.some(x => x.type == 'STREAMING')){
const newid = newPresence.user.id
const streamer = await guild.members.fetch(newid)
streamer.roles.remove(role15)
}
if (activity.type == "STREAMING") {
const newid = newPresence.user.id
const streamer = await guild.members.fetch(newid)
const streamerlogs = streamer.roles.cache.array()
if(streamer.roles.cache.has(role1.id)){
console.log('user has founder role')
streamer.roles.add(role15)
}
}
```
(I am using precenseupdate btw)
ping me with the answer please!
apresence[0].state
Hello can someone help me? I don't know why it's saying it's undefined i'll post the full code if needed Thanks in advance!
How did you define User?
And you provided an ID?
Yeah
okay i'll try
uhhh i kinda forgot how to use await didn't develop a discord bot in a long time
Gotta be in an async function
is 1msg.author.bot the best way to check if a message comes from a bot?
Yeah as it’s a boolean value
Anyone that knows the answer?
tbf it's the only way to verify
You're returning false if there are no activities. I'm not really familiar with the way activities work or how you're checking but maybe you should try without that line? Or code it another way. Basically what I mean is if they stop streaming and have no activities on their new presence data it'll return before it gets a chance to remove the role.
Maybe return if the new presence has no activities set and the user doesn't have the streaming role
That sounds pretty good actually. Might remove that line!
Or wait actually, stopping a stream is still seen as an activity as the presence changes.
Tbh I'm watching Netflix so I didn't read through the rest of your code.
What do you get for newPresence when the stream stops?
Okay thanks
It returns nothing
Yeah so my suggestion might work.
It’s like that 2nd If statement just gets skipped or something
Yeah I will try that and let you know
Your first line is saying "if the new presence doesn't have activities, ignore everything that follows this line" which is what happens every time they stop streaming.
that code can be simplified a lot
That also
const oldStream = oldPresence.activities.find(a => a.type === "STREAMING");
const newStream = newPresence.activities.find(a => a.type === "STREAMING");
if(!oldStream && newStream) {
// user started streaming
} else if(oldStream && !newStream) {
// user stopped streaming
}
alrighty. Thank you so much guys
@brisk portal https://anidiots.guide/understanding/sharding
oh ok thanks
How would I modify this RegEx so that it will only capture if the full parameter is matched instead of just part of it?
Ah ok! Cheers G
I need someone to create a bot for me? For the Olympics
I make my own bot but i don't know why my bot don't move to voice channel
when I check bot's voice_clients, it gives me an empty list
I'm doing my bot with python
send code
how can I put my code in discord
`
code
`
async def join(self, ctx):
print("join")
if ctx.author.voice and ctx.author.voice.channel:
channel = ctx.author.voice.channel
await channel.connect()
else:
await ctx.send("not in voice channel")
in the class and self.__bot = bot
in main file I add this code
bot.add_cog(myclass(bot))
bot.run('token')
ok there are 2things I'm wondering here, if you're in a class why is @commands.command() not @commands.Cog.listener()?
The code you copied should be indented back by one
cuz I don't know how to use @commands.Cog.listener()

Thanks! I'll check it
yeah you don't have to worry about @commands.Cog.listener() since it's for events, not commands
oh got it
which language is better to make bot golang and python?
there's no "better" language
unless you need a specific use-case
it's just whichever you prefer
yeah you needed the voice part of it too
once you dl the library i think you should have it
It's just optional
Are there other options?
nope
just discord.py and discord.py[voice]?
yes
👍
?
await bot.process_commands(message)
shouldn't have to
that's for on_message
iirc that's only if you have a on_message bot event in your main file
if you have an on message event in a cog, you won't need it
oh got it thanks 🙂
@split blade simply don't use [] or quotes
[] in regex means char matching
and strings don't need to be quoted at all
What's a reasonable permission to require a user to have in order to change the bot prefix?
Alright, thanks!
for me i think admins should control the bot's config 
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: DataError: invalid input for query argument $1: ' Edition Fossi... (a boolean is required (got type str))
```why am i getting this error when my data type for $1 is text?
in discord.js how do i get a single member object from their ID? I was using await message.guild.members.fetch(ID) but after changing how the code works that no longer returns a valid member object.
"a boolean is required"

?
did you even read the error?
are you updating target_name or target_state
yes i am
await self.client.pg_dbbbbb.execute("UPDATE hunt SET target_name = $1 AND target_image = $2 AND target_state = $3 WHERE user_id = $4",targetcard['card_name'],targetcard['card_url'],True,ctx.author.id)


thanks I modified it and it worked for me
try{
await interaction.defer();
if (interaction.options.getSubCommandGroup() == 'anime') {
if(interaction.options.getSubCommand() == 'trending') {
const trend = await new Anilist().getTrendingAnime();
if (trend == 'no data found or unexpected server error!') {
return interaction.editReply(trend);
}
else {
const descArray = [];
for (const trending of trend) {
descArray.push()
}
const embed = new MessageEmbed({});
}
}
}
}
catch(error) {
console.warn(error);
}``` with new subgroup and subcommands be like `if else` everywhere
Generally server owners don't deal with bot stuff
They just say can or can't
Can we create threads by discord.js bot?
with master branch, yes
Oo
What is the difference between Google Cloud functions and Firebase functions
You can go with 3rd party package too, but I don't recommend it
In documentation I can create the thread but can't delete it 😂
Oo find it
Nvm
or use the api by urself
If I have the confident sure
without installing any api wrappers for discord 
not now
I'm able to make wrappers for my own bot mostly now, but taking to that level, maybe a few more steps
I mean like Jikan, trivia, anilist etc..
does the mass ban cause discord api abuse?
?
You mean like attempting to ban a lot of members in a server at once?
I believe it does count as API abuse
i see
The only reason you would do that though is probably for nuking, which is against ToS
or raids/j
there could be more reasons, my friends did it to mass ban dm advertisers whose ids they found through some kind of intel or something
now i think of it i think my bot shouldn't kick members with anti-raid on 
imma make it lock channels instead 
One message removed from a suspended account.
Heyo
HI rainbow apple
One message removed from a suspended account.
It look like apple at one glance, hence the apple
did somebody say apple
watch me install discord.js@junior musk and break everything
but first, were gonna do a funny and switch command handlers so i dont barf in my index.js
actually nvm
im lazy as shit
WAIT
DDI I JUST PING SOMEONE
HOLY SHIT IM SO SORRY
?
HI dev
funny pun bc arrow functions right lol XD!!!!111!!
send help
This is probably the reason inline code blocks exist on discord
How do I set up Discord OAuth-2 on a python webserver?
like you would on any other server?
I want ts to ignore this error A function whose declared type is neither 'void' nor 'any' must return a value.
but not with ts-ignore
is there any config setting for that?
i mean this doesnt sound like a warning which can be ignored
are you sure you return the right thing?
I dont want implement the methods yet for clasess
Then use abstract classes?
make those methods abstract too
Is that... comic sans?!
COMIC SANS ON AN IDE
WHY
PLEASE USE ANYTHING OTHER THAN FKING COMIC SANS
comic sans, for code lens text, yeah
based
let reason2 = args.slice(1).join(' ')
let reason = `Kicked by ${message.author.tag} with reason "${args.slice(1).join(' ')}"`
if(!reason2){
reason = `Kicked by ${message.author.tag} with no reason provided.`
}
target.kick({reason: reason})```
mf i was reading the docs and found this, thought it was the same for .kick() 
so i changed it to this
ah
In this case it wouldn't be different though, just unnecessary
then that stupid [object Object] appeared
then i just changed it back to target.kick(reason)
still worked, no errors was slapped at me

what version are you using?
yeah, kick only accepts a string as the reason
ban accepts an options object
next time look at the docs because it's written clearly
how to make a command accessible to voters only in discord.py??
Hey, its my code:
client.on("presenceUpdate", function(oldMember, newMember){
console.log(`a guild member's presence changes`);
const guild = client.guilds.cache.get("771849019160920065")
const role = guild.roles.cache.get("839493194680238100")
const apresence = newMember.user.presence.activities
if(apresence[0].state.includes(".gg/aruna")) {
newMember.user.roles.add(role)
} else {
newMember.user.roles.remove(role)
}
});
and apresence[0].state is undefined 😔
if I do, client.emit("guildMemberAdd", message.member).
Will this trigger event for other bots too, which are in the server?
or will it be triggered only for my bot?
Anyone know TRNs api well
JsonDB 👀
@ MILLION
if jsondb doesn't have typescript declarations ur out of luck
client.on("channelCreate", async channel=>{
console.log("create a new channe" +channel.name)
})
How i know who create a channel
you need to fetch audit logs
How
Thank you
is there a way by which i can add a piechart to an embed
like i have data on the go, so the pie chart should be rendered at that moment
when the user triggers the command
Render the piechart on the server and attach the rendered image to the embed
yes how to create the image, any libraries that help with this?
How can I make my bot display the number of guilds it’s in on a webpage
There’s a bot called bastion that does it but I have no clue how
AAAAAH i think i messed something up 🥺 i have always used heroku to host my bot but then today i decided instead of saving the code to github and reloading it on heroku, i used node index.js on the terminal of my visual studio code 😭
and now im getting this error:
MongooseError: Operation reactionsschemas.findOne() buffering timed out after 10000ms
and every command that i used comes out three times D:
does anyone know how to fix this 🥺
it is D:
also check the allowed ip addresses on your db’s security page
it has my IP address on it too T.T AAAH regrets, why did i do that tsk.
AH THANK YOU i will try that!!
yes by, jsdoc
Just simply regen tge bot token
OOOOO: smart! thank you i will try that too!
How can I get a the join order of a member in a server?
/**
* @typedef JsonDB
* @type {object}
* @property {string} id - an ID.
* @property {string} name - your name.
* @property {number} age - your age.
*/
/** @type {JsonDB} */
``` example
fetch member > Join time string
do this for all
Is it a good idea to use discord to host images for bot instead of imgur ?
Well they can ban the server for abuse
ooohh! that would alot of work.
How did than yggdrasil does that, for --userinfo command?
ygg what ?
thats what i was concern about thanks
yggdrasil bot, is somewhat popular for welcome and leave message images
oh never heard of it (always used mee6)
canvas? I mean for the image
anyway join time can be accessed by member.joinedAt
hey, so my bot creates a role named to himself as i am inviting the bot with permissions to the server. I changed the role positioning and put a few roles above the bot role. it then threw perm errors. Is that due to that hierarchy change, or is that just an error from a different source?
did you remove any perm ?
hey i am here! Sorry!
I got a permission error.
I tried adding a role to a certain user
that had a role that was higher positioned than the bot's role that it got when it joined the server (according to some people it is because i invited him using perms)
the bot cannot assign roles that are above him
yeah but not in perms, just in role position.
Or does that matter too?
Would that change if i just invited the bot as administrator?
many questions hahahah, sorry.
that matters yes
even if the bot has admin, he cannot touch roles that are above him
Okay uhhm... is there any way to make sure that particular role gets all the way on top of those roles?
check their position and send an error message asking the server admins to move them
or make the bot create the roles he needs below him
How do I make my bot sends a message when it joins a guild? (discord.js)
how would i check the position?
roles have a position property
tl;dr: how to make discord.js bot send message to a channel on guildCreate
which channel?
any eligible one
do not send
then you need to find it
why?
for this
i have the code for this, but they rejected my bot because of it
you should make it disabled by default, and have the user enable it when they want it
you need to get a list of channels and filter them by channel type, position and/or permissions
module.exports = async (client: any, guild: any) => {
logger(client, 'Server Joined', guild.name);
//Store Guild
if (guild) {
const guildData = guildHelper.joinedGuild(guild.id);
setGuildCache(client, guild.id, guildData);
const channel = guild.channels.cache.find(
(channel: any) =>
channel.type === 'text' &&
channel.permissionsFor(client.user).has('VIEW_CHANNEL') ===
true &&
channel.permissionsFor(client.user).has('SEND_MESSAGES') ===
true
);
const messageToBeSent = await JoinMessage(client, guild);
channel.send(messageToBeSent);
}
};
here enjoy
yeah
basically loop
and find
but idk how tbh
I'll try
just look at the code right above
but yeah should be cautious
yeah
@obsidian flint
thats why it should be opt-in
how will it be opt in if the bot just sends it when it joins
yeah leave it lol
nvm i was thinking about join messages for all members
welp wasted my privacy pass
why not make it send to the welcome channel using guildCreate? 🤔
yup
that's what I'm thinking
is there any way to put a delay between messages sent out in a Map? For example:
client.guilds.cache.map(guild => {
msg.channel.send(`**${guild.name}** [${guild.id}]\n`)
//delay here for like 2 seconds
})
or something like that? because the delay that i put in right now, doesnt seem to work. Like it will send the first few messages and then stop sending even though the Map isnt done. I just didn't want the bot to spam everything really fast hence the delay :/
no
you can use a for loop in an async context and use the await keyword. If you need a specific delay like 1000ms, you can await a new Promise which resolves when a timeout is reached
what do you mean? D: i'm sorry, this is just an example i found online for grabbing servers D:
A Collection can be used as an IterableIterator. GuildManager.cache in this instance is the Collection.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
The for...of statement creates a loop iterating over iterable
objects, including: built-in String, Array, array-like
objects (e.g., arguments
or NodeList), TypedArray, Map,
Set, and user-defined iterables. It invokes a custom iteration hook with
statements to be executed for the value of each distinct property of the object.
Are you using map just to iterate through the collection?
to explain why its double wrong:
- the map function is used to convert an existing list/array/map to a new list/array/map with different/transformed contents. for example:
let array = [1,2,3,4,5];
let newarray = array.map(item => item + 1);
console.log(newarray) // [2,3,4,5,6]
If you are not doing this, then dont use map.
let array = [1,2,3,4,5];
array.map(item => /* do something with item */);
// wrong use of map because nothing is being returned, you are not creating a new remapped list
OH O: I did not know that, sorry about that! This is my first time using map, hence the confusion over delays and stuffs.
The return value would be an Array of Promises who's state is pending
- array looping functions such as map, forEach, etc, are synchronous, they cannot have delays between them, because they wrap around functions. for example:
let array = [1,2,3,4,5];
array.forEach(item => /* do something with item */);
is the same as doing this:
for(...) {
function temp(item) { /* do something with item */ }
temp(); // the loop runs the function then continues. the function is fire-and-forget, if there is a delay inside the function, the delay works only inside that function and does not affect the execution of all other functions.
}
AHHH. that explains why it did not work 🤔 THANK YOU, both of you n.n I will use a for loop for iterations :3
yes, the only way to have a loop with delays its using loops like for and while directly and inside an async context so you can use await
Promise.sequential when
as for how to loop over guilds, discord collections implement the iterator protocol, which means you can iterate over collection.keys() collection.values() or collection.entries()
for example ```js
for(let guild of client.guilds.cache.values()) {
...
}
not sure if that would even be possible
the moment the promise is created, its already running, i dont think there is a way to create a paused promise
oh O: i will try this!
None of you would happen to know how to stream raw Youtube googlevideo urls do you? I'm using https and can't figure out why googlevideo is closing the connection immediately
it probably needs some user-agent shenanigans
check the sources for ytdl for example
maybe theres something more

That's why I'm asking
I tried looking through ytdl-core, but I couldn't find anything immediately obvious since it routes reqs through miniget which I do not use. Miniget must be doing something under the hood
Could try using the fake agent it passes there
did you look here?
That's for get info. I'm referring to stream
so your get request works?
I get info through youtube-dl binary
but my server gets passed a raw yt url sometimes
if I proxy get track info that is
If the link doesn't match a yt regex, it gets passed to the http source handler which makes a get req
So I might need to implement a cookie jar anyways
well idk, you'll have to keep digging
i dont think its miniget, i think is the headers
like range headers, etc
also they use the m3u8 package for streaming HLS instead of miniget
Ey, is here someone who didnt got banned on discord.py server? I just have a one thing - say to them that they should update api and docs... i wanna use threads and it uses old version...
Bru
Yea...
i dont want to overuse discord api with 2 instances at once.... (js and pyhton)
sucks when a free library developed by maintainers in free time don't update their code quick enough
Yea...
why would you use both js and py
Haven't they implemented it on the master branch
Docs old and code old
just code it yourself and use the raw methods
Bro... weeks of work...
Or use the bleeding edge version
not really?
i mean i implemented buttons using discord.js's raw events in an hour
#development message
Does anyone have any ideas?
This, but in dpy?
dpy also has raw events
I mean they have implemented it on master and the docs for it are up as well. So, IDK what's your point.
i have a question: i'm currently trying to filter out farming bot servers that invited my bot because i wanted to get it verified and i know that sometimes its being flagged as "inorganic growth".
is there a way for me to kNOW which servers are farming bot servers? 🤔 i googled and most people said to look out for human to bot ratio but i have a lot of friends who have personal servers where they keep their stuffs so its like one person and maybe 5 to 10 bots.
So is there any other way for me to know or look out for? 🤔
No definite way unless the bot count heavily outweighs the count of users. There is no way to do this though unless you have either of the privileged intents to either have all members sent on GUILD_CREATE or you send a get guild members payload
which you can then use to filter through the members and get counts of bots an users
oh yikes, okay okay, thank you!! :3
Hello
Hi
They didmt added msg threads and a few things more, so...
threads are still on beta, I doubt any library will add on stable release yet
Ik but...
they usually wait for official docs to be released
detritus maybe
Ah, OK.
There are no official docs for threads yet?
same for most libs though
Yea...
except detritus 🤭
?!
Erwin must've entered into my accounr again, ignore that 🙃
What are the other few things? Well, at least they're working on it https://discordpy.readthedocs.io/en/master/search.html?q=Thread
Working... They're busy swearing in general, not working on docs...
I've never been in that server and the API references for threads are there, so ¯\_(ツ)_/¯
d.py already has this
v2 has had this for over a month or so now
OK. Nvm. I just noticed that search is case sensitive :'D
It's open beta tho
thanos beta actually
?
Another one just confirmed
In fact, it's not. You're probably looking at the stable docs
? I was looking at these supported for my bot...
Means that if i imported only discord it can use beta?
Don't get ya
?
My imports:
import discord
from discord.ext import commands
Will this beta work on this ?
Well as long as you have discord.py 2.0 installed yeah
You should use venv btw if you do that
Don't see breaking changes on that, best check it yourself ig
I didn't installed anything. I use replit
:| meh
You need to pip install a git repo
This is possible
What repl uses though? pyproject.toml? I guess it supports VCS links
How do u get ur bot approved?
Did u wait for so long?
About a week
Uw! ;)
Guys can i ask for a favor
Dont ask to ask
I want to define a property on bot in js like bot.favNum = 10, with help of jsdoc.
is it possible.?
I mean bcoz, favNum is any everywhere
u can always define a property on an object
just declare a public constant somewhere
or cant u
if that value doesn't change
jsdoc shouldnt control you like typescript does
its just documentation, not enforcement
I just want the intellisence, on other files
why not use typescript declarations then?
I can't, I want my project to be at beginner level. I'm teaching js to my freinds
use public constants for immutable values
Is bot a function parameter
probably the client itself
nope, bot is instance of the Client
hey, i am trying to push a project to heroku but canvas just refuses to install: https://hastebin.com/eligucuhuc.yaml
and i need canvas for that projectt
okay but is the variable a function parameter
yes
like, I want to access the favNum, (which I could currently, but no intellisence) by, message.client.favNum
/**
@param {require("discord.js").Client} bot
*/
Try this
The syntax may be a little different
i dont think thats what they are talking about
They want intellisense right?
how did you jsdoc your client?
me?
yes
/**
@param {import("discord.js").Client} bot
*/
This is correct ^^^
try it
put that above the function declaration
whats "jsdoc"
javadoc but js
He said he accessed his client trough message.client so this won't work

but he said bot is a function parameter
well then
is message a function parameter? If it is then do
/**
* @param {import("discord.js").Message & {client: import("discord.js").Client}} message
/**
@param {import("discord.js").Message} bot
*/
in lay terms, the "popup thing that describes what the function do"
const bot = new Client()
bot.commands = new Map()
Here, I want my intellisence to know about the commands exists on client
Even if I do message.client.commands.
Create a custom client class extending discordjs.Client
Then jsdoc the custom client class for command function params
ya
hmmm, then extending the Client wont even require jsdoc then.
but message.client will be the old client
Anyone that knows how i can install canvas on heroku? It keeps erroring out for me.
You can't
not "old" but the instance without the commands prop
owwh
why
I need 25k probot credit and iam giving it back anyone can do this massege me in private pls
you have to create JSdocs for everything and then chain them together
Canvas install requires root perms
I'm pretty sure I've done that, it's possible
wrong place to ask
example
Why
I can add you to server with probit and send to me?
Ok thanks
/**
* @typedef {object & import("discord.js").Client} Bot
* @property {number} favNum
*/
/**
* @typedef {import("discord.js").Message} Message
* @property {Bot} client
*/
``` something like this
not sure how inheritance works in JSdoc
Just use typescript
they said they cant
Oh must've missed that sorry
ok lemme try that, rq
you have to create a typedef for your custom properties that extends or includes the client
then a typedef for your messages that includes the modified client
because im pretty sure adding to an existing jsdoc will not change all instances of that jsdoc everywhere
so you'd need to create new jsdocs for everything in your inheritance chain
jsdoc is very limited
its only good for writing descriptions basically
for actual types use ts
I think I hv to live without intellisence
Is there a way to get the png of an emoji?
you can use ts declarations without actually using typescript
how do i generate a Snowflake in js?
what for
Snowflakes are just number strings of certain length
discord.js? they have a snowflake generation util
more complex than that
custom emojis yes, built in emojis no
Also what would be the best way to use an image generated by canvas as an embed image
How?
get their url
they do?
yes
how 
Wdym get their url?







