#development
1 messages · Page 1354 of 1
What's the code to put client.users.cache.size in my bot's custom status
@abstract coyote lemme guess... Sharded?
I tried once, it didn't go so well
What's the code to put client.users.cache.size in my bot's custom status
@rotund vale there is no exact code for anything
send yours
we'll help debug it
I see wait
@carmine summit send code mate
Can I populate a field, after exec() is run?
SomeModal
.findOne({blalala})
.exec()
.then(doc => doc.populate('some-ref'));
@carmine summit stop posting the same error without any context or code
@abstract coyote lemme guess... Sharded?
sorry? I am not sure what sharding stands for here :/
sorry? I am not sure what sharding stands for here :/
@abstract coyote he's asking if you're trying to get the users/guilds amount for a sharded bot or not
I don't think doc has a populate method @rocky hearth
@carmine summit send code pls
nah its not sharded
then client.users.cache.size
I am stoopid
replace users with guilds if.. you know what I'll say
Yes, I am sorry! 🙂
then client.users.cache.size
Tried that before :(
@abstract coyote everyone ain't cached
d.js only stores stuff in cache if the thing interacts with the bot in some way
oh okay
uh
well same story if you don't have guild member intents
I didnt even know
@carmine summit since I see you're in the discord bugs server, you should know that we can't really help you with something that is not easily reproducable
@abstract coyote you can use guild.memberCount
to get the total number of members in a specific guild, regardless of caching
yeah
@earnest phoenix btw I found the code for client.users.cache.size in bot status
I have a JSON list of hundreds of games formatted like this:
{
"cod1": "Call of Duty 1",
"cod2": "Call of Duty 2",
}
What would be the best way to paginate those?
I saw a few pagination node packages for Discord.js but all rely on embeds.
There should be a better way than making a new embed every 10th game in a for loop?
If you answer, please ping me as I come and leave frequently.
its like a line that would be ez to make urself if you checked the docs tbh lol
what's the problem in here? (Language: JavaScript)
if(!message.member.hasPermission('BAN_MEMBERS'))
message.channel.send("Missing Permissions!");
else {
let bannedMember = await message.guild.members.ban(args);
if(bannedMember){
try {
console.log(bannedMember.tag + " is banned.");
message.channel.send (`${bannedMember} has been banned!`)
}
catch(err) {
console.log(err);
}
}
}
}
module.exports.config = {
name: "ban",
description: "Bans a Users",
usage: "b!ban",
accessableby: "Admins",
aliases: []
}```
if i do fs.readFileSync("/path/to/some/file/without/extension") will it return the data inside the file as a normal string or smth else?
it does nothing when i write b!ban
@sturdy star please color-code your code, add js after the ```
I have a JSON list of hundreds of games formatted like this:
{
"cod1": "Call of Duty 1",
"cod2": "Call of Duty 2",
}
🙏 Please call a doctor 🙏
```js
my code
```
im just new to coding
@sturdy star then it's not a good idea to start work on a bot right now
@earnest phoenix Regarding the format? I can change it, I guess. What about an array of objects that look like this { code: "cod", name: "Call of Duty" }?
i mean like im only 5 days into coding
@earnest phoenix Regarding the format?
@stoic girder no I'm talking about why the fuck are you storing a huge list of games
ahh, it's from gamedig node.js library
list of supported games
even worse, they store it in a badly(?) formatted txt file
i parsed it and converted into json
I don't think doc has a populate method @rocky hearth
@fluid basin There IS a populate method ondocument
did you check?
yes

why does res.send make my browser download the file instead of parse it as HTML
express.js
why does
res.sendmake my browser download the file instead of parse it as HTML
express.js
@earnest phoenix Wrongcontent-typemaybe?
welp
hmm ok, weird
I fucked everything up and wiped half of my servers my bot is in
Just try plain/text to test @earnest phoenix
stupid verification
I fucked everything up and wiped half of my servers my bot is in
@carmine summit oof what happened?
i was forced to code a thing where the bot will check weekly for activeness
each command run = +1 activeness
Well that's so sad 😦
so what happened is, instead of db.delete('activeness.'+ guild.id), What I accidentally coded is: db.delete('activeness')
which deletes the whole array
and leaves no data behind
res.set("Content-type","plain/text");
res.set("Content-Type","plain/text");
testing if the problem is with the header name
then I stupidly ran the ?purge command without knowing waht is happening
so yeah...
header name should be case insensitive
tf
so it doesn't matter
used axios to send a request to the server and it shows this:
headers: {
content-type: "application/octet-stream"
}
should be "content-type":

axios is nuts
gotta be valid JSON
not json but just a js object in general
lmao
https://discordpy.readthedocs.io/en/latest/api.html#discord.AutoShardedClient.shards someone sent this to find what shard im on
for dpy
but i didnt get it
how would i like find what shard the bot is on?
you're using AutoShardedClient, right?
yes
Hello!
I was wondering: using Discord.js we always have to choose between "resolve" functions that return an object (Guild, Member, User, Message) or the "fetch" functions that return the same thing but async (with a Promise). What's the difference? Does the "resolve" functions use only the cache and are not truth-worthy?
resolve uses the cache. fetch is async since it tries to look in the cache first. if not found, it will try to fetch it from the API
fetch is better to use if you're unsure whether something you're looking for is cached or not
the status code was 304 lemme try reloading the page with clear cache and hard reloard
Resource interpreted as Document but transferred with MIME type application/octet-stream
WHY
thonk
fetch is better to use if you're unsure whether something you're looking for is cached or not
@pale vessel thanks. Some "fetch" functions seam to not be related to cache, they don't have thecacheorforceboolean parameters. ExampleUserManager.fetchvsGuildMemberManager.fetchDo you know why?
both of them have it
it's my CDN acting up bruh
both of them have it
@pale vessel Yes my bad. It's just that these flags are given in theoptionparameter for theGuildMemberManager.fetchfunction
Hi n.n
I have problems displaying messages on embed with no breakline ):
It shows like this
I want that commands appeared just under the category, not after that breakline
and the breakline would have to be below commands description to separate categories
dont add a field for every single command
use a field for a category, then use the field data for the commands
@earnest phoenix I'm back... did plain/text still open a file stream?
what was working for weeks
can you get the number of users in each shard without the server members intent? (discord.js v12)
yis
how
fetchClientValues?
oh i see thanks
can you not access client.users.cache without the intent
same with guilds
hm
if you don't have the intent, you can't request guild members
so it could be empty but still accessible
if you have a bot with say 11k guilds, using a sharding manager is better than internal sharding, right?
yea
i've just restarted my bot for the first time since the new enforcement, and i'm getting the same error as with my other (non verified) bots, which was fixed by just enabling the intents on the application page; but i can't very well do that for the verified one
kurasuta is a good one
i've just restarted my bot for the first time since the new enforcement, and i'm getting the same error as with my other (non verified) bots, which was fixed by just enabling the intents on the application page; but i can't very well do that for the verified one
@dense patio you can, contact https://dis.gd/support
agh
okay yeah maybe i shouldn't still be internal sharding 
what makes kurasuta good?
all good, why didn't you request for it in the first place in the application?
didn't think i'd need it
still don't know what's causing the issue
i didn't think i'd need the intents for anything
@grizzled raven i heard it handles everything better than discord.js's shardingmanager
plus chip uses a modified version of kurasuta iirc
guild member intent is for guild_member_xyz events and other guild member related stuff
oh yeah because like people always say it's better but like i've never actually heard a reason as to why, or stuff that it does better
i don't think discord.js shardingmanager allows clustering, does it?
the only thing i use guild members for is fetching a user from their username i think
if not then kurasuta is definitely better
what does clustering do
HELLOU
what does clustering do
@dense patio shards, but bigger
on web servers, someone know why there is a IIS 404.0 error when trying to open it on the http://localhost/ protocol?
oh okay that's a great reason
will using kurasuta make restarting my bot faster? it takes bloody forever if i want to restart it on the fly
nah

anyone here know tweepy
wdym takes forever?
my bot won't start rn and i'm getting this error
Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
which happened on my other bots; fixed by enabling intents
i need to know how to delete my last message
oh
i have never had issues with djs taking a long time to restart
did you have fetchAllMembers enabled in your client options?
then thats the problem
what a pain
it's trying to fetch all members on each guild, but no members were sent since the bot didn't have the intent
so it'll keep waiting until the timeout
furthermore, djs is dumb and doesnt check if the members intent is enabled before trying to fetch all members
so it just fetches then waits forever until it crashes
smart
will i still be able to fetch a user from their username if i don't have the intent?
Well, lots of programming is like that.
will i still be able to fetch a user from their username if i don't have the intent?
@dense patio yes you can
you can use guild.members.fetch({query:"usernamehere"})
and it will return a list of people with similar usernames in that specific guild
oh you can do that? i wish i knew that before lol
i was making it search the guild users for a user with that username
ye
thanks for your help 👍
does guild.members.fetch({query:"usernamehere"}) return an array?
TIiiiiiim
a promise<collection>
ok thanks
many people
well so, im making the classic localhost
aaaand im getting a iis 10 404 http error
but the file exist
you're making an IIS webserver?
yes
i've never used IIS so idk
okthen
IIS is weird af
thanks
are you on windows?
you want to work with php or what?
hmmm no php
there are many webservers out there you can use instead of IIS
so, like this?
var moment
Can you elaborate on the etc.
just say a = "a"
Ah ok..
there is a nice module called express-ws I've used that integrates nicely with express
i can't send embeds with my bot, i am using the command handler listed in https://discordjs.guide
does the bot respond if you send non-embeds
i use this
yes, it responds
does the bot have embed permissions
yes
ok now that the dumb questions are out of the way send the code that responds with an embed
is there anyone else who can't login with their bot right now? I'm using JDA and it doesn't go further than 'connected to websocket'
const { MessageEmbed, Channel } = require('discord.js')
module.exports = {
commands: ['help', 'cmds', 'commands'],
description: 'Displays help menu',
usage: null,
minArgs: null,
maxArgs: 1,
permissions: [],
requiredRoles: [],
callback: (message, args) => {
const { guild } = message
const icon = guild.iconURL()
if (!args[0]) {
const categories = new MessageEmbed()
.setTitle('Command Help')
.setDescription('Here are the different command categories!')
.setThumbnail(icon)
.setColor('#aec6cf')
.setFooter('More commands coming soon!')
.addFields(
{ name: 'COMMAND', value: '`COMMAND`', inline: true },
)
Channel.send(message)
}
}
}
code is like this
@lunar knot check if there was any update or new information regarding intents in JDA
since discord pushed new changes
to channel.send(categories)
there's one other issue here
you are calling send on a prototype of Channel, you need to call it on message.channel
also youre sending the var "message"
when the embed var is categories
so message.channel.send(categories)
it'll respond to normal commands but wont repond to embeds command
let embed = MessageEmbed()
.description("pong");
message.channel.send(embed)
Here is the issue:
Channel.send(message) - this will take an uninitialized Channel object and try to send a Message class to it. Not only will the message go nowhere you also can't send a Message class. Further, you don't use categories at all.
You need message.channel.send(categories) instead - this will send a message to the channel the message came from containing the categories embed.
@earnest phoenix I'm back... did
plain/textstill open a file stream?
@boreal iron res.set is doing nothing to change the content type header and/or res.send is changing it to a text/octet-stream for some reason
@earnest phoenix the correct mimetype is text/plain
is there anyone else who can't login with their bot right now? I'm using JDA and it doesn't go further than 'connected to websocket'
@lunar knot I have the same problem
Enabling Gateway Intents fixed it for me, created a ticket for my verified bot tho
ah
it seems that my bot sometime last night stopped receiving guild join/leave events so I think something changed
Is anyone else having an issue with their bot not passing the "on_ready" event
My bot has been working fine
but today deiceded that it doesent want to start
yes, try enabling privileged intents
For other people who are having issues with their bot -> https://dis.gd/gwupdate
@earnest phoenix And axios using headers will return a stream, too?
If so take a look at the request config param transformResponse
client.shard.broadcastEval("const name = message.args[0].toLowerCase(); delete require.cache[require.resolve(`./${name}/js`)]; ..")
-> message is not defined
Anyone has a solution to my query?
I want to reload commands on every shard.
/js
the problem is, is that it says that name is undefined
and when I have the code out of the broadcastEval, it says the same
@earnest phoenix And
axiosusing headers will return a stream, too?
@boreal iron my guess is because he usedplain/textinstead oftext/plainsomething in the chain converted it to an octet stream
code let propose = new discord.MessageEmbed() await propose.react("✔️");
error propose.react is not a function
#react() only works on messages
#react() only works on messages
@earnest phoenix then how can we do it on embed
the same way '
const my_message = await channel.send({ embed: my_embed });
my_message.react(emoji);
embed: propose?
what do you think
ok got it
no problem
ty
@boreal iron my guess is because he used
plain/textinstead oftext/plainsomething in the chain converted it to an octet stream
@floral rune i noticed that error and changed it to text/plain
And the result still is a stream?
Yes
I'm pretty sure it's my CDN
Adding a console.log inside the app.get callback does not run
Did u try axios as mentioned?
at how many servers/shards do you recommend to start clustering
after 1k try switching to a sharding system if you feel like your bot could use a tiny bit of performance, it's mandatory after 2500
i mean clustering
does your vps have multiple cpu cores? do 1 process per cpu core
does yout vps have only 1 cpu core? use internal sharding
is it like multiple shards for each core
1 process per core, multiple shards per process
got it
and uh since it's one process with multiple shards, would those processes still need to use those async methods to interact with the shards or is it kinda like internal sharding
processes cannot talk to each other without a communication channel
stuff like djs's shardingManager creates a communication channel between the manager and the processes
i meant, say if you have one process with 3 shards, will those 3 shards sorta be like internal sharding, where it's one process with the guilds of 3 shards or whatever
yes
okay thanks
What should I do for the bot to automatically delete the message it sends after some time?
is this the right way around? https://cdn.yxridev.com/u/gtECzR42.png
Alright so I'm tryna make a "Trivia" command and I'm probably doing it wrong, but I basically have an array of wrong answers and 1 right answer, I want to add the right answer and then 2 random unique other "wrong answers" this is my code, it works but for some reason after I do it multiple times it only shows the right answer.
let allAnswers = questions[keys[0]].wrongAnswers;
let toAnswer = [];
toAnswer.push(questions[keys[0]].rightAnswer)
let randomPick = Math.floor((Math.random() * allAnswers.length - 1) + 1);
toAnswer.push(allAnswers[randomPick])
allAnswers.splice(randomPick, 1)
toAnswer.push(allAnswers[Math.floor((Math.random() * allAnswers.length - 1) + 1)])
(It's ChickenDev btw I changed my name and pfp)
@tulip ledge hi vigintillion this is planck length
message.reply('Your command response here')
.then(msg => {
msg.delete({ timeout: 10000 })
})
.catch(/*Error handling if the Message isn't returned etc*/);```
@jagged spruce 👆
@tulip ledge Can you show an example of what you're trying to do? I kinda didn't get what you meant
Hmm?
const filter = (reaction, user) => {
console.log(1)
console.log(reaction.emoji.name)
return ['🇦', '🇧', '🇨'].includes(reaction.emoji.name) && user.id === message.author.id;
};
const collector = message.createReactionCollector(filter, { time: 15000 });
collector.on('collect', (reaction, user) => {
let picked = 0;
if(reaction.emoji.name === '🇧') picked = 1;
if(reaction.emoji.name === '🇨') picked = 2;
message.channel.send(askedAnswers(picked))
});
nothing is logging, nothing is happening on collect
Are you creating the reaction collector on the correct message?
Oof
haha
nekos.life API endpoints are not allowed here either, it shows up loli (minor) nsfw content
Reddit API can be used however
Some APIs can't be trusted nowadays
When did we say that
@jagged spruce 👆
@rose warren thank you
opinions? https://cdn.yxridev.com/u/iqO06B7a.png
const bot = new Client();
const dbl = new DBL(token.toptoken, bot);
bot.on('ready', () => {
console.log('Cookies are ready!');
setInterval(() => {
dbl.postStats(bot.guilds.cache.size);
})
})``` and this gives me an error
(node:132260) UnhandledPromiseRejectionWarning: Error: 429 Too Many Requests
at IncomingMessage.<anonymous> (C:\Users\Andy\Desktop\Cookie bot test 1\node_modules\dblapi.js\src\index.js:118:25)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1221:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:132260) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 40)
but language = portuguese
opinions? https://cdn.yxridev.com/u/iqO06B7a.png
@obtuse jolt looks pretty good if that's what you're asking
can anyone help me with fixing this it spams that error over and over
@hollow sedge yes it was, ty
@upper elm Dude, u need to actually defined an interval
@upper elm well, the problem is in the error it's pretty self explanatory
oh my god
For example 12h
bruh I'm dumb
you need to set time in between each request
I do it every 5 minutes but you can choose any time that isnt like every 3 seconds
I set it to half an hour
setInterval(function() { dbl.postStats(bot.guilds.cache.size); }, 60 * 60 * 1000);
would be each hour
cool it works now but I still get the error
You don't even have to set an interval, dblapi.js posts server count on it's own
Hello
I am beggining in .js
oh so I can just do dbl.postStats outside of an interval?
And I don't understand why this not worked
`const {
GiveawaysManager
} = require("discord-giveaways");
const manager = new GiveawaysManager(client, {
storage: "./giveaways.json",
updateCountdownEvery: 1,
default: {
botsCanWin: false,
exemptPermissions: ["MANAGE_MESSAGES", "ADMINISTRATOR"],
embedColor: "#FF0000",
reaction: "🎉"
}
});
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("I'm ready !");
});
client.login(settings.token);
client.on("message", (message) => {
const ms = require("ms");
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command === "gcreate") {
client.giveawaysManager.start(message.channel, {
time: ms(args[0]),
prize: args.slice(2).join(" "),
winnerCount: parseInt(args[1])
}).then((gData) => {
console.log(gData);
});
}
});`
cool it works now but I still get the error
@upper elm Yes, because you're being rate limited the next hour.
No just don't put anything
@upper elm Take a look in here: https://top.gg/api/docs#ratelimits
thanks
dbl.on("posted", () => console.log("Server count posted!"));``` just put this in
^^
You'll see it's posting it, without interval
oooh I think I got it
so I'm sort of being stopped from send the request to poststats because I already did it like a shit ton?
is there a way to create a client defined variable in a start.js file?
Yes
ok
You're blocked for one hour
thanks for ur help
np
is there a way to create a client defined variable in a start.js file?
@obtuse jolt You can create the client and export it through other files
https://hastebin.com/ixaragemur.js Anyone knows why this is saying That's the wrong answer even tho I do the right answer and why it does this weird thing
Show code maybe
Theres a hastebin link 😛
Oh wait you did
lmao
Is line 47 just an issue pasting into hatebin? @tulip ledge
return [':regional_indicator_a:', '��', ':regional_indicator_c:'].includes(reaction.emoji.name) && user.id === message.author.id;
@tulip ledge Aye bot got approved after a few weeks.
Nice one 😄
hello guys ! i added my server to top gg but it doesnt show up in my profile ! what's the issue ?
It's ChickenDev btw
Aye remembered ur profile status Social Incapable
You should try to log both of the askedAnswers[picked] and questions[keys[i]].rightAnswer
what are the main things that canvas takes the longest to load
See what it returns
what are the main things that canvas takes the longest to load
@tired nimbus Images but that depends
Master Necromancer -> Picked
Master Necromancer -> Right
Elementalist -> Picked (but not actually picked)
Stalker -> Right
Stalker -> Picked
Stalker -> Right
Wither Lord
New Necromancer
New Necromancer
New Necromancer
Im just really curious how people use canvas for general things such as rank cards that are created quickly
They're either done in other processes or use few properties on creation
Lets say the first question had
A: Elementalist
B: New Necromancer
You pick B, but on the next question you pick A it shows A Elementalist as ur first pick and then ur actualy pick
I'm so confused
Does the first question works all the time?
Lets say the first question had
A: Elementalist
B: New NecromancerYou pick B, but on the next question you pick A it shows A Elementalist as ur first pick and then ur actualy pick
@tulip ledge Hmm, might be a wrong order push, lemme do an experiment on this, eval mode activate
But before anything, i need to see how your questions are stored
No I mean answering the first question works all the time?
if (message.includes ("give me nekos")) {
^
TypeError: message.includes is not a function
at Client.<anonymous> (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\bot.js:42:13)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
how do i fix this
message is an object
message.content.includes()
ohh updated
Videos are terrible sources
the video predefined message
It has never been message.includes , not in the history of discord.js since version 6 at least.
if the video is older than a year it is false
There was a major api change yesterday
Any video older than 24 hours contains false info
You should try to log both of the
askedAnswers[picked]andquestions[keys[i]].rightAnswer
@tulip ledge Did u do that already?
I dont really see any issue so far, just guessing ur shuffled array keys are not accurate
Please log console.log(askedAnswers); console.log(reaction.emoji.name); console.log(askedAnswers[picked]); console.log(questions[keys[i]].rightAnswer); right after line 57, before if(askedAnswers[picked] === questions[keys[i]].rightAnswer)
and post the results
[]
[ 'Stalker', 'Elementalist', 'Professor' ]
�
Stalker
Stalker
[]
[ 'Stalker', 'Elementalist', 'Professor' ]
�
Professor
Professor
[]
[ 'Wither Lord', 'Stalker', 'Professor' ]
�
Professor
Professor
[]
[ 'Stalker', 'Elementalist', 'Professor' ]
�
Elementalist
Apprentice Necromancer
[ 'Wither Lord', 'Stalker', 'Professor' ]
�
Stalker
Apprentice Necromancer
[
'Master Necromancer',
'Shaman Necromancer',
'Apprentice Necromancer'
]
�
Shaman Necromancer
Apprentice Necromancer
[ 'Wither Lord', 'Apprentice Necromancer', 'Shaman Necromancer' ]
�
Apprentice Necromancer
Apprentice Necromancer
The weird part is that there's only 3 questions it asked yet it logged like 5 or 6 times
Ignor the [] they're something different
The console logs are in the same order as I posted?
yES
Ok, so I read, 1st question u selected the right answer but still the error?
its so weird
1st was right
Then I had the 2nd one right but it logged twice?
And then I had the 3rd one right too but it did all the possible answers?
i'm confused
askedAnswers is the first array, means ur 2nd question has the same 3 answers as the first one
oh I see, your answers are placeholders yet and are similar anyway
do this instead ```js
console.log({
askedAnswers,
emoteName: reaction.emoji.name,
picked: askedAnswers.picked,
answer: questions[keys[i]].rightAnswer
});
How can I make [0] be random between 0 and 3?
not needed, the emojy is correct
I4; confused
How can I make [0] be random between 0 and 3?
@granite trout is this js
ye
Please add the question to the log I guess I know what's going wrong
Math.random() will give you a number between 0 and 1
${json.list[Math.random()].definition} ```?
console.log(questions[keys[i]].rightAnswer);
console.log(askedAnswers);
console.log(askedAnswers[picked]);```
@tulip ledge
@tulip ledge
@granite trout it gives a random decimal number between 0 and 1
you're using a recursive function which creates reaction collectors
each answer creates more and more collectors running at the same time
so do something like Math.floor(Math.random()*4) for a number between 0 and 3
@floral rune i dont think it it works where it is
[]
What is the **status** of **Bonzo**?
New Necromancer
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
New Necromancer
[]
What is the **status** of **Livid**?
Master Necromancer
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
Professor
What is the **status** of **Livid**?
Master Necromancer
[ 'Young Wither', 'Professor', 'Master Necromancer' ]
Master Necromancer
[]
What is the **status** of **Livid**?
Master Necromancer
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
Master Necromancer
[]
What is the **status** of **The Professor**?
Professor
[ 'Young Wither', 'Professor', 'Master Necromancer' ]
Young Wither
What is the **status** of **The Professor**?
Professor
[ 'Professor', 'Elementalist', 'Wither Soldier' ]
Professor
What is the **status** of **The Professor**?
Professor
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
Master Necromancer
What is the **status** of **The Professor**?
Professor
[ 'Young Wither', 'Professor', 'Master Necromancer' ]
Young Wither
What is the **status** of **The Professor**?
Professor
[ 'Professor', 'Elementalist', 'Wither Soldier' ]
Professor
What is the **status** of **The Professor**?
Professor
[ 'Professor', 'Stalker', 'Shaman Necromancer' ]
Professor
Aye Tim is right
U see?
each answer creates more and more collectors running at the same time
Same question over and over again
youre still creating multiple event listeners
D.
oh ok
@quartz kindle you know it xD, you are here the sharding expert
show the current shard in client.user.setActivity @quartz kindle
ah
for set activity is the other way around
you chose which shard you want the activity to be for
how then?
client.user.setActivity(`%command & %help | Shard ${client.shard.id}` );
it does not give the Shard @quartz kindle
so I can not no in differnt guilds, which shard they are , becuase of the differnt status?
client.user.setActivity("this activity will be on shard 0 only", { type: "WATCHING", shardID:0 })
client.user.setActivity("this activity will be on shard 1 and 2", { type: "WATCHING", shardID:[1,2] })
ah , so I have to define it for every shard?
I have the auto manager
yes
okay thats to much work for me xD, because the Activity is everytime same
if you're using the sharding manager, you can do shardID: client.shard.ids[0]
ah okay
https://hastebin.com/nidabawufu.yaml
how do I access emoji here? I did reaction._emoji but didnt work
okay thx a lot
What is the best way to set up a premium version of a bot
._emoji is the raw data for the emoji
you should be able to use .emoji which is a getter and returns the formatted data as an Emoji class
TypeError: Cannot read property 'name' of undefined
reaction._emoji.name
console.log(reaction._emoji)
undefined
ffs hastebin text is tiny as fuck on mobile
doesn't reaction.emoji.name show the name of the emoji
no not on awaitReactions
@tulip ledge show code
@tulip ledge console.log reaction.emoji
randomly happens while streaming music or downloading it using ytdl
oh nvm
@tulip ledge reaction is a collection of reactions
since its awaitReactions
undefined
so you have to reaction.first().emoji
The HyperText Transfer Protocol (HTTP) 416 Range Not Satisfiable error response code indicates that a server cannot serve the requested ranges. The most likely reason is that the document doesn't contain such ranges, or that the Range header value, though syntactically correct, doesn't make sense.
I'll look into it
await reaction.users.remove(message.author.id) how do I remove the reaction now
I see, maybe I had the highWaterMark set too high
@tulip ledge same thing
your reaction is a collection of reactions
not 1 reaction
Now its working
Hey,
so i want to remove some roles in a function, that you define by def func(): some code
it says you can't have await in a non async function
how to fix this?
async def func()
kk
@hollow sedge if the ytdl crashes whilst setting highWaterMark too high, then how do I prevent the audio from being laggy and choppy otherwise?
Idk, I just looked up your problem lol
oh I see
@ancient nova you should look it up yourself though, more than likely someone had the same problem
SyntaxError: 'await' outside async function
``` how to fix this?
I've tried, google didn't help much
await needs to be in async functions
SyntaxError: 'await' outside async function
``` how to fix this?
@modest smelt don't use await outside of async 😆
the only thing that I've done that worked
I've set highWaterMark to 550
but it created those weird 216 errors
- randomly
216 errors, just a few
@hollow sedge @solemn latch the function is defined as:
async def function():
#some code
it is part of an async func
where are the brackets
where are the brackets
@ancient nova it's PYTHON
lawl
Lol it's supposed to be more readable
@earnest phoenix where is the await
well it's just my opinion, but yeah it wants to be more visible, instead it hurts my eyes
it is part of #some code
Can you just put the actual code there
kk
async def job():
guild= client.get_guild(764893841068261447)
for role in guild.roles:
if role.id ==765213445997068319:
for member in guild.members:
if role in member.roles:
await member.remove_role(role)
nothing = {}
with open('correctpotd.json', 'r') as f:
json.dump(nothing, f)
with open('incorrectpotd.json', 'r') as f:
json.dump(nothing, f)
with open('progress.json', 'r') as f:
json.dump(nothing, f)
with open('potd.json', 'r') as f:
data= json.load(f)
today = date.today()
todays= data[str(today)]
problem = todays["problem"]
yesterday= str(today-timedelta(days = 1))
yesterdays= data[yesterday]
source= yesterdays["source"]
answer = yesterdays["answer"]
points = yesterdays["points"]
channel = client.get_channel(764903892081180682)
await channel.send(f"Source: ||{source}||")
await channel.send(f"Answer: ||{answer}||")
await channel.send(f"Points Received: ||{points}||")
await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")```
if anyone has fix to ytdl core audio being laggy, please dm me
kk
@earnest phoenix it'd check the spacing on all of them and see if you might have accidently put one outside
Otherwise 🤷
hm ok
what was I smoking when I made this https://cdn.yxridev.com/u/tCufdDbv.png
I'm doing <Message>.edit how can I remove the Loading...
edit the content
You could just edit to be something else like "Congrats you won" etc
Just
<message>.edit("", {
embed: // your embed here
});``` @tulip ledge
@obtuse jolt what db you using
MySQL
YESSIR
does anybody know any websites that set off vt detection?
wow someone finna went and scanned my website on virustotal https://cdn.yxridev.com/u/IASnlUGL.png
<Message>.reactions.remove() is not a function
That removes all reactions mate
yeah could want to do that
<Message>.reactions.cache.remove()
^wat
<message>.reactions.cache.get("emoji you want to remove here").remove()
@quartz kindle Do you know what would cause this, upon reaction, the unicode emojis appear as unknown, as you see the iteration on that array turns them into the emojis
This is kinda really confusing
state property is nullable
discord.gg links in it
state && state.includes(<whatever here>)
@earnest phoenix remove the link from it
That's already the fix
do you have presence updates enabled in settings?
state && state.includes(<whatever here>)
@earnest phoenix pretty sure .react() doesnt accept emojis :like_this:
in the developer portal theres a setting called presence updates
u spelled status wrong
@earnest phoenix pretty sure .react() doesnt accept emojis :like_this:
@quartz kindle It does accept this 🇦 but when putting it's actual unicode, it doesn't
@earnest phoenix Yes
@dusky garden help me find virus links
oh where
i need them for testing purposes
ah ok
but I cant find any that aren't already cached
just make one then lmao
I need uncached links that set off virustotal
how do u make a "virus link checker"?
VirusTotal api
I think he means how does it check for "virus"
@earnest phoenix it works with the unicode for me, but it doesnt work with the emoji string
Now that's suspicious
That worked for me too
it might be a feature in one of the libraries ur using
imagine a bot that checks your status for an ad then kicks you from every guild with anti ad on


LOL

Anyway to parse it to that emoji like 🇦 before passing it as a parameter to react() ? @quartz kindle
nope
100 guild ban speedrun 2020
you have to map them to unicodes yourself
lol
Welp, @tulip ledge we failed on that
@earnest phoenix it'd check the spacing on all of them and see if you might have accidently put one outside
@hollow sedge i just checked there is no spacing error
@earnest phoenix That's what it's supposed to log
Wait really? What was wrong
@earnest phoenix u spelled status wrong in the code u sent us
It was making multiple collectors since it was a recursive function
Not you, was talking to vigi
in state.includes
async def job():
guild= client.get_guild(764893841068261447)
for role in guild.roles:
if role.id ==765213445997068319:
for member in guild.members:
if role in member.roles:
await member.remove_role(role)
nothing = {}
with open('correctpotd.json', 'r') as f:
json.dump(nothing, f)
with open('incorrectpotd.json', 'r') as f:
json.dump(nothing, f)
with open('progress.json', 'r') as f:
json.dump(nothing, f)
with open('potd.json', 'r') as f:
data= json.load(f)
today = date.today()
todays= data[str(today)]
problem = todays["problem"]
yesterday= str(today-timedelta(days = 1))
yesterdays= data[yesterday]
source= yesterdays["source"]
answer = yesterdays["answer"]
points = yesterdays["points"]
channel = client.get_channel(764903892081180682)
await channel.send(f"Source: ||{source}||")
await channel.send(f"Answer: ||{answer}||")
await channel.send(f"Points Received: ||{points}||")
await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")
ERROR: SyntaxError: 'await' outside async function
@tulip ledge 
@dusky garden is ur bot offline?
damn
what's ur new one gonna do?
i migrated from js to python
smh
python is so much fucking easier
SMH
with what
async def job():
guild= client.get_guild(764893841068261447)
for role in guild.roles:
if role.id ==765213445997068319:
for member in guild.members:
if role in member.roles:
await member.remove_role(role)
nothing = {}
with open('correctpotd.json', 'r') as f:
json.dump(nothing, f)
with open('incorrectpotd.json', 'r') as f:
json.dump(nothing, f)
with open('progress.json', 'r') as f:
json.dump(nothing, f)
with open('potd.json', 'r') as f:
data= json.load(f)
today = date.today()
todays= data[str(today)]
problem = todays["problem"]
yesterday= str(today-timedelta(days = 1))
yesterdays= data[yesterday]
source= yesterdays["source"]
answer = yesterdays["answer"]
points = yesterdays["points"]
channel = client.get_channel(764903892081180682)
await channel.send(f"Source: ||{source}||")
await channel.send(f"Answer: ||{answer}||")
await channel.send(f"Points Received: ||{points}||")
await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")
ERROR: SyntaxError: 'await' outside async function
ur await has to be in a async def
it is
no its not
async def job
smh
@earnest phoenix Instead of all that you could have just done this
if (newpresence.activities.find(a => a.type === "CUSTOM\_STATUS") && newpresence.activities.find(a => a.type === "CUSTOM\_STATUS").state && newpresence.activities.find(a => a.type === "CUSTOM\_STATUS").state.includes("Some server link")) newpresence.member.roles.add("630855613093642240");```
that is so complicated
nah i dont
i dont know whats wrong
it should work
python right?
@earnest phoenix its in python correct?
yeah
ok
OH
await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")
that line is wrong
no
i got that wrong
@swift umbra should already be I think
can u send me a screenshot of ur line in vsc @earnest phoenix
im stupid then
thought u had a indent problem on the last part of the string
no sry
@swift umbra Docs are mostly not up to date. Since discord took 6 months for the intents to get in place v6 won’t live long anymore I guess
also i have a question
yeah
in python, the discord.User object detects what
im not sure
what is that supposed to mean
python
detects?
^
@dusky garden https://discordpy.readthedocs.io/en/latest/api.html#discord.User take a look at the docs
i took a look already
well take a second look
ah lemme try converting it to str
@earnest phoenix can you at least share the py file..otherwise no one can help you
who else uses heroku to host their bots cause they dont wanna pay
i dont think heroku would "just break"
You shouldn't use heroku as a bot host, it's meant for hosting websites not hosting bots
oh i see what you're saying
i hate 2 space tabs
How i can get create in a category ?
same
im js
"js" is a language. What library are you using?
@hollow sedge @dusky garden do you see a problem anywhere?
no
😦
wdym
yeah thats what i said @dusky garden
sry
in repl you can go into settings and change it to 4 space
yeah lol its simple
you know what is worse than 2 space tabs? 8 space tabs that notepad likes to do
wheres the @bot.command()
you know what is worse than 2 space tabs? 8 space tabs that notepad likes to do
@placid iron oh no
ah ok
@earnest phoenix any idea how i can create a channel in a categroy ?
<client>.on("presenceUpdate", (oldPresence, newPresence) => !oldPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) && newPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) ? newPresence.member.roles.add("Role ID" : oldPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) && !newPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) ? newPresence.member.roles.remove("Role ID") : null);``` @earnest phoenix
Spoonfeed moment
try moving schedule.every().day..... under the bot.event

can someone help me
like im trying to make a unban command but i cant get the bot unban the id said
@earnest phoenix any idea how i can create a channel in a categroy ?
@willow miragejs <Guild>.channels.create(<Channel name>, { parent: <Category channel ID> });
its saying "id" is not a member
not sure where to go with this, but, I've set up an official Discord announcement channel in my server, but nothing was popping up there since the time I set it up
can anyone help me?
code?
no, the discord announcement channel like #discord-news
I know that
what do u want to pop up there
try moving
schedule.every().day.....under the bot.event
@dusky garden thats not the problem and if i move it, then the thing done in bot.event wont be defined
the official discord server announcements
ah ok bob
lol
so
anything else to fix?
@earnest phoenix well..did it work?
@willow mirage
js <Guild>.channels.create(<Channel name>, { parent: <Category channel ID> });
@earnest phoenix uh no u have to dochannel.setParent("parentID"), just googled
try refollowing it
@earnest phoenix well..did it work?
@hollow sedge no 😦
no, the official discord announcement server, it gets i's own notifications'
@willow mirage No
like you don't have to follow anything
yes
You can set the parent channel on creation of the channel
can someone help me
i tried making a unban command in python and the bot does not recongize the id that the person sent, and its saying that "id" is not a member
And you forgot a )
@earnest phoenix then how i can set the type
ive been using the discord.User object
@willow mirage Channel type?
oops
lmao
regen it right now
@earnest phoenix newPresence.member.roles.add("Role ID" <= here
n014tok3nn014tok3nn014tok3nn014tok3nn014tok3n.n014tok3nn014tok3n
cause i deleted 10 chars
i can't find it smh
@floral rune fake
n 0 1 4 t o k 3 n
n o t a t o k e n
wahhh i need help
@earnest phoenix use
discord.ext.commands.tasksinstead of schedule
@hollow sedge but it worked
what?
WAIT I AM NOT SAYING IT WORKED
so basically
instead of all the await stuff
i just put
def func():
print('bruh')
@earnest phoenix ```js
bot.on('presenceUpdate', (_,newPresence)=>{
if (newPresence.activities.find(({type,state})=>type==='CUSTOM_STATUS'&&state&&state.includes('server link'))) {
newPresence.member.roles.add('role id')
} else {
newPresence.member.roles.remove('role id')
}
})
yes but that func isnt even async
ik
so how is that the same
but it worked
but it doesnt mean anything
srsly, just use tasks
srsly, just use tasks
@hollow sedge ok
different approach
nvm
That won't check if they had the custom status containing the link then removed on the newPresence nununoisy
it will only check if the newPresence has it or not
although i am being slightly lazy by calling add/remove regardless of whether or not they have the role or not
my bot stopped working for good
@earnest phoenix discord api changed, update libraries and make sure you don't need privileged intents
ok sir
it's not that, you need to make sure you aren't using any privileged intents
do you have join/leave/boost messages or are you keeping track of presences
all
you need to turn on privileged intents on the Developer page
@earnest phoenix were you able to get it working with tasks?
i was able to get it working on my side
you need to turn on privileged intents on the Developer page
@floral rune ok!
this?
Are already active
also update discord js
@earnest phoenix were you able to get it working with
tasks?
i was able to get it working on my side
@hollow sedge can you send the code?
can anybody tell me of a bot-hosting site that is not too expensive? picked up discordjs as more of a side project so in case I drop it I don’t want to have wasted a bunch of money on hosting
@earnest phoenix
no, but i can help you figure out how to do it
you have to use the @tasks.loop(hours=<hours>) decorator
hmm
@earnest phoenix what are you trying to do
calculate the time until that time and asyncio.sleep until that
@earnest phoenix what are you trying to do
@floral rune they're trying to run an async function every day at a specific time
if you need the delay to persist across restarts you will need to store the 'next run time' somewhere
then you can check if the time is past that time
calculate the time until that time and
asyncio.sleepuntil that
@hollow sedge great idea!
but wouldnt we need to use functions again bringing us back to that function error @hollow sedge
🤷 the only thing we can do is try
kk
@floral rune i did it all
but now how would it be to activate?
i can put this?
if you updated discord.js and everything it should just work
const client = new Discord.Client({ ws: { intents: Discord.Intents.ALL }})
you shouldn't need that
I give up
@earnest phoenix open a ticket with support I'm not sure at this point
how would you calculate the number of seconds from now till the specified time @hollow sedge
The error is Supplied roles is not an Role, Snowflake, etc.
so for some reason it doesn't recognize the role ID
does the role still exist
@earnest phoenix
- get current time
- get later time:
datetime.datetime(now.year, now.month, now.day, hour=10, minutes=10) wait_for_seconds = (current_time-later_time).total_seconds()- and then sleep for wait_for_seconds
- after sleep start task with
<name_of_function>.start()(assuming you are using discord.pytasks)
i edited it
thx
this is assuming you want it to start at 10:10
@earnest phoenix open a ticket with support I'm not sure at this point
@floral rune okok
thx!
👍np
hmm interesting
is now a variable @hollow sedge
@earnest phoenix now is datetime.datetime.now




