#development
1 messages Β· Page 1718 of 1
thought it will be useful for ya
Two, you are wrong as I need an int to be supported
if isinstance(user, discord.User):
pass
elif isinstance(user, int):
user = self.bot.get_user(user_id)
if not user:
return await ctx.send(f"User with ID {user} was not found.")
As you can probably see
Or maybe not, I don't remember why I did it that way
that's what i'm saying
KEKW
why get_user()
when this thing user: User will fet it for ya
2019 me was high on something
I don't even write Discord bots actively anymore lmfao
oke
I'm allowing users to clean dms sent by bot. This is still approved right?
Hey, gonna ask again again but anyone here has some good resources to split my bot into multiple threads with discord.py?
not really, you're spamming message deletions by deleting them one by one - I don't see why you would clean up your DMs with a bot btw π€
well... after a message get deleted it waits 1s to continue
if u get to know share with me, ok?
i want users to test my bot
after they are done they can use that command
why not bulk delete instead of deleting one by one
it's a dm channel
tbh i don't see any point in that
oh
let them be in DMs
it's not like they are willing to create an acc just for testing
Still looks like unnecessary usage of resource for your bot, especially if an user has 1k+ messages with your bot - DMs are a private place, there's no need to delete messages after
it isn't in server or anything
Your users will also need to delete their owns messages in DMs, I don't see what's the purpose of doing that
@JomaTech
well...
i dunno how to create Mute command
as someone who doesn't want bots to message me...
i thought it would be a help...
but i see
i guess it's just me
it's as simple as giving role but...
π€¨
It doesn't prevents bots to message you..?
I don't see how deleting messages after will "fix" the problem
he simply want a clear DM
nothing much
If x or y user doesn't wants to interact with your bot, it's their problem
yea that haha
Can anyone tell me how I can fix the API Spam, I Got 429 hit on route /gateway/bot
Don't spam the API :)
Stop logging in constantly
How?
What the actual hell are you even doing to get a 429 on that endpoint
Don't do it
setInterval(client.run(), 1000) 
?
you're constantly logging in and out
isn't the limit 1000
Means turn off the bot and on it right?
no that's IDENTIFY limit
yes
Ooo
yes
well...
How
stop testing on your prod bot and instead create another app and use that app's token to test
Your token will likely get reset by Discord soon for attempting to connect indefinitely btw
Me?
yes
:/
it will get fixed soon wait for sometime
Yeah ik
it's kinda like cooldown
5 Hours :/
it's like 1 day right?
@slender thistle hi qt, do you have any idea about this?
ohh
you're thinking of IDENTIFY
IDENTIFY ratelimit won't allow you to connect to the gateway
Threading, oh boy
ahhh
lemme know when u get to know
Me when no reload command
their fault for testing in prod
Why are you trying to thread your bot?
Hoollllyy
what are shrads?
Processes 
you didn't actually hit that limit
or shard
O
you just got ratelimited on the endpoint
You can specify the shards eacj process uses when connecting to discord
if you want to see how much more you have to wait, manually make a request to discord and see the ratelimit headers
Like, I have 40 shards and everything is running on the same core, the bot can't keep up
So you give each process the total shard Count and an array of shards that the process is responsible for
asyncio-subprocess?
AutoShardedBot someone explain this to me
Consider looking at what we did for spoodefy https://www.github.com/SpooderfyBot/SpoodefyBot/tree/main/
........?
I can feel the pain when I see this code
It is recommended to use this client only if you have surpassed at least 1000 guilds.
I guess it's time for me to create clusters
Spooderfy's setup was a little overkill but it was designed to be pretty clean
You shoukd be able to just take that scaler module
I need to verify my bot if my bot reach 100+ Servers or 70+ ?
Make a run function for the bot
Then a starter file
And it should just work with n amount of workers and n amount of shards
Would this allow the bot to use multiple cores instead of being stuck on only one?
It'll devide the amount of shards you give it across n workers evenly, distributing the load
sounds pog
You can apply for verification when it reaches 75, until then it will be limited to 100 guilds
The scaler module was designed to be put on a webserver eventually for a web control but never got around to it
What's the point of worker threads?
I just noticed yesterday that my tasks weren't invalidated if the bot was getting ratelimited
Ah, right
basically, the bot was getting ratelimited after triggering a command at 1pm (ratelimit for the guild), if the ratelimit expires at 4pm, then the bot was finishing the task at 4pm
it wasn't aborting it
Then we get onto really complicated scaling like Crunchy where the whole bot can reload without loosing any events files adapted etc... While able to use all cores on a machine with work stealing 

The scaler module is sync, right?
Yeah
It was designed to go onto a flask app
Hence why starting it doesnt block etc...
Ah, I see
More a discord question like a bot question but is it possible to
write external emojis in ``this style`` --> this style
like this
this doesnt work for external emojis
or is there a way to do it?
No
Ahh finally my bot is running now :D
I want to make a wrapper for an api in NodeJS
but I have no experience in using API keys 
I want like
let a = require("a")
let A = new a({
key : "api key"
})
class API {
constructor (key, options = {}) {
if(!key) throw new Error('Key is required or something')
this.key = key
this.options = Object.assign(options, defaultOptions)
}
}```
ezpz
Thanks
class API {
constructor (key, options = {}) {
if(!key) throw new Error('Key is required or something')
this.key = key
this.options = Object.assign(options, defaultOptions)
}
cnjoke: function cnjoke() {
something here
},
anotherjoke: function anotherjoke(){
}
}
like this right?
nope
olisjds
isn't this what I am doing
function
ohh
its not an object 
class API {
constructor() {}
joke() {
},
another() {
}
}
like this?
no comma
yepp
constructor
oh
but I want to get it in the joke part so I can make request to the api
this.key
ight
Thanks 
and in end I do need to end module.export
and export API?
yea
k
kk
so this should work
ya
ight
I wish more developers used the assert module in Node.js
How can I make my bot 24/7 without heroku
It looks correct to me (even though it doesn't evaluate the if then block) I see the issue now
You'd need a host that's able to keep it online 24/7. Most users seek out VPSs
Is there any VPS for free?
#development message
read this
glitch is probably as close as you'll get
or repl
@split hazel they go to sleep after 5 mins
no hosting company in their right mind would give out a free vps with an isolated operating system
excluding things like giveaways of course
If there was a good, free VPS, everyone would be using it
Hello Spaxter
hai

Should do the thing
Or any port you would like to use
There's no place like 127.0.0.1
But I live in 127.0.0.1
resubmit it
fuck
let command = client.commands.get(args[0].toLowerCase()) || client.commands.get(client.aliases.get(args[0].toLowerCase()));
embed.addField('Name', `\`\`\`${command.name}\`\`\``)
embed.addField('Category', `\`\`\`${command.category}\`\`\``)
embed.addField('Aliases', `\`\`\`${command.aliases ? command.aliases.join(", ") : "`None`"}\`\`\``)
embed.addField('Example', `\`\`\`${command.example}\`\`\``)
embed.addField('Description', `\`\`\`${command.description}\`\`\``)
embed.setTimestamp()
return message.channel.send(embed)
}
}
}
for each comand help showing this field not define
how can i solve
I'm gonna go ahead and guess the error doesn't say Error: this field not define . Can you show exactly what the error is?
You are your own 127.0.0.1
I don't know how one can make a funny joke about it
Great, so, that means everything is undefined in that command object
log it and see what the heck it actually is
i log it but you can see i am define all this
embed.addField('Name', `\`\`\`${command.name}\`\`\``)
embed.addField('Category', `\`\`\`${command.category}\`\`\``)
embed.addField('Aliases', `\`\`\`${command.aliases ? command.aliases.join(", ") : "`None`"}\`\`\``)
embed.addField('Example', `\`\`\`${command.example}\`\`\``)
embed.addField('Description', `\`\`\`${command.description}\`\`\``)
embed.setTimestamp()
return message.channel.send(embed)
}
}
}
"not showing" what?
yes
What isn't it showing
It doesn't show this because the online/offline feature is currently broken. It used to rely on bots being on this server, but they have not yet devised an alternate method for it.
Which bots
@umbral zealot
I believe the vast majority of bots that show online have been on top.gg for longer than when they turned that off
showing
So it's "still" showing and hasn't updated since
top.gg probably went like "eh these guys are guaranteed to be online 99.99% of the time, so lets just make their online thing permanent"
or they did it themselves with css edits
not in the cards they didn't
They probably had last shown status saved in a database
What does your code look like
let command = client.commands.get(args[0].toLowerCase()) || client.commands.get(client.aliases.get(args[0].toLowerCase()));
embed.addField('Name', `\`\`\`${command.name}\`\`\``)
embed.addField('Category', `\`\`\`${command.category}\`\`\``)
embed.addField('Aliases', `\`\`\`${command.aliases ? command.aliases.join(", ") : "`None`"}\`\`\``)
embed.addField('Example', `\`\`\`${command.example}\`\`\``)
embed.addField('Description', `\`\`\`${command.description}\`\`\``)
embed.setTimestamp()
return message.channel.send(embed)
}
}
}```
@slender thistle please solve
lmao
did you copy and paste code or did you write it yourself?
I have written this, but I have taken help of this code, now offline
can anyone tell me what are webhooks??
discord's built in webhooks function as an easy way to get automated messages and data updates sent to a text channel in your server.
webhooks in general are reverse APIs
instead of you making a request, the API is the one making a request to you
ohk thanks
wait, what do I fill in defaultOptions
you can remove it then
nvm?
i use nvm
how do I use nvm?
This is my code
I keep getting this error - TypeError: Only absolute URLs are supported
api.pgamerx.com/demo/ you're missing the protocol
oh
sand me steam
where
nowwwww
nice domain
didn't know gay was a tld
is there any proper way to write this
what the fuck is that
why is discord like this
im stuck at this
in your type declaration, you define the type as false
true is not assignable to false. Replace it with boolean
add index signatures for the other two properties to the type
what i want to happen is when property x is false, property y and z should not be defined
or vice versa
so i have to separate it
Yeah
options.database.query(`SELECT * FROM warns WHERE guild_id = ${message.guild.id} AND user_id = ${user.id}`, function(err, result){
let warns;
const getWarns = result.map(w => w.warn);
const getPos = result.map(p => p.number);
if(!result.length) warns = "L'utilisateur n'a aucun avertissement.";
else warns = getWarns.join("\n");
const embed = new Discord.MessageEmbed()
.setColor(options.colors.gray)
.setTitle("π¨ Liste des avertissements de `"+user.username+"`")
.setDescription(getPos + ". `" + warns + "`")
options.database.query(`SELECT * FROM warnsCount WHERE guild_id = ${message.guild.id} AND user_id = ${user.id}`, function(err, result){
if(result.length) embed.setFooter("L'utilisateur a "+result[0].count+" avertissements");
return message.channel.send({
embed: embed
});
});
});```
I made this script to display the list of warns. But currently the embed gives me this (see photo) when I would like to like its:
1. β’ warn here β’
2. β’ warn here β’
etc ...
but how can i do??
-wrongserver
how can i make the roles varible send a tag instead of the ID?```js
const Discord = require('discord.js');
module.exports = {
run: async(client, message, args) => {
// !role @user
const user = message.mentions.members.first();
if (!user) {
const noUser = new Discord.MessageEmbed()
.setColor('#9e5ab9')
.setDescription(`Coulnt find user`)
return message.channel.send(noUser);
}
const roles = user._roles;
const roles1Embed = new Discord.MessageEmbed()
.setColor('#9e5ab9')
.addField("Role Name", `${roles}`)
await message.channel.send(roles1Embed);
},
aliases: [],
description: 'Lists every role from a user'
}```
You have to manually set line endings \n in embed description
And u dont need to separate order from items
const items = result.map(r => `${r.number}. ${r.warn}\n`);
There are lots of "features" but its on your own
oh thx uu
Don't take private fields there is user.roles.cache
What next: https://discord.js.org/#/docs/main/stable/class/GuildMemberRoleManager?scrollTo=cache
private fields?
Yeah _roles seems like private and not supposed to be used by you
it did manage to get the role id
Roles may be more than 1, you want to list all of them?
user.roles 
They dont need id to manage them
name your variables correctly
yes
Look at Collection methods filter to remove role everyone and method map to list rest of them
Why remove the role π€
thanks
Can I ask a discord related question here
If it's development related, sure.
Even after claiming roles in the server, the roles doesn't show up on his profile
And I don't see any kick or ban option even after having admin perms
What do you mean by "Claiming a role"
Just as normal other members claim role by reacting to the message
He claimed
But the role doesn't show up on his profile
And what concerns me more is that I don't see any kick or ban option for him
No no I checked he has the role
are you sure they're even on your server still
Oh oke
Just wondering if anyone knows how to keep an express server running? Currently pm2 isn't keeping it up and neither is forever.
are you using screen?
Yeah
afaik it shouldn't shutdown unless:
A - The process crashes
B - You manually interrupt the process (closing terminal or ctrl + c)
case A should be detectable if you store the logs
I do store the logs. Starting the server with pm2 I get the following error the displays on the site itself
what error?
at Function.render (/root/discordbotslist/node_modules/express/lib/application.js:580:17)```
sorry was grabing it
So uh. I shutdown the terminal for my bot but all the commands work still for some reason.
dual instance
or you're running it in the background
It was this one. Ty.
ive dug through this actually. uppdated pm2 aeverything
yes. i was on pm2 v 4.4.1 now i am on 4.5.6
sadly I can't help too much on that one, but I'd suggest manually updating every package
thanks for the help you did provide though. ill give that a try and update everything. Ill also probably update node to the new node now i guess, maybe that will help too
I want images from an API I'm maintaining to be sent to the user with a preview. The preview will most likely be the dominant color from the image so it feels natural when transition via animations. Would it make more sense to calculate the dominant color on the server side or client side?
server-side 100%
not only it becomes client-independent but you can also cache dom color per image
https://sourceb.in/rcXrauFaB8
Why The Kick Commands Allow UnManaged Server, Can Someone Help Me?
you what?
yeah I'm not sure what that's asking either
I like how this code couldn't really work because it would error on attempting to redefine the member variable a second time
Typo
Member Didnt Have Manage Server Role Right Except The Owner Give It
your code, as is, will only work if the person doing the command is done by someone with the Manage Server permission
But if there is a new member he can kick the person out of the server
Without Role
"he", as in, the new person coming into the guild can use the kick command? is that what you're saying?
Yes ... But I Want To Make That Person Can't Use Kick Command Unless He Has A Manage Server Role
Ok so that means the code you showed is not the code that is running
the code you linked would not allow for what you're describing
it would also error out anyways
so I have a feeling you're not aware that for nodejs to be able to see your code YOU MUST SAVE THE FILE. CTRL+S on your file.
then reboot the bot
let server = "";
client.guilds.cache.forEach(guild => {
server += `**${guild.name}** (${guild.memberCount} membres) \n`
})```
How do I sort to display the biggest servers first?
use sort() on the cache
Does anybody know of a good documentation template for github pages which looks something similar to this? I've seen so many bots have something very similar to these layouts for their docs and im planning on doing something like this
me ?
typedoc/jsdoc
for code at least
There is a high number of possible ways to produce this. PErsonally, I use JSDocs and convert to gitbook format after
gitbooks for manual shit iirc
lol
yes. that.
I had this in front of me but I donβt know how to use it:/
what library/package has the best/easiest to read docs?
yes but... 
hmmm
I think mine but I'm highly biased. https://enmap.evie.dev/
π
Thanks guys
.sort((userA, userB) => userA.memberCount > userB.memberCount)
well you're not sorting a member
you're sorting guilds
so you can rename those variables so they're more... y'know, descriptive?
Also if yo'ure asking if that works, the answer is: __try it __
mmmh
let server = "";
client.guilds.cache.forEach(guild => {
server += `**${guild.name}** (${guild.memberCount} membres) \n`
})```
but where do I place it x)
?
but you could do js client.guilds.cache .sort((a, b) => a.memberCount - b.memberCount) .forEach((guild) => { server += ''// what you had here before })
Thanks a lot !
maps but not
https://media.discordapp.net/attachments/754981916402515969/835016606429872148/buttons.gif
Is there a docomentation / tutorial how to use / make these buttons?
this is coming in v9 api iirc
current is v8
ayo that actually looks pretty cool
in .sort((a, b) => a.memberCount - b.memberCount), the contra of - is that + ?
im stupid pfffff
No, you're just inexperienced.
thanks π
-a + b
We all were stupid in something once
only those var names are
client.user.setActivity('${client.guilds.cache.size} ${clients.users.cache.size}', { type: 'WATCHING' })
})```
when i execute this i get this why
you used ' instead of `
``
Do you guys know how to make a ban or kick cmds, Can you send me the code in this chat?
I am usuing discord.js
hi teacher I don't know what the answer to this question is, can you do the test for me?
then graduates without knowing anything and fails in life
that's the same
asking for people to send you code instead of trying to learn will lead to failure
for example let's say we give you the code, you use it to make a bot, the bot starts growing, then you won't know what to do, if people want new features, changes, etc... u won't know what to do
Thanks For Info, Now Its Work
Good! 
Sorry If You Didnt Know What I Said
I Need Translate For What I Say
Yes, and I'm sure the translator is at fault for every single word being capitalized, too 
lol
im confused, i thought this would work..
err ```throw new TypeError('INVALID_TYPE', 'roles', 'Role, Snowflake or Array or Collection of Roles or Snowflakes');
^
TypeError [INVALID_TYPE]: Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes.```
var currentdate = new Date();
var time = "Date & Time: " + currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " @ "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
console.log(time)
exports.run = async (client, message, args) => {
let role = message.guild.roles.cache.get(r => r.name === 'Verified');
message.inlineReply(`Verified You On ${time} (Time Is Based Of My Host's Server)`)
client.channels.cache.find(i => i.name === 'logs').send(`${message.author} Has **Verified**!`)
let member = message.mentions.members.first() || message.member;
if (member != undefined) {
console.log('member=' + member);
message.member.roles.add(role);
} else {
message.channel.send('Verification Failed Please Contact Staff');
}
console.log(role);
}```
What does console.log(role) actually give you?
message.guild.roles.cache.get(r => r.name === 'Verified')
replace get with find
oh
now works
tyty thaT worked
how to add custom emoji in bot status?
You can't
kk
how to know which servers my bot is on?
client.guilds.cache
idk
From your shard
the problem is i want to check the names and how many members those servers have?
since i dont want my bot in small server with 5ppl or less
why?
well just check that when it joins a server
if it has less than 5 people
then have it leave the guild
my friend once did this by inviteing in less servers his bot not verified
how i check?
that's a bad way of growing your bot tho
no, I mean
what you're doing is the bad way
allowing small servers is the good way
okk
well depends on what lib you are using
discord.js
like, apart from verification, you still need to build a reputation for your bot
segregating servers based on member count will just make people hate it
Either way, guild.memberCount gives you the number of members.
also, the more members a server has the less likely it's to invite an unknown bot

yes
foreach nasty
unless it has some background history or was recommended by someone
yes
Yes, just use the guildCreate event with the guild parameter and check if it has less than 5 members. If it does than just have the bot leave it.
client.guilds.cache.forEach(guild => {
if(guild.memberCount < 5){
guild.leave();
}
});
run this once a month
foreach ew
it works
kk
if I invite 6 bots then after adding his bot I make all other leave then it'll still be there
that's the law you know
you try to make the code better and it won't work
because its >5 members at that time
the same thing can happen when running the foreach snippet
me
wait for it to execute and then kick off the bots
nah, that "don't touch working code" is bogus
once a month
idk how i managed this, but if someone uses the verified command form a different server there verified message gets logged in every server its in in the logs channel even if that member is not in the server the message is sent to
maybe each time the bot restarts
How long the heroku free dynos last?
hmm and yes is it fine if i make a command where it shows which server the bot is i n ?
about 20 days/month
@lyric mountain ohh
that's a violation of privacy
You can't just make my server data public
kk not even private cmds
if you shutdown your bot for 4 hours/day it can last a whole month
becoz some unknown servers add my bot
@lyric mountain how to keep my bot 24/7?
Add card
Without heroku
A - Buy a VPS
B - Use """free""" hosts
- Why did I put so much quotation marks? read this: #development message
C - Selfhost it
be like me and add a extra admin webpage for the bot where you can check which guild the bit is in, make it leave, see crash logs etc
look pins, there is message with VPSs
if it's public isn't it supposed to be added by unknown servers anyway?
yes so how u do it
your bot will only grow if strangers like it
no for now its private
not many cmds
only memes and staff cmds
learn expressjs and passportjs(for security)
kk
I say that's enough
enough so less lamo
command count is not a factor, code maturity is
and web dev (I use react)
kk
hmm code maturity?
my english aint good
broken english
yes, low bug count, highly user-proof, etc etc
when I made my bot public it barely had 30 cmds
how many servers now?
15 if you remove generic commands
now? about 2k
yesh
wow whats ur bot about?
ah u have the badge nice
they stopped giving right?
yes
kk
games with some general-stuff flavor
mostly games
and economy
I'm pretty sure you can but only disclose the server information to yourself.
GenshinUtils be like

Just not like expose the information about the servers to everyone
@opal plank forgot to ping
pong
β’ β’ β’
imma foward this everytime @zenith terrace says something about me advertising, im blaming it all on u million
I just personally attacked Erwin
hey so i have this at the top of my code message.author.bot) return;,but in one of the commands i do want to listen to one word of the bot. How do i make an exception in that specific command handler or is that not possible?
nah you gotta hit where it hurts more
why not return on the command instead?
aaaaaa
like "I think detritus is meh"
ok ty
or can i login in my bot and see?
that is indeed possible, but is there no other way to make an exception in the code?
definitelly don't
that's extreme privacy breach
you can, just gotta code it yourself, "command handler" is as descriptive as "i have a bot"
if(!message.author.bot){
//All the commands
} else {
//The other command
}
kk
theres thousands of ways you can do a command handler
on detritus it would be simple to check
I already used 5
they are all the same concepts tho
detritus, maps, commando, reading files on the go, using an api, 
if(msg.content === "$guild name") {
const ownerIdd =client.users.cache.get("769077060944658452")
client.guilds.cache.forEach(guild => {
ownerIdd.send(`${guild.name} | ${guild.id}`);
})
}
How can I list this in embed?
this has to be an emote tbf
that indentation is making me mad
- If ... else
- switch ... case
- the thing in Discord js.guide
- using objects (old me)
- using class handler (now after Erwin nagged me)
- maps
...
if(msg.content === "$guild name") {
const ownerIdd =client.users.cache.get("769077060944658452")
client.guilds.cache.forEach(guild => {
ownerIdd.send(`${guild.name} | ${guild.id}`);
})
}```
fucking dammit
Mmmm?
why is it ownerIdd not ownerId ?
you should concat them instead
if(msg.content === "$guild name") {
const ownerIdd = client.users.cache.get("769077060944658452")
for (const guild of client.guilds.cache)
ownerIdd.send(`${guild.name} | ${guild.id}`);
}
then separate it cuz of the 2k limit
.addField(client.guilds.cache.forEach(guild => guild.name))
if/else and switc/case are not handlers tho
wtf
what was the first bot code you wrote again ?
π
mmmmm, this is looking promising
wdym?
wtf
this
left hand side - triviabot cluster using D++
right hand side - triviabot cluster using aegis... on a GOOD day.
(green rows are native threads)
so its using half the ram, and under half the cpu
what's triviabot ?
what's D++ ?
what's aegis ?
what's that fuqing image ?
his bot
his lib
old lib
htop + stats
brain brain brain brain brain
@near stratus triviabot is my bot. D++ is my discord library. aegis is the discord library i was using previously. the image is some diagnostics of my testing showing that ive done what i set out to do and made something better. im flexing.
so left is the current stats menu?
oh okay
the new one isnt running on the dashboard atm, its in test mode
Can I get my answer?
so im using htop to monitor it
htop is cool but, I miss %st data
i dont really miss that
how do i add async here?
but i dont get the fascination with bashtop
bashtop looks like a toddler was set loose with crayola in my terminal
@earnest phoenix add awaits
module.exports = async (client, message) => {
//.......
}
pls
uhm yeah thx wait
where is Member ?
read my second message
server.members.cache.fetch()
you forgot the cache maybe
oi
then just use the async func
I'm pretty sure it's server.members.fetch
I'm dumb
cache.has works but i want to fetch it
do <Collection>.get || <MemberManager>.fetch()
wait are you trying to make the command guild only ?
nah for some premium commands i want that the people are in the support server for using the command (everywhere)
then use this ^^^
or you can just message.member || fetch...
@cinder patio he Can't see above^^^
the member in the message is granted to be cached
ah
how would i catch this to not error and force the bot to restart if the channel cant be found (Since not everyone has a log channel) ik i need to add a return somewhere and message.channel.send(""Unable To Log Verification As Logs Dont Exsist")
````message.guild.channels.cache.find(i => i.name === 'logs').send(${message.author} Has **Verified**!)```
but he wants to cache him from the support server
channel = bla.find()
if(!channel) return
https://i.callumdev.pw/3dz21.png
I have this to check if a session is available, and if not, authenticate with discord, but for some reason whenever it authenticates, it redirects back to the page it was on, as it should, but then creates an infinite loop, its as if the session was not created.
If I remove the check for a session after the user has authenticated atleast once then it works fine, with session being loaded. It's as if session does not become active after signing in until the page fully loads and renders, why could this be and how could I overcome this?
ty
Where are you getting the useSession hook from?
tim back at it with the bla
hi Tim
Never used next.js or next-auth, can't help ya
bla
bla bla
bla bla bla
bla bla bla bla
bla bla bla bla bla
@quartz kindle
if(bla) bla = blabla.then().then().then().then().then(await await await await await await await await message.channel.send('bla'))```
possibility of working : 13%
ex dee
const bla = (str) => {
if (str.length > 1) {
return bla(str+= (Math.random() * 100).toFixed(0))
} else if (str.length < 1) {
return bla(str+= (Math.random() * 10).toFixed(0))
} else if (str.length = 1) {
return bla(str+= ((Math.random() + 1) ** 5).toFixed(0))
} else throw new Error('huh?')
return
}
bla(0)
bla time
I messed something up
const discord = require('discord.js')
module.exports = {
name: 'maths',
run: async (message, args) => {
const maths = require('./maths.json');
const item = maths[Math.floor(Math.random() * maths.length)];
const filter = response => {
return item.answers.some(answer => answer.toLowerCase() === response.content.toLowerCase());
};
message.channel.send(item.question).then(() => {
message.channel.awaitMessages(filter, { max: 1, time: 15000, errors: ['time'] })
.then(collected => {
message.channel.send(`${collected.first()} is correct`);
})
.catch(collected => {
message.channel.send('Sorry but your answer was incorrect');
});
});
}
}
what the error mean?
your json file is not valid json
use https://jsonlint.com/ to validate and pinpoint syntactic errors
JSONLint is the free online validator and reformatter tool for JSON, a lightweight data-interchange format.
is there an easier way to use node canvas?
define easy
easier how?
there are many frameworks for it
depends on what you want to use it for
canvas-constructor is a good start
using chart.js and canvas gave me so much headache until ive figured out how to properly use chart.js
though using canvas directly gives you unparalleled freedom
in exchange for a lot of math
@bot.event
async def on_message_edit():
await bot.process_commands(message)
Would this work lmao
so it would process messages for commands if they edit?
does it?
canvas-constructor barely adds anything to canvas lol
Chained methods okay I guess but that's it
hey help!!!!!!
r_subreddit = await reddit.subreddit(f"{sub}")
posts = []
hot_subs = r_subreddit.hot(limit=5)
for submission in hot_subs:
posts.append(submission)
and i get this error
TypeError: 'ListingGenerator' object is not iterable
so how do i extract data from it?
umm...
is there a release date?
idk
..?
thats quite literally all I heard
Wait is there a bot which already implements this or is that a demo
Someone else tried it and it works
How is the styling for the buttons gonna work
oooo
he made it sth like this:
but It doesnt work correctly
thats how I saw it
and on the computer I cant see anything
Maybe. idk how to use a dev build ^^
But you can remove now attachements
thats new it think in discord
Im looking forward to try it
I'm waiting for dropdowns
ayo..
const desc = [];
const getMap = result.map(x => x.warn);
for(let i = 0; i < getMap.length; i++){
desc.push(`${i + 1}. ${getMap[i]}`);
}```
I want to remove a data in my MYSQL database using this, but how to get the data from i = 2
Give an example what you want to do
What's your file structure like and where are you importing those modules from
If the administrator wants to delete a data with the identifier (i) which is equal to 2 (or 1, or 3 etc..), then delete the data
@still sky

Guys is there any guides on how to host database on any vps like vultr
Currently I'm using mongodb as a database
Is it easy to use?
there should be plenty of them
Yes mongodb is easy for me for now
once you know the basics of mongo its easy
But if I m using vps I can use the storage it provides instead of mongo
Like
SELECT col FROM table WHERE primary_key == 1
That's how it goes in every db right?
Where is that "identifier" defined? there is no any numbers to compare with
Except indexes
@still sky Look, desc send this (there is currently data). And {i +1} itβs the number at the start of the sentence is 1. and 2.
I wanna move from it coz it's not very cheap also I wanna use the storage comes with vultr
Which is server based
And can be accessed from anywhere
Unlike SQLite which is only accessible where it's stored
The SQL syntax doesnβt know ==
WHERE key = 1
Would be the correct syntax
Yeah yeah
just =
Damn now everyone be pointing out that thing
i help u
Oh
Help me with this thing
I dunno what to do with that ListingGenerator thing which it returns
Using praw lib
For Reddit
If you wanna keep the SQL format then switch to MariaDB, Postgres etc.
Oh oke alr
Which will help you to create a decentralized database you can access from anywhere
what db do you use
Me ?
ye
ListingGenerator is an async iterable, you need to use async for
if you at least attempted to google this, you'd find this information
const indexForDelete = 2
const updatedDesc = result
.filter((_, i) => i !== indexForDelete )
.map((warn, i) => `${i + 1}. ${warn}`)
I tried googling
I'm not sure if it exactly what you want
@worn sonnet is a first resultβ¦
And the results showed up for ListGenerators
I got some weird quora answers
Saying generators are not iterable and so on
On the topics of stackoverflow, you will have very little nonsense
i go to test
There was one video so I followed him too resulting in the above code
Worked for him but not for me
ππ
stop watching youtube videos and start reading doc pages
@still sky No, he returned all the table
I looked into the doc and
Dumb me was looking into praw doc instead of async praw
@worn sonnet use mySQL instead
Did you test with indexForDelete = 2 and only 2 records in table?
Change indexForDelete to 1 ...
mmh ok
Most of them recommend it but I don't get it how to host on my pc
Will look into that answer tomorrow
returned all the table @still sky
ok
show pls all code
ok wait
It has workbench and someother thing
I dunno how to get started
And which password is for what
U can say I'm completely lost on MySQL
@worn sonnet
Do the passwords need to be stored on your phone or in a secure place?
It will cost you less to take a vps than to leave your poor computer on all the time (level of electricity bills)
update .filter((_, i) => i !== Number(id) - 1)
.join('\n')
when i do the command with 2, he returned only 1.
if i use the command with 3, he returned all record
but always object Object
where your .send()?
const updatedDesc = result.filter((_, i) => i !== Number(id)).map((warn, i) => ${i + 1}. ${warn}).join("\n");
message.channel.send(updatedDesc)
i have remplaced console by .send
i have removed - 1 and when i do the command with 2, he show me 2 record so itβs good
but i donβt want this, i want to show only the record = 2
You wanna keep order number, dont you?
yes
Otherwise I cant understand what exactly you need
use reduce
Example: i have :
- data here
- data here
how can i show only 2.
Your ordering based on indexes in array, you need connect ordering with something else
IDs for example
Even so you wont get order numbers between commands
Mb with awaiting message, if its like "minisession" for one commad
You can define list after query, set ordering, show it -> await message -> do side effects, delete and show updated
i to make warn
i have a bot that coded in java
discord.js
and i have working music bot with some mod commands
and i need more
How can i check if result returned [] in mysql?
what
do you mean if the query returned no rows
yes,
i have try if(!result.length) but he tell me « cannot read property length »
can i get a mute and warn command
like warn
which library are you using to interact with mysql
i want to make on
javascript
library
no
i need that in warn
Ok and?
please
because u bot developer
according to the docs if no rows are returned the result will be an empty array, it shouldn't be undefined
what's your code
and ur active rn
ask mee6 owner to give you warn command
database.query(`SELECT * FROM prefix WHERE guild_id = '${message.guild.id}'`, function(err, result){
let prefix;
console.log(result)
if(!result) prefix = data.prefix;
else prefix = result[0].prefix;```
oh god
please use prepared statements
you're going to create an sql injection vuln somewhere in your code
no
??
i don't think you understand what i'm saying
traductor is so bad
Cannot read property 'find' of undefined
at Object.run (/home/runner/Jester-Bot/commands/music/play.js:74:35)```
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
thats my code
can someone help?
why are you copypasting code
doesnt matter now
yes it does
can u help me or not?
where did you copypaste it from lol
some github repo
doesnt matter now
anw
can u help me?
SyntaxError: C:\Users\MagiK\Desktop\BOT SENGOKU NADEKO\config.json: Unexpected end of JSON input
running music bots isn't really profitable nor sustainable anymore for small bot devs
your config.json contains invalid json
use https://jsonlint.com/ to validate and pinpoint syntactic errors
JSONLint is the free online validator and reformatter tool for JSON, a lightweight data-interchange format.
invalid, not valid
in the result says valid
are you able to share the file?
remove any sensitive information, i.e. your bot token
That seems correct





