#development
1 messages ยท Page 1567 of 1
Ik
About your question, guildMember doesn't exist
How Do i make It Exist
I want to get someone's bank balance in dank memer through a bot. The embed with the user's info is the last message, but how do I read the embed and get the actual bank balance? discord.py
problem: something is not defined
solve: define something 
Those are your available variables
ye
Unless you have some global vars file, that's all you have to work with
Oh
Read the docs for the lang/lib you're using, that's all the reference you'll ever need
Ok
with open(".cogs.games.easy.txt", "r") as dictionary: is this correct?
Assuming msg is the Message object, msg.embeds[0] will return the first embed of the message, then just get the attribute you need.
it keeps saying file not found
I doubt
how the file structure looks like?
I want to get someone's bank balance in dank memer through a bot. The embed with the user's info is the last message, but how do I read the embed and get the actual bank balance? discord.py
well its cogs > games > the file
Already answered
where?
try cogs/games/easy.txt
Here
oh i didnt get the ping
what is the "first embed"
how do i upvote mafia bot
Click vote on its page
worked ty
Well, a message can have multiple embeds, so you get the first one
how
ok i want to get the second line
like not the description
but the second element
second field?
Top.gg -> search -> view -> vote
how would i do that?
k
then just embed.fields[1], embed is the first embed I was talking about
ok
Ok, nvm
huh
It'll return an EmbedProxy that has name and value attributes btw.
bro i correct it and now the error is :
code is :-
`def get_prefix(client, message):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
client = commands.Bot(command_prefix = get_prefix, help_command=None)`
if someone invited your bot while it's offline, the key will not exist
i am now doing rial only
assuming you're dumping it in on_guild_join
my bot is in my trial server
oh
i was sleeping, check out this article https://mikecodes.net/2020/05/11/in-app-scripts-with-c-roslyn/
`@client.event
async def on_guild_join(guild):
with open("prefixes.jsno", "r") as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = "]"
with open("prefixes.jsno", "w") as f:
json.dump(prefixes, f)`
Why on earth is it jsno
well doesn't matter anyway
๐
i have to re invite my bot ?
wait json db?
then will it work ?
ya
That's the unlike option I'd choose
๐
if it was a public bot, why would you let people to re-invite it just to make it work? Instead, handle the error. You could do either:
- try and except, then dump it on exception
- if statement to see if the key exists, if not dump it
- use dict.get which can return a default value if the key doesn't exist
ok
which db do u use ?
should i use mango db ?
postgresql
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.

One message removed from a suspended account.
One message removed from a suspended account.
do you have a vps?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
What should I use as a database
Pick what suits your project, I found relational DB convenient
Ok
I have do many more like
Timed mute
Warning
And more ....
Is it online db ?
Or I have to make in my pc
if you just need something basic use mongo i guess
and self host your own instance on a vps
There are services that provide that, but I do self-host it on the same machine
One message removed from a suspended account.
One message removed from a suspended account.
yeah i snatched that flowchart from dnet
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Anyone here successfully implemented sharding with discord.js?
For some reason, my sharding manager hasn't actually spawned any new shards ... it's up to about 1.4k servers on a single shard. Unless that's by some default higher number than 1,000?
i thought default was 2500
i dont actually know, lemme see if i can find it in the docs
Is 2,500 recommended? I've seen 1,000 recommended in various places.
1500 is recommended to start sharding, the number you use is as much as a single thread can handle.
many bots use over 2500 with internal sharding.
I'm trying to make an embedded message and I keep getting this warning "UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message"
How can I set that defined number? I tried setting it ... but it ended up spawning multiple shards over and over again ๐
That's error sounds fairly self-explanatory, tbh
I don't know how to fix it though
Send content in your messages ๐
I tried looking up solutions but none work
Probably what's happening is that you're sending an undefined variable by mistake.
Can't be clear on that without the code ๐คทโโ๏ธ
op its 1000 by default
const embed = new Discord.MessageEmbed()
.setColor('#f1fab9')
.setDescription(`${message.author}'s avatar!`)
.setImage(message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setFooter('Wanted someone else\'s avatar? Tag them in the command!');
Do you have the link to that?
That is the code for the creation of the embed
I don't see a title ๐
I have discord defined as discord.js
Where is the setTitle()?
Are titles necessary?
I thought so ๐คทโโ๏ธ - could be wrong
It gave me the same message when I changed the description to title.
Doesn't it need both a title and description?
no
Ah, see. I'm an idiot
What about the actual message send portion?
How is it sending the embed?
can someone tell how i can send an array into a text file, does i need fs ? or i can do something without it
if (!message.mentions.users.size) {
try {
const embed = new Discord.MessageEmbed()
.setColor('#f1fab9')
.setTitle(`${message.author}'s avatar!`)
.setImage(message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setFooter('Wanted someone else\'s avatar? Tag them in the command!');
message.channel.send({ embed });
}
catch(error) {
message.reply('there was an error');
console.log(error);
}
}
what's the use case for this
@earnest phoenix export a list of user with a certain badge
Do you use DiscordJS with its sharding manager?
you should probably use json
i dont even have any bots anymore, never got to the point i needed sharding
json?? no i mean i want to send the userlist into a .txt file
and i don't want a lot a text files on my vps so i can send a txt file without fs?
you're sending an object that wraps around the embed, not just the embed, remove the curly brackets in send
what do you mean by "send" a txt file?
writing a txt file?
upload to discord and yes you can
Still gives the same issue.
i can without fs?
I'm not quite certain on that. I have to use message.channel.send({embed: whatever}). The syntactical sugar there is message.channel.send({embed}) since the variable name is embed
i have no idea how to do it with node but you need to generate the string, convert it to a buffer and then just send that buffer as a file
@mellow kelp but i need a file??
If you are storing data you should use sql databases
oh, i thought the first argument accepted a string or an embed, not an options object
Ig sending a text as a txt file without an actual txt file
That is interesting now that you mention it.
oh no it's okay, i saw MessageAttachments on the docs and that's actually what i search i think
I just used the options object and it works for me ๐คทโโ๏ธ
I can additionally do message.channel.send('text here')
It sends an embed just gives an error
oh aight
Does anyone have a successful implementation of the sharding manager for Discordjs?
This is the embed it gives me an error in the terminal but still sends ๐คท
I also want the avatar to be larger like how dyno has it, but I couldn't find a solution
for the size, use the size option on the avatar url method
Ok
are you sure the error is coming from there
All of the guides I found used 256 which didn't change the avatar's size but using 2048 is a good size in my opinion
const Discord = require('discord.js');
module.exports = {
name: 'avatar',
description: 'Gets your avatar or the avatar of the tagged user!',
execute(message) {
if (!message.mentions.users.size) {
try {
const embed = new Discord.MessageEmbed()
.setColor('#f1fab9')
.setDescription(`${message.author}'s avatar!`)
.setImage(message.author.displayAvatarURL({ dynamic: true, size: 2048 }))
.setTimestamp()
.setFooter('Wanted someone else\'s avatar? Tag them in the command!');
message.channel.send(embed);
}
catch(error) {
message.reply('there was an error');
console.log(error);
}
}
const avatarList = message.mentions.users.map(user => {
return `${user.username}'s avatar: <${user.displayAvatarURL({ dynamic: true })}> \n Wanted your avatar? Don't tag a user in the command`;
});
message.channel.send(avatarList);
},
};
actually it could be, you're not awaiting send so that try catch won't work
Full command file
1024 is big enough
I don't get any errors with my ping command
most people don't have a big pfp
imagine misspelling that
i presume it's the last few lines that are causing your problem
"most people don't have a big pp"
@slim heart are you still alive? I need help
currently dead but sure what's up
โจ and it was an xyproblem all along โจ
I thought you had defaults
it does
thats why its intents?
don't define it
it should default to all intents but privileged ones
pain
uh
just sent intents to the array of intents u want
I grabbed the basic intents from the intents calc
u can make it an array
of strings?
pog
or try settings intents to false
intents: Array.isArray(options.intents)
? options.intents.reduce((a, b) => a | Intents[b], 0)
: options.intents === true
? Object.values(Intents).reduce((a, b) => a | b, 0)
: options.intents
? options.intents
: Object.values(Intents).reduce((a, b) => a | b) &~ Intents['GUILD_MEMBERS'] &~ Intents['GUILD_PRESENCES'],
sadly it worked before I pulled
idk what could be wrong
fuck intents
just use an array of intents
Intents good
should be typed
oe
I think
I have this,
const manager = new ShardingManager('./src/bot.js', { token: Config.Bot.token });
manager.on('shardCreate', (shard) => console.log(`Launched shard ${shard.id}`));
manager.spawn();
My discord bot hasn't actually spawned any new shards even though it's been placed in over 1k servers? Am I doing something wrong?
Just 1
the recommended is 1k per shard
likely because discord thinks it only needs 1
if you want more shards u have to set it manually
It's in 1.4k right now ๐ค
Shouldn't it have spawned another automatically?
Making it 2 shards?
once you hit 2k it will
berry
So the first 1,999 servers are all on 1 shard?
u can lower it to like 700 servers per shard or something
That's technically almost 2k servers to 1 shard
yeah
Thanks for filling me in. I thought I was doing something wrong. Thank you.
a shard can reliably handle more than the max, which is 2.5k it's not debilitating to have 2k on one shard
Yeah, def. I'm not worried about it.
I was just concerned thinking I wasn't doing something correctly.
sup
i mean u can forcefully shard
not terrible
depends on your workload
I'm just going to let it do its own thing. I'm at 2% CPU usage with 1.4k servers ... and I don't really notice any lag at all.
1.4k shards ?
oops - 1.4k servers ๐
how exactly do you make sharding in a lib
shards aren't really for lag preventation but yeah
Damn, they aren't?
for discord it's useful
it doesn't force you to do anything
and less load on them
I thought discord did force you to shard?
at 2.5k yeah
but discord recommends sharding for ease on them
Yeah, that's what I thought.
discord has a shard count calculate endpoint that is used by default
so if u leave it undefined discord decides how many shards to spawn
Which library do you work on?
pog
@top.gg/sdk ?
yessir
Perfect! 0 problems. Thanks for your contribution on that!
ye lol
yeah im still having issues with intents
can you send me the intents you test with?
Thank god I don't use them ๐
const config = require('./config')
const Master = require('../master')
const master = new Master(require('path').resolve(__dirname, './worker.js'), {
token: config.token,
cache: {
members: true
}
})
master.start()```
lmao
"Make your bot into a moderation bot", they said. Screw that.
i dont define the intents
Is that your own client, Stinky?
wip
tyty
for discord when?
i used to lmao
idk man you actually look like spiderman
but i like frog
It looks lightweight judging from the 5 seconds my eyes have laid upon it ๐
try setting intents to true
if you had different glasses
it can be if u want it to
Exactly
the caching is just toggleable lol
and built in clustering 
light-discord.js
No issues so far ๐
Worst comes to worst, Tim gets hit by a bus and if no one maintains it ... I'll just interchange it out with Discord.js again.
@crimson vapor just realized im having the same issue
bro your lib is trashhhhhhhhhhhhh
ill fix it 1s
Imagine having a lib.
lmfao the loop of reconnects
well if u have disallowed intents what do u expect smh
bro just fix
errors right there just fix it 9head
yeah it does
the warnings are just borked some how
intents: true
enables all intents
lol what
LOL
ok i pushed
I fuckin deleted the this.initMongo() and was confused why my db wouldn't connect
How are you
and my cache is working well
now im doing way less requests
~1/2 of the normal requests
nice
Another quick question - is there any referenced documentation for catching DiscordAPIErrors?
@slim heart add ctx.content which is message.content minus the prefix shit
'Cannot execute action on a DM channel' would be something I'd want to avoid in the future by just filtering those out all together
don't log the error depending on it's error code
I'm saying, how can I prevent the bot from responding to DMs. Sorry for not making that clear ๐
Is it that simple ๐
Is that a client parameter?
message.channel.type === "dm"
message.guild will be null on DMs
Yes

Is it custom for most bots to allow dm's? Or do most popular bots not allow them?
Not that it matters, just curious.
I dont allow mine
My bot doesn't allow it
bcs I dont need them
It breaks my prefix stuff
^^
and people would just spam it
I don't do anything about it
True
well you can do like
Most bots are meant to be used inside guilds anyway
I just added error reporting to actually notify me of uncaught errors lmao.
message.channel.type === "dm" && message.content === ${prefix}help {...}
hey guys so i have a question
Thomas legit the only reason you would need dms would be for like help commands
they arent a object
Yeah it's annoying
True . Plus, I don't want to do that anyways ๐
Some people disable their DMs
Not only is it annoying to navigate to dms - but it may also pose another problem of lack of permissions to be able to send dm's.

Exactly
lets say i have a queue that is put in a promise.all that would finish executing any element in the queue array, how do i remove the finished item from the queue? queue.shift() would remove the first one, but it whouldn't if its not rfinished
var userQueue = [user1, user2];
function initUpdateQueue() {
setInterval(() => {
Promise.all(userQueue.map(async (u) => {
await updateUser({ id: u.id }, u);
var temp = clone(userQueue);
temp.shift();
userQueue = temp;
}));
}, 1000 * 5);
}
yeah ik
but if user2 finishes and user1 is still executing
it shouldnt remove that from the queue
what?
i mean
check length of the array
You can't use async inside methods like map() and forEach()
idk what you mean exactly
They ignore it
i need to remove the item that finishes first
if [0] has not finished but [3] has finished
i need to remove 3
not 0
ah splice
flaze give canvas code for lego @pale vessel
Asking for code multiple times despite being ignored, funni
yeah pls
Any idea why m.createdTimestamp returns NaN?
Code: message.reply('Pinging...').then(m=> { m.edit('Pong! '+Date.now() - m.createdTimestamp+'ms')
Because math and numbers
Lol
Put date and time stamp in ()
I did
Surround your calculations with parentheses
Then got m.createdTimestamp is not a function
I-
Lmao
"Pong" + (now - timestamp) + "ms"
Ok
Iโll show my code
It worked, Youโre a life saver
module.exports = {
name: 'ping',
requiredPermissions: undefined,
owner: false,
description: 'Get the bot's ping',
run: async (message, args) => {
await message.client.responses.smallEmbed(message, 'Pong!')
await message.client.responses.smallEmbed(message, Pong! (${Math.round(Math.random() * 100)}ms))
}
}
Poggers code? @pale vessel

Ok 8/10
Why 8?
~~Because two space indent, no double quotes, and no semicolons ~~
It's based
Interesting
const DC = require("discord.js");
module.exports = {
name:"serverinfo",
run: async(client, message, args) => {
var memberCount = message.guild.members.cache.filter(u => u.user.bot == false).size
let TOMATO = new DC.MessageEmbed()
.setTitle("**Server info**")
.setColor("RANDOM")
.addField("Member Count",""+message.guild.memberCount+"")
.addField("๐งHumans๐ง" , memberCount)
.addField("๐คBots๐ค" , message.guild.members.cache.filter(u => u.user.bot == true).size)
.addField("Channels Count" , ""+message.guild.channels.cache.size+"")
message.channel.send(TOMATO)
}
}
Why is the bots and humans returning 1?
Before my bot got verified it worked. Now itโs verified on discord and doesnโt work.
You need to cache members
It worked fine before verification though
Did you request for the guild members intent?
You need that in order to fetch all guild members
I did and I got asked to provided screenshots of it, So I did and a week later and it was verified
Try adding await message.guild.members.fetch() to the first line of your code
That makes sure that all members are cached
Hello, I'm developing a bot with the discord.py package and using python's built-in SQLite3 to store users/guilds settings. Eventually I want to host my bot on Heroku, but since it loads the database from github and SQLite3 is a local database, restarting the bot would result in losing everything after the bot started running. Is there a way to solve this without having to move the database to something like Postgresql? Thanks :)
I'm afraid not
You'd have to use remote database
Heroku offers free PostgreSQL database, maybe use that?
Ye, I knew about that, I was Just too lazy to change the whole code database system 
But ok seems like ill have to do It anyways, thanks :]
ik my js and it says this isnt a function. ever with a .cache in there
.cache and without both return without a function
Are you on Discord.js v11?
What is the best way to create a blacklist of users? Load ids into a map and call it day? Before each command, check to see if the user is in the map? O(1) complexity?
yes, thats the easiest way
I appreciate it! Do you have any recommended ways for storing a huge list of user ids like that? I wouldn't want to throw it in my NoSQL database since I'm charged per every kb pulled from it ๐ฌ
I guess most people just use a database table for that ๐คทโโ๏ธ
mongodb atlas is free, you can have their 500 mb storage. That reaches for 4million documents with each 5 fields
@long marsh Which language are you using?
JavaScript ๐
Yeah, that should work. I appreciate it. I may just store it in my database for now; however, I'll look into that.
Thanks!
you can us mongoose, Its a easy libary for data storage.
Any discord.py devs wanna collab on a bot?
any C# devs?
do you have presence intent on
You don't need that intent for that
Ok so
now i have another issue
client.guilds.cache.size returns Cannot read property of 'cache' of undefined
client.guilds is undefined
Are you sure you passed the client correctly?
Log client
It shouldn't be undefined then
ikr
quite unusual
FetchError: invalid json response body at https://hastebin.com/documents reason: Unexpected token < in JSON at position 0
at C:\Users\shahn\3D Objects\Botcode\rewritten br\node_modules\node-fetch\lib\index.js:272:32
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async C:\Users\shahn\3D Objects\Botcode\rewritten br\commands\Dev\ex.js:153:36
at async C:\Users\shahn\3D Objects\Botcode\rewritten br\commands\Dev\ex.js:149:26 {
type: 'invalid-json'
``` I was trying to post something, but its not working
Did you use a POST request instead of a GET request?
await fetch("https://hastebin.com/documents", {
method: "post",
body: evalOutput.join("\n")
})
.then(async (res) => await res.json());
yes
do you guys know how to run asyncio.gather() outside an async function?
can I use vs code to just search some specific code and then a part is a any, like for example yes = "*"
I tried with an asterisks but it did not do the thing
hey guys
umm so
when there are 100 users concurrently making calls to DB the response time keeps increasing
it went from 20ms to 130ms for 100 calls wtf
16gb ram and a 4cpu db
I'd suggest to start caching then imo
what does it mean when a shard is ready but the bot didnt restart?
Yeah cache them in a guild settings cache instance, making a query for every messsge will block the db when necessary data to be entered.
Anyone knows what's the current Ratelimit for DMing a user or users globally ?
hi guys
how can i get number of members in a voice channel?
if i have channel id and guild id
i could get the snowflake of .members
members is not array
well its not making query for every message, also these are update calls
and in the get call there are like 200k+ rows which i obv cant cache
can i know that my code is right or not for posting votes?
const DBL = require('dblapi.js');
const dbl = new DBL(`mytoken`, { webhookPort: 5000, webhookAuth: 'kristabisop' });
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
const webhook = new Discord.WebhookClient("806564380589293568" , "xEuuucsqFPdJ5JsOTONgGzGP-sHmSCaqdY_gBc8TNAVse11C8H3-TO-QwlTVvIpV3oi5")
webhook.send(`<@!${vote.user}>, Just voted the Order It!! \n\nThanks for you great support mate :)`)
});
it should work yes?
ik
time to fire up my bot nets
its old one
can anyone help in it?
umm?
also #topgg-api
what is this?
new library for js
can i get the link?
ok
which other example?
i only see the autoposting example and webhook
yes, the autoposting one
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
})
I dont use express so what should i put in app?
you need to use it
webhooks are reverse APIs, top.gg makes a request to your ip/domain instead of you making a request to their domain
oh oops misread what you need
lol maintaining a WS server costs more than just making http requests
umm
yes
bruh the CPU still needs to make heartbeat
lets say there is 10k bots connected
every min or so
it needs to send out 10k pings to the connected clients
i'm aware
it's not as tasking as you think it is
if not gameOver: mark = "" if turn = ctx.author: if turn = player1: mark = "๐ฝ" elif turn = player2: mark = "๐
พ๏ธ"
got an error :-
if turn = ctx.author: ^ SyntaxError: invalid syntax
thats true, ask veld/team ppl then
compare that to people who are actively making REST requests
a ws is just another type of protocol
in both cases you still need to have a listener
= =/= ==
i use glitch for hosting so what is my ip address?
thx
how about you make one to forward webhooks to WS ๐
ironic, i thought about making that like half a year ago
just a simple WSS server
What I need to correct !?
never got around to doing it
Ok
Not = I have to use == right ?
K
btw can we use discord.js client and express at once?
yes
your app is not just your discord client nor is it just your express server
your app is an... app
you choose what to do inside of it
then you didn't set it up properly
make sure the port and ip is correct
and the auth password is the same as the one you put in your bot edit page
i have
i make app and make it listen to 5000 and i got the ip and puted in bot edit page
Is it on a vps or your own pc?
gLitCh
ex dee
What did you put in the url? Glitch has a specific way of doing it
It doesnt use ip
How can I connect to mariaDB in java (maven)
any solutions?
umm
it gave me ip
mariaDB shares the same protocol as mySQL, so any mySQL library for java should work
ok
glitch doesnt use ips
The correct url is not an ip
also they dont allow you to use port 5000
bruh then what can i do ?
The correct url is https://YOURPROJECTNAME.glitch.me/WEBHOOKPATH
And the correct port is process.env.PORT
needing assistance with the bot
anyone know postgres?
how can i get it to start registering chats to my ark survival ps4 servers?
how to use it?
.listen(process.env.PORT)
help
/home/runner/Maimy-Bot-V2/index.js:29
delete require.cache[require.resolve(`./commands/${fileName}.js`)];
^
TypeError: require.resolve is not a function```
you did not defined as a function
probably you copied the code from somewhere and did not copied all of them 
huh?
did you make it yourself?
Nope im learning tuto about module.exports
give , me full code lol
huh?
of the command
i just made BAN COMMAND .-.
where is this code running?
you pc? a vps? glitch/heroku/replit?
repl
tim, I have a problem with my reload command, it does not reload commands ๐ฆ , Let me send the code
repl.it uses ES modules instead of CommonJS
ES modules do not support require.cache and require.resolve
const resolveFolder = folderName => path.resolve(__dirname, "..", "..", folderName);
const commandsFolder = resolveFolder("commands");
fs.readdirSync(commandsFolder).map(async(dir) => {
if (dir.endsWith(".txt")) return;
fs.readdirSync(path.join(commandsFolder, dir)).map((cmd) => {
const pull = require(path.join(commandsFolder, dir, cmd));
delete require.cache[pull];
client.commands.delete(pull.name);
client.commands.set(pull.name, pull);
if (pull.aliases) {
pull.aliases.map((p) => client.aliases.delete(p));
pull.aliases.map((p) => client.aliases.set(p, pull));
}
});
});
console.log("All Commands Have been reloaded.");
Is not working lol and it does not give any error
deleting from the cache requires the module path, not the module itself
also, deleting it after requiring it is dumb
and dont use .map if youre not returning anything
i hate using forEach just because it looks dumb (and because it returns undefined and thats boring) 
i'm just
but... if you're not returning anything anyway, you want to return undefined lmao
also yikes, async map
Is this right?
oldBoolean == true ? newBoolean = false : true;
newBoolean == true ? toggle = 'on' : 'off';
huh
I'm rather curious why you would do that
why not just newBoolean = !oldBoolean?
You can assign something inside ternary?
nah
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for +: 'int' and 'str'
something = False is a statement sadly
how will i know in which line the error is ?
>>> something = True if True else x = False
File "<stdin>", line 1
something = True if True else x = False
^
SyntaxError: cannot assign to conditional expression
Cast the string into an int

Print the traceback
omfg, so you can do that
which line how i will know
How are you handling your errors?
how should I properly replace all occurances of say {{guild.name}} and {{user.name}} in a string without doing many different replace functions?
me ?
Yes
k
@tictactoe.error
async def tictactoe_error(ctx, error):
if isinstance(error,commands.MissingRequiredArgument):
await ctx.send("Please mention two person for this commmand :watching_you:")
elif isinstance(error,commands.BadArgument):
await ctx.send("Please make sure to mention players :alert:")
else:
raise error
@slender thistle
@pale vessel you alive?
"{{name}} {{owner}}".replace(/{{(.+?)}}/g, match => {
switch (match.slice(2, -2)) {
case "name": return "Name";
case "owner": return "Owner";
}
});```
ty
just retype it smh 
no thanks
yo norizon
sup qt?
js let str = "{{guild}} {{guild}}"; while (str.includes("{{guild}}")) str = str.replace("{{guild}}", "Guild"); str; // "Guild Guild";
bruh
joke
why would anyone want that

I suppose 
wtf is this is not shit
is it wrong ? @slender thistle
Do you have an on_command_error event?
just to add up on it
@slim heart I evaled process.exit() and got Segmentation fault (core dumped)
ya
show
k
@client.event async def on_command_error(ctx, error): if isinstance(error, commands.CommandNotFound): await ctx.send(f"Can't find that command, send ]help to view a list of commands")
is that all
Do you not get a full traceback when an error occurs?
ya i get
ah wait @slender thistle
i had forgot to scroll down
the error line was shown
๐
do you mean where the commands are allocated?
message.guild.roles.cache.forEach(role => console.log(role.name + " | " + role.id))
im trying to list all roles in a server which ive managed to do above, but now i want to make it so itll only list the roles thats name starts with args(0)
use .find method
the require cache stores data using the full module path
like this
I would have done if(role.name.startsWith(args[0]))
require.cache = {
"C:/users/USERNAME/desktop/bot/node_modules/somemodule/index.js": module
}
i tried adding an if function but it outputed a ton of errors
so to access or delete it from the cache, you need to obtain the full module path
for this you can use require.resolve("module") to get the full path, then run:
delete require.cache[FULL PATH OF THE FILE]
message.guild.roles.cache.forEach(role => if(role.name.startsWith(args[0])){console.log(role.name + " | " + role.id)})
would that work?
k
it won't
shh
SyntaxError: Unexpected token 'if'
how do you think you should fix this?
by finding an alternative to 'if'?
thats 1 solution
or by having almost no understanding on the whole forEach function and its rules
message.guild.roles.cache.forEach(role => { if(role.name.startsWith(args[0])) {console.log(role.name + " | " + role.id)} })```
or
```js
message.guild.roles.cache.forEach(role => role.name.startsWith(args[0]) ? console.log(role.name + " | " + role.id) : null)
oooooooooooooooh ok
i remember seeing something like thgat in a document for .forEach but it made it a lot harder to understand
foreach takes a function
role => role.name.startsWith(args[0]) ? console.log(role.name + " | " + role.id) : null is a function
so is role => { if(role.name.startsWith(args[0])) {console.log(role.name + " | " + role.id)} }
for each just loops over an array / map and calls the provided function on each iteration
you can achieve the same thing with a for loop
or any loop
bro my command not working and no error comes ๐ญ
ok
(it's even recommended to use a loop over forEach)
debug it
k
Sorry for you
๐ฅบ
ig
how do you think you should figure out if the command is running
and then do that
error come = look at console
ok
careful read
bruh
see error traceback = carefuler read
lol
ok
okay will try
i want help with node fetch, i need to get property of json nested arrays from an api
That's not really node-fetch related but okay
thing[0][1][2] etc. innit?
{
"tag": "#P2U0GVJP",
"name": "DYNAMIC FIGHTER",
"nameColor": "0xff1ba5f5",
"icon": {
"id": 28000043
},
"trophies": 16395,
"highestTrophies": 16395,
"highestPowerPlayPoints": 71,
"expLevel": 104,
"expPoints": 57365,
"isQualifiedFromChampionshipChallenge": false,
"3vs3Victories": 1677,
"soloVictories": 206,
"duoVictories": 722,
"bestRoboRumbleTime": 6,
"bestTimeAsBigBrawler": 0,
"club": {
"tag": "#RPVU92GC",
"name": "Royal Lynx"
},
"brawlers": [
{
"id": 16000000,
"name": "SHELLY",
"power": 8,
"rank": 21,
"trophies": 511,
"highestTrophies": 556,
"starPowers": [],
"gadgets": [
{
"id": 23000255,
"name": "FAST FORWARD"
}
]
},
{
"id": 16000001,
"name": "COLT",
"power": 8,
"rank": 21,
"trophies": 549,
"highestTrophies": 560,
"starPowers": [],
"gadgets": [
{
"id": 23000273,
"name": "SPEEDLOADER"
}
]
}```
this is the api
what are you trying to get?
i can get tag, name, easily
cuz they are above
im trying to get those brawlers array fully
how to get each brawlers data and its properties
<APIresponse>.brawlers is an array
by using Array.map or just looping through it
you can loop through it with .forEach / for
smone says to use this
const res = await fetch('https://api.brawlstars.com/v1/players/%23P2U0GVJP', { method: 'get', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer <my token>' } });
const data = await res.json();
async data.brawlers.forEach((b) => {
console.log(b);
});
That async shouldn't be there, other than that, sure
if i remove tht async, it says await is valid only with async
just think of a JSON being a folder structure
ok....
. gets a file/folder
so let's say name of the first brawler
it'd be brawlers[0]/name if it was a folder
so brawlers[0].name
ok so if i swap .startsWith with .includes, it works if im looking for the role, but when i try list every member it only works if i use .startsWith
ohh ok, then?
now you just need to iterate over the contents of brawlers folder, because it doesn't have a single file but many unnamed folders
yeah, that ^
what
nice channel
@drifting axle
ye
it cancels because you're stating a fixed transform for the element
I removed it but it still does not work
try changing translatey to translateY
Any npm lib to generate qr codes?
Yes, qrcode
lol
flaze the entire time I had my mic unmuted, I was confused on why my db wasn't saving, turned out I was saving to the wrong collection
my reaction:
flazepe swooping in with a damaging left "gOoGlE iT" hook.
Thanks
lol i use heroku for bot hosting, the database just sorta died, like whenever i add a database, even an empty one, the whole bot just stops working now and i have no clue why
heroku isn't meant for bots so ๐คทโโ๏ธ
rent a cheap vps
it costs you less than a mcdonalds trip
How
Most people would have the money
It's just the payment method that could be a problem
both glitch and heroku said publicly that they aren't meant for bot hosting
VPSes are SO cheap
glitch banned auto-pingers
Which anyone can get 90 days free
yes they do
they do?
yep
there's a "database" tab on the left when you're in the repl editor
Heroku is nice
can't miss it if you look
I hosted my bot on Heroku until recently where I moved to a VPS
Heroku is actually good if you can use it properly
I had Puppeteer working
you got a vps?
which tier from where?
ok dms
why i have black line above
<html>
<body>
<style>
.entity-header__image {
border-radius: 50% !important;
/*border: 3px solid gold;*/
animation: float 5s ease-in-out infinite;
}
@keyframes float {
0% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
50% {
box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
-webkit-transform: translatey(-30px);
transform: translatey(-30px);
}
100% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
}
</style>
<h1>123</h1>
</body>
</html>
ok
@drifting axle thats the percentage, when your bot will be approved
Ok thanks
iframes
how lol, I am really css and html new. I have the link and want this as my top.gg page
yes
aprix you've been on the development channel ever since you sent that "banned item" screenshot
xD
thx, what should I take as height?
You can omit it
Only src is needed
what do you mean by "omit"?
<iframe id="inlineFrameExample"
title="Inline Frame Example"
width="300"
height="200"
src="https://hackmd.io/@meister03/mpdb">
</iframe>
``` I have this , I want that it fits in the page
lol, I know what the word means xD. Did you meant I should leave the height away?
<meta name="viewport" content="width=device-width, initial-scale=1">
do i need this?
Just...remove it?html <iframe src="https://hackmd.io/@meister03/mpdb"> </iframe>
you can also try a width and height of 100%
guys i have a question, if i apply my bot for verification, will it look fishy that a lot of the servers the bot is in are by the same person?
isnt there a minimum length on characters?
You can add random characters to bypass that, it's allowed
yes, you'll get an "inorganic growth" error, and won't be able to verify
As long as your iframe has content
how will I do this lol?
it is whole docs lol
ah, okay lol
i need help
hmm does anyone know the autoresponder discord js module
They live the shame by pretending rounded borders are cool
seriously mac is so unusable
it treats you like a baby so much to the point it's unusable
what should i do if the servers aint mine
leave them.
yes. make the bot leave the servers
how do you do that
guild.leave() in discord.js
and how do you choose what server to leave
You'll have to figure out how to find the servers owned by the same people and leave them, that's... not trivial and cannot be answered with one line of code
something like "search guilds for duplicate owners, sort them by how many servers one owner has, leave the extra ones" or something like htat
if the servers are by different people then is it still inorganic growth if my bot randomly grows
inorganic growth = one or more server owners have your bot in multiple of their servers
that's all it means.
the other is suspicious growth, which basically translates to "oh you poor thing you got to 100 because you're on top.gg, well, deal with no growth for a few weeks"
@umbral zealot how many servers per person does not look fishy
Discord has not and will not release the exact numbers on that
otherwise it would be too easy to game and get around
@umbral zealot the thing is i was spreading word about my bot and one of them really liked it and made a bunch of servers