#development
1 messages · Page 1384 of 1
oh yeah that would probably help dealing with noobs. good idea.
this is actually the time of editing
but yes im a bit tired
@opal plank Oh im fucking dying
fetch(jamieson.bottle())
"noobs" who are you calling a noob
@opal plank which language did you think this was 😂
It literally says on the link i sent
U wot
What if i switch to TS
come to the dark side, we got donuts and typed objects
come swim in our integrated wiki and docs
Come to the darker side, we have cookies
Ah yes, errors hmm... Delicious
better fixing errors while you coding than waking up the next day every 5AM with users dm'ing and flooding your ticket system with bug reports

It's 2 am and I'm making this function in first try, bruh moment?
well, currently
there will be bugs
and then you'll come crawling
ts would babysit you
just saying
There was no bugs though xd
Why is it called the dark side though
It's also super strict and causes a lot of headaches, your dark side.
strict good
Isn't it supposed to be light side or whatever because ts is better
too much flexbility and you have it doing shit like
10 * '2' returning 20
"better" is all about perspective. It's not better, it's different.
It's just JavaScript with type guards
Of course you would argue it's better, since you use it and you love it
I don't, and I don't think it's better.
too much flexbility and you have it doing shit like
10 * '2' returning 20
@opal plank Can't JS already do that
i may be biased, yes, though comparing the two, ts is better, even with the drawbacks of typing more
adding a colen and a type isnt that hard
for the benefits it yields
not even talking about the shipped docs and declarations with most of the libs
popular* libs
Welp, i think i have answered my own question, it's the most efficient paginate function, big win win
too much flexbility and you have it doing shit like
10 * '2' returning 20
@opal plank uhm... but that's... the correct answer...
you are still multiplying strings with numbers
Javascript is a loosely/dynamically typed language, this is by design.
indeed, which is what makes its bugs unbelievably hard to ctach beforehand
you'll spend 80% of your time debugging stuff, later on when you are experience you'll still catch quite a few bugs
Sure, but it's a choice that's been made, saying it's wrong is an opinion, not a fact.
im not saying its wrong
im saying ts is better
it shouldnt multiply strings by numbers
even though it does
while my example is lacking, stuff like that can cause bugs in code quite easily
ts reminds me of the python 3.6 update where you can optionally use static types
by saying TS is better you're saying JS is worse.
so i am back
i found no help
You may as well not use JS at that point
If you wanna use TS, use it, but I'm not going to be convinced.
you guys are useless
thanks
@earnest phoenix no u
help with what
@split hazel can u ban that guy, pls?
already too much drama
or a warning at least
fgor the love of god
so some guy just gave me some code randomly
@support.error
async def support_error(ctx, error):
if isinstance(error, discord.ext.commands.errors.CommandInvokeError):
await ctx.send(
f"<@!{ctx.author.id}>, the AI chat bot doesn't have all day for you, the support AI is now disconnected")
elif isinstance(error, discord.ext.commands.errors.CommandOnCooldown):
em = discord.Embed(
title="The AI bot is under heavy use, so you have to wait 5 minutes to use it again.",
colour=discord.Colour.red()
)
cooldowntime = '{:.2f}'.format(error.retry_after)
cooldowntime = float(cooldowntime)
cooldowntime = cooldowntime / 60
cooldowntime = round(cooldowntime)
msg = 'Please try again in {:.2f} seconds'.format(error.retry_after)
em.add_field(name="Cooldown : 5 minutes", value=f"{msg} or around {cooldowntime} minutes")
await ctx.send(embed=em)
else:
raise error
so you WERE spoonfeed? nice
ok and?
what is this
It's code
^^
@opal plank Multiplying string by numbers?
hELp cTrL C CtrL V doesnt WORK
Or did you mean something else
If you want to know what that does @earnest phoenix you'll need to actually stop being lazy and learn python
@opal plank Multiplying string by numbers?
@earnest phoenix any other compiler would screech at you for multiplying different types. number * number
i am in process of learning python
It would make coding a bot in python a lot easier if you knew the language you were trying to use
bruh
It would make coding a bot in python a lot easier if you knew the language you were trying to use
@umbral zealot this
string * number can be helpful
Learning a language while making a bot is bad. Learn the language first, then make bots. Bots are hard.
i have 3 years experience in c#
for larger projects i prefer ts since it catches so many more bugs at compile time
python is ez
for example, Python uses it for repetition
Apparently it's not ez enough for you to make bots
and intellisense is much more reliable
Python iz ez yet you still don't know perfectly
so maybe... like... go through a couple python tutorials
I've been doing JS for 20 years, doesn't make me a C# expert either
I've been doing JS for 20 years, doesn't make me a C# expert either
@umbral zealot wait how old are oyu
40
learn the language first rather that coming here asking for spoonfeed code and then taking a piss and the people who were trying to help you
#development message
#development message
i am 14
Great. learn to learn shit
yes
and stop being an entitled little tyler
^^
i need python for my penetration testing course
go. learn.
so i am learning it
Great so go learn python, not bots.
I KNOW python
if you knew python you wouldn't be here
No you don't know python.
bruh
if you knew python you wouldn't be here
Why are you learning python if you know python
if you knew python you wouldn't be here
@split hazel i know about python but i dont know about discord api ok?
🗿
how is a command handler with cogs related to discord api?
Why are you learning python if you know python
@earnest phoenix i am practicing it
if it handles everything ofr you?
i dont know
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=cooldown#discord.ext.commands.cooldown this is basic py, nothing related to api
ok i am done with discord bots
lol
bye
We went from databases to the programming language itself to the library and you want cooldowns but how are we going to help you if you weren't able to get it from the official discord.py server?
they gone already
🗿 Why are we hurting our brains in this channel
peace at last
i wouldnt even waste time with him tbh, even though im a hypocrite for doing just that
hi Tim
yes, we all dumb
hi tim you came at the right time before you lost cells
xDD
not like we'd be better tham him before this convo started anyway

tim too big brained
care to explain what happened in that previous conversation that caused you to lose brain cels?
we are too smoothed brained
the usual entitled skid that pops up every now and then that gets triggered because we dont spoonfeed him
tldr
Lemme explain you this in a few words
Little tyler that doesn't listen at all
the best is just explaining code in real words
so then they have to either beg for code
or decipher it
hence why i love providing snippets in TS for JS users
LOL
i just wait and bait them to come back asking WHY IT ERRORS??
We literally told him everything we could mate
lmao
how dare we give them docs, snippets, databases, free databases, advice and everything else but NOT give gim spoonfed code that he can just copy paste
we clearly the bad guys

yes, you are the bed guys
LOL
bed guys
bed
hmmmm
Seems sus
yes
because you put the kid to sleep
oh my how lewd
too bad, another 10 minute effort bot that wont see the day of light again
im gonna have trouble sleeping tonight
His brain malfunctioned so hard he fell asleep
i feel like im being too toxic, imma grab some booze and chill with dem animie ti...tles of very good series
Weeb
someone needs to make a tutorial on using google
and pin it here
tbh
can you buy .google domains?
That guy wouldn't even know what a "google" is
because how.to-use.google would be good
I don't think .google domains even exist
they do iirc
unless it is just chrome playing tricks on me
Find your place online with a domain from Google, powered by Google reliability, security and performance.
nope I don't think it is chrome lying to me
How do i make a const on python 
How can I get data from this site? https://www.techpowerup.com/gpu-specs/?ajaxsrch=3080 or can i convert to json format?
this doesn't look like api
const is a javascript keyword lol
web scrap maybe idk
@earnest phoenix use any scraper you want to use
@drifting wedge what type of pie is py?
snake pie
let fetched;
do {
fetched = await message.channel.messages.fetch({ limit: 100 });
message.channel.bulkDelete(fetched)
.then(async () => {
let msg = await message.channel.send(":white_check_mark: | Successfully deleted all the messages in <#" + message.channel + ">");
msg.delete({ timeout: 3000 });
})
.catch((err) => {
message.channel.send("The messages in this channel are too old for me to delete");
});
} while (fetched.size >= 2);
``` how can i end the loop if the msgs are too old?
I need help for canvas not work createLinearGradient, can someone help me ?
whats the pip for googleapiclient?
How do you check if your bot has a specific perm?
Read the docs of the lib you're using ig
ALTER TABLE Users RENAME TO Test; I'm trying to do this but it says users relation is not found. The table name is Users so I'm not sure why this is happening.
What db is that I am curious @reef carbon
postgresql
K
on what?
How do i add a custom background to my bots page, plus how to i change the CSS of it ?
@blissful coral i did that and it did nothing
lol
.botimg {
border-radius: 50%
}
learn css
but the variables will be different due to the site
like i wouldnt have been able to know it was .botimg
oh, you mean the selectors
yes
the classes?
yeah
it actually depends
the css only works on your bot page
you can't, unfortunately
do you know how to change the background of the page?
change background-color of the body tag
ah
createLinearGradient is not working In nodejs GRRRRRRR
wasnt changing
add a semicolon, just in case
where?
at the end of background-color
Hi people
that didnt work
What?
do {
fetched = await message.channel.messages.fetch({ limit: 100 });
message.channel.bulkDelete(fetched)
.catch((err) => {
message.channel.send("The messages in this channel are too old for me to delete");
});
} while (fetched.size >= 2);
``` how do i stop the loop in the .catch()?
You'd need to use a try/catch block.
Wrap the expression in the try {...} catch (err) {...} block, await in the try block for message.channel.bulkDelete(...). You'll catch the error and use break in the catch block.
You could expand it to also cover the awaiting you're doing for fetched.
let fetched;
do {
fetched = await message.channel.messages.fetch({ limit: 100 });
try {
await message.channel.bulkDelete(fetched);
} catch (err) {
message.channel.send("The messages in this channel are too old for me to delete");
break;
}
} while (fetched.size >= 2);
message.channel.send(":white_check_mark: | Successfully deleted all the messages in <#" + message.channel + ">")
.then(msg => msg.delete({ timeout: 3000 }));
``` how do i do it so the message.channel.send("✅ | Successfully deleted all the messages only comes after the do while loop
tell dank memer to hire me now
let fetched;
do {
fetched = await message.channel.messages.fetch({ limit: 100 });
try {
await message.channel.bulkDelete(fetched);
} catch (err) {
message.channel.send("The messages in this channel are too old for me to delete");
break;
}
} while (fetched.size >= 2);
message.channel.send(":white_check_mark: | Successfully deleted all the messages in <#" + message.channel + ">")
.then(msg => msg.delete({ timeout: 3000 }));
``` how do i do it so the message.channel.send("✅ | Successfully deleted all the messages only comes after the do while loop
@silver lintel i think you could do setInterval
idk tbh
dank memer should obviously hire me
Setinterval sets intervals
@silver lintel lmao i realised that
so a function executes after time
if u used setinterval it would repeat ever amount of time
im big brain
you could use setTimeout()
but it would be better to use a function that loops over it until there are 0 left to delete then send a message
hi
show prop.help
Hi, i have a school assignment that i have to complete and it's js. I have to create something like this but im not sure how to do it. https://cdn.discordapp.com/attachments/681893466682425407/777018111659474954/unknown.png
Im given this code and i have to complete it https://cdn.discordapp.com/attachments/681893466682425407/777018372520673280/unknown.png
U love it ? Tackerr spotify by me xD
cool
Cool i am noob so i use bot ghost
Hi
Hi
What?
?
'-'
why does a url can be accessible with http but not with https? (im using cloudflare and im new to it)
https is secure and has some requirements
it normally means it is able to be trusted
Btw
why does a url can be accessible with http but not with https? (im using cloudflare and im new to it)
@clever dust
You haven't enabled ssl
I told you
Or it's either at lowest level
In cloudfare
It should be either at flexible
Or strict
But not the most strict
Because it won't work
As you are using GitHub for hosting that's why
As you are using GitHub for hosting that's why
@delicate shore i don't
at my home
Are you sure ?
yes
Hmm wait
Alright I know this is basic JavaScript but I'm gonna ask
I have an array
And for each value of it I need to add a link in descriptionOf the embed Like array has - ['one','two']
So in discord embed in description it adds something like this -
First - one
Second - two
Do I need to map them first ?
Or what's the scenario
array.map(item => item + '\n')
i want to do a verification system only for my server
code looks like this
if(cmd === `${prefix}verifyen`){ if(message.deletable){ message.delete() } let role = message.guild.roles.cache.find(role => role.id === `775390638270578708`); let otherrole = message.guild.roles.cache.find(role => role.id = `775581337976963133`); if(message.guild.id == `775388232233517076`){ try{ message.member.roles.add(role); message.member.roles.remove(otherrole); message.member.send('Thank you for verifying! Enjoy your time in BraceDash!') } catch(err){ const embed = new Discord.MessageEmbed() .setAuthor('Oh no!') .setTitle('An error occured while running this command!') .setDescription(`${err}`) .setColor('RANDOM') .setFooter("DM my Dev to solve the error! (<owner)") .setTimestamp() message.reply(embed) } } else{ return; } }
it removes the otherrole
but doesn't add the role
what should i do in this situation
nvm i solved the problem
array.map(item => item + '\n')
@proper bolt
Thanks
They stopped inviting bots.
why is that
Discord now allows on 50 bots per server.
Okay thanks ❤️
Discord now allows on 50 bots per server.
@normal sage not yet..no official statement either
Oh ok
Hi everyone!
So I was helpfully recommended yesterday to use webscraping for my bot bye another member in this discord. I'm trying to make a discord bot (using discord.py) that would scrape images and text from websites. To be specific, it would scrape recipes from websites such as allrecipes.com or shoutabkhin.com and then display them inside discord.
I was wondering how exactly this would work. Does Discord's API have features for web scraping? Is there a way to do it in python or would I need to use a language such as javascript using discord.js? If anyone has any ideas or knows a helpful guide, it would be greatly appreciated. I've been trying to figure this out but can't find a way to do it. Is there a specific library I need to import? Language I need to use? Method to look into? Any help would be really nice as I can't find anything on this specific topic, since I've never used webscraping before.
You should probably look into the aiohttp module for async webscraping
Thanks a lot
You should probably look into the
aiohttpmodule for async webscraping
@hollow sedge also beautifulsoup
and does the website I'm scraping need to be in a certain format/language
You should also look into an API/API wrapper that can just get the recipes with easy usage
with requests
as in can I scrape PHP and HTML websites?
@proven cliff I’ve seen someone make something like this.
no requests, requests is not async
oh
So you want their discord @?
not really cause I'm trying to figure out myself and actually learn how to do it
no requests, requests is not async
@hollow sedge i use requests for web apis
I don't like copy pasting code if I can't replicate it myself organically
But thanks for the help guys
I'll look into both beautifulsoup and aiohttp
@hollow sedge i use requests for web apis
@earnest phoenix ok, but it shouldn't be used for discord bots
As they are async
It will block the event loop and everything else will have to wait for it to finish
I'll look into both beautifulsoup and aiohttp
@proven cliff they're not mutually exclusive, you would typically use them together
It would, but it wouldn't be good to use
I hope you find a solution
me too lmao
how do i authorize myself? didnt understand properly. Like what does http authorization header mean? (in dbl)
you send your API key as a Header with the API request
to authenticate yourself to the API
Hello, can I ask something
what ?
read the channel topic
Just ask
hey my foreach code working only once did anyone know why
provide more context with your issue
{
if (message.content.startsWith('update'))
{
var channels;
channels = message.guild.channels.cache.forEach(gtg =>
{
// <Code>
});
};
})```
it is only working for one channel
hi
message.channel.createMessageCollector(filter, {time: 120000, max: 10 })
here
like you have max: 10
is there anything you can use to find a certain message from 10 messages
in py
using the bot.wait_for() coroutine
i dont need message collecter
it is for updating permissions
@earnest phoenix can you help
Anyone Uses BCFD?
i need to know what you're doing inside of the forEach
i need to know what you're doing inside of the forEach
@earnest phoenix updating permissions for a role in all channels
yes
thonk
it have administrator
it should work fine
help pls
What language do you use?
I mean the coding language
No like javascript python
JS?
ı dont use python
It looks like javascript
That why, what is your coding language?
yeah
It looks like javascript
Yeah
Okay
@earnest phoenix Can you look at this please this is not the type of JS I use as mine is a database js which changes alot of the script for it to work
@earnest phoenix Can you look at this please this is not the type of JS I use as mine is a database js which changes alot of the script for it to work
@knotty quartz oke, wait
Thanks
@rain obsidian can you please screenshot your logs like on terminal?
you need to declared the variable "args".
Let me write 1 in the args part
👍
Please learn js
@rain obsidian show more code
You should probably remove that last )
let collection = client.users.cache.filter(user=>user.id===`${top5[0].ID.split('-')[1]}`);
var winner1 = collection.first().tag;
var winner1msg = top5[0].data;
}
if(top5[1]){
let collection = client.users.cache.filter(user=>user.id===`${top5[1].ID.split('-')[1]}`);
var winner2 = collection.first().tag;
console.log(winner2)
var winner2msg = top5[1].data;
}
if(top5[2]){
let collection = client.users.cache.filter(user=>user.id===`${top5[2].ID.split('-')[1]}`);
var winner3=collection.first().tag;
var winner3msg = top5[2].data;
}
if(top5[3]){
let collection = client.users.cache.filter(user=>user.id===`${top5[3].ID.split('-')[1]}`);
var winner4= collection.first().tag;
var winner4msg = top5[3].data;
}
if(top5[4]){
let collection = client.users.cache.filter(user=>user.id===`${top5[4].ID.split('-')[1]}`);
var winner5=collection.first().tag;
var winner5msg = top5[4].data;
}
if(top5[5]){
let collection = client.users.cache.filter(user=>user.id===`${top5[5].ID.split('-')[1]}`);
var winner6=collection.first().tag;
var winner6msg = top5[5].data;
}
if(top5[6]){
let collection = client.users.cache.filter(user=>user.id===`${top5[6].ID.split('-')[1]}`);
var winner7 = collection.first().tag;
var winner7msg = top5[6].data;
}```` so this is my code , top5 is a array from quick.db but it returns this error ``*Cannot read property 'tag' of undefined ``
can someone help me?
is your collection valid?
i mean it is
but everytime i restart my vps it becomes invalid
then i have to clear all the data on quick.db to get it back working
well the collection gets reset every time you restart
and the restart seems to corrupt your DB
what host did you use? a paid one or a free one?
paid vps
quick.db is the db
yea but how did you collect the data
every time they send a message it adds 1 to the key messages-authorid
so you get a ton of duplicates
or did you increment the number by 1
ohh yea i know what your issue is. when you restart your VPS the cache gets released
what steps should i take then?
store the userids and then fetch the winner
fetch will get him back into the cache and then you can use .tag
yes you get it from the cache. the cache will only give you the userid not the full userobject
bcs the user is not cached after a restart
ah ok so u want me to save the user instead of its id righ?
no you store the id then fetch the user to get the userobject
thats what i do?
fetch(userid)
give me a sec
after you fetched the user once you can use the cache normally
if(message.content.startsWith(prefix + "purge")
let amount = parseInt(args[0])
if(!message.member.hasPermission("MANAGE_MESSAGES")) {
return message.channel.send(`You do not have perms`)
}
if(!amount) {
return message.channel.send(`Specify amount`)
}
if(isNaN(amount)) {
return message.channel.send(`Valid amount`)
}
message.delete()
message.channel.bulkDelete(amount, true)```
what is wrong in this guys?
what did you want to accomplish?
see now
did you get an error?
also you dont need 2 message delete. iirc use your amount + 1 to remove also the command message.
where bro?
its just a notice not important for now
await msg.channel.messages.fetch({ limit: amount + 1}).then(messages => { // Fetches the messages
msg.channel.bulkDelete(messages // Bulk deletes all messages that have been fetched and are not older than 14 days (due to the Discord API)
)});
did you tryed something like this?
there are some API limitations. max 2 weeks old and max 100 messages
did you know how to write stuff in js?
then you should know where this 2 lines of code go
what does await do btw?
this makes it async -> waits for it to complete
i dont do DMs bcs people expect more there
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('../config.json')
const command = require('./command')
client.on('ready', () => {
console.log('The client is ready!')
command(client, 'ping', message => {
message.channel.send('Pong!')
})
})```
so for couple days i getting that error 'cannot find module discord.js' but i installed so many times,
```js
const Discord = require('discord.js');
const client = new Discord.Client();```
i already did this but same error... i need a help
did you ran npm install discord.js?
yes
delete the node_modules folder and run npm install. this will delete all installed modules and installs them again
this helps sometimes
did you moved the folder?
npm i discord.js?
PS C:\Users\Lenovo\Desktop\command> node index.js
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'discord.js'
Require stack:
- C:\Users\Lenovo\Desktop\command\index.js
hmm try npm remove discord.js
then npm install discord.js
hi
async def spawn(caught):
if caught == False:
msg = await bot.wait_for('message', check = check)
if "p!c" in msg.content.lower():
if msg.content.lower() == f'p!c {pkmn_list[rand_no][0]}':
await message.channel.send(f"Congratulations {msg.author.mention}! You caught a {pkmn_list[rand_no][1]}!")
caught = True
return True
else:
await message.channel.send("That is the wrong pokémon!")
caught = False
await spawn(caught)
else:
await spawn(False)
def check(m):
return caught == False
while await spawn(caught) == True:
caught = True
i have all of this
and shouldnt the value of caught become True as per the last line.. if first it goes into an else block in def spawn() which recurses it causing it to end up becoming true when it goes into the if block
cuz if it goes into an else block even once it does not change from False to True ever
plz help
py?
hey guys
const name = getName(raid.pokemon_id);
const lat1 = raid.lat.substring(1);
const lng1 = raid.lng.substring(1);
console.log(name, + "\n" + raid.gym_name, + "\n" + lat1, + "\n" + lng1);
return `${lat1}, ${lng1}\n`
+ `**${raid.gym_name}**` + "\n"
+ `**Raid level: **${raid.level} | ${name} | **Pokemon Cp: **${raid.cp}\n`
+ `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
+ `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
+ `http://www.google.com/maps/@${lat1},${lng1},6z`
});
const reactionEmoji1 = message.guild.emojis.cache.find(emoji => emoji.name === 'valor');
const reactionEmoji2 = message.guild.emojis.cache.find(emoji => emoji.name === 'mystic');
const reactionEmoji3 = message.guild.emojis.cache.find(emoji => emoji.name === 'instinct');
if (timer !== null)
{
clearInterval(timer)
}
timer = setInterval(async ()=>{
if (responses.length > 0)
{
let msg = await message.channel.send(responses.shift());
await message.channel.send(exampleEmbed);``` as you see lat1 and lng1 and even the embed are defined outside the scope they are called in. How do i fix it?
as of now, it is saying lat1 lng1 undefined
where did you get the error?
in the .setDescription
as lat1 and lng1 are defined outside the scope they are called in
but how should i approach this problem?
i dont see anywhere .setDescription
set it at a higher scope or use var, but var is not really the thing you want. you could also use a function
console.log(name, + "\n" + raid.gym_name, + "\n" + lat1, + "\n" + lng1);
return `${lat1}, ${lng1}\n`
+ `**${raid.gym_name}**` + "\n"
+ `**Raid level: **${raid.level} | ${name} | **Pokemon Cp: **${raid.cp}\n`
+ `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
+ `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
});
const reactionEmoji1 = message.guild.emojis.cache.find(emoji => emoji.name === 'valor');
const reactionEmoji2 = message.guild.emojis.cache.find(emoji => emoji.name === 'mystic');
const reactionEmoji3 = message.guild.emojis.cache.find(emoji => emoji.name === 'instinct');
const exampleEmbed = new Discord.MessageEmbed()
.setColor('RANDOM')
.setDescription(`[Google Maps](http://www.google.com/maps/@${lat1},${lng1},6z)` + " | " + `[Apple Maps](https://www.apple.com/maps/?daddr=${lat1},${lng1})`)
.setFooter("Command Created For Pokehub!")
if (timer !== null)
{
clearInterval(timer)```
var ignores the scope
const is also static?
var is more or less deprecated but still there to keep older software working
hmm okay great!
py?
@lusty quest yea
thanks
cant help you with py @vale garden
oof ok
hi
well my problem was fixed
but i have another question
@bot.command()
async def pick(cmd, choice = None):
pokemon_choices = ('Charmander', 'Squirtle', 'Bulbasaur')
if choice.lower() in pokemon_choices.lower():
i have all of this
to check if the any element of the set pokemon_choices in all lowercase is equal to arg1 in all lowercase
now if that is true
how can i find the index of the arg1 in the pokemon_choices set
@eternal osprey
that is my question
use case statements
wdym
yea ik i can check it like that but is there a quick way
to just get the index
lol
why don't you use dict? with the pokemon names being the keys
also that is tuple, not set
const prefixes = ['<', '/', '%']
prefixes.forEach(async prefix => {
//rest of code
})
My bot responds 3 times because of the prefix being an array, is there a way to fix that?
just use index method to get the index of it, pokemon_choices.index(choice.capitalize())
guys
i jsut solved the problem
i listened to you and actually read the code
and it was easy
YES
now i can publish my bot
wait imma try a for loop
msg.guild.member(person).kick().catch(() => {
return msg.channel.send(`I could not kick ${person}`)
}).then(() => {
if (msg.guild.member(person)) return;
else return client.emit("newcase", {
type: "kick",
channel: msg.channel,
offender: person,
timestamp: msg.createdTimestamp,
reason: reason ? reason : "No reason provided"
});
});
```this code is supposed to try to kick a member and then check if theyve been kicked, if they have then emit newcase to the client but it doesnt emit even if the person is kicked
it works for my ban which has virtually the same code
Kick doesn't use a reason for standard
w
I have a question: I want to programm a python discord bot but get_all_members doesn't really work anymore
for member in client.get_all_members(): print(member)
´for member in client.get_all_members():
print(member)´
have you enabled member intent?
^
it is turned on! Or is it the wrong one?
give it a couple mins
open the link, you gotta pass Intents object with members set to True to intents kwarg of discord.Client or any class that inherits it
Ohh I found the solution! I only turned on the Presence Intent to and now everything workes fine. Thank you for your help and time👍
open the link, you gotta pass Intents object with members set to True to intents kwarg of discord.Client or any class that inherits it
@earnest phoenix
msg.guild.member(person).kick().catch(() => {
return msg.channel.send(`I could not kick ${person}`)
}).then(() => {
if (msg.guild.member(person)) return;
else return client.emit("newcase", {
type: "kick",
channel: msg.channel,
offender: person,
timestamp: msg.createdTimestamp,
reason: reason ? reason : "No reason provided"
});
});
```this code is supposed to try to kick a member and then check if theyve been kicked, if they have then emit newcase to the client but it doesnt emit even if the person is kicked
lemme just bring it back here so its annoying everyone else
let fetched;
do {
fetched = await message.channel.messages.fetch({ limit: 100 });
try {
await message.channel.bulkDelete(fetched);
} catch (err) {
message.channel.send("The messages in this channel are too old for me to delete");
break;
}
} while (fetched.size >= 2);
message.channel.send("✅ | Successfully deleted all the messages in <#" + message.channel + ">")
.then(msg => msg.delete({ timeout: 3000 }));
``` how do i do it so the message.channel.send("✅ | Successfully deleted all the messages only comes after the do while loop
why don't you use dict? with the pokemon names being the keys
@earnest phoenix oh yea thats a good idea
thx
@pure lion put .then() before the .catch()
also it wont read when someone joins and leaves, im assuming i need an intent
But if you do then before, it will catch
If you think about it, catching catches he problem, but then will run after
ohhhhhh sgbjjiksdgh noted
yea joining leaving needs an intend
so catch always goes at the end
yea joining leaving needs an intend
alr
whats the name in so i can add it in the bot files
server members added
alright so
const client = new discord.Client({ws: {intents: ["GUILD_MEMBERS"]}});
```i did that
and now kick doesnt work
the message event broke

const prefixes = ['<', '/', '%']
prefixes.forEach(async prefix => {
//rest of code
})
My bot responds 3 times because of the prefix being an array, is there a way to fix that?
@stable eagle what is rest of code
Uh, well executing command
youre executing the command 3 times
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName)
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return;
try {
return command.execute(message, args)
} catch(err) {
errembed.setDescription(err)
message.channel.send(errembed)
}```
yeah it executes it 3 times
I dont see why tho
just do
if (prefixes.some(p => msg.content.startsWith(p))) {
// execute command
}```
^
can someone tell me why my message event broke when i enabled the guild members event
You would literally only have to change one line of code
which
Sorry talking to Milo
ah
no
join pls
@weak parrot h
no firends to play with
Not really the server for that
join pls
Dude
lmao
or the channel for that matter
Channel doesn't matter just not this server in general
so yeah can someone help me, the message event just broke
because i enabled the GUILD_MEMBERS thing™️
does anyone have a tip for multilanguage support in bots?
like a DIY guide or anything?
the problem is how do I have the other languages
I know that C/P'ing the code but with another language is dumb
uhh code
probably most of the users are uncached or something
and ur fetching every single one
Oof
- that loop isn't asynchronous
How can I set the permission my bot need
In oauth2
Ok
try asynchronous loops
smth like this ```js
async function processArray(array) {
array.forEach(async (item) => {
await func(item);
})
console.log('Done!');
}````
async
instead of sync
can someone help me with my bot, i enabled the guild members intent and it works, but the message listener seems to have stopped working
For discord api requests, is it 50/1s per client, or 50/1s per shard
smth like this ```js
async function processArray(array) {
array.forEach(async (item) => {
await func(item);
})
console.log('Done!');
}````
@restive furnace this wouldn't even work
you can't use async in forEach(), you need a for loop
For discord api requests, is it 50/1s per client, or 50/1s per shard
not sharding, the bot is is one server
@low orbit
you might have to get it from id unfortunately, but im not an expert in mongodb
oh nice lool
Does anyone know an api which retrieves famous people? Like, their name, birthdate etc.
@stable eagle https://github.com/daxeel/CelebInfo-API
Unofficial API of famousbirthdays.com. Contribute to daxeel/CelebInfo-API development by creating an account on GitHub.
ty
np
var output = await message.channel.send(`\`\`\`js\n${clean(code).replace(client.token, "-")}\n\`\`\``)
await output.react('❎')
const filter = (reaction, user) => user.id !== message.client.user.id && user.id === message.author.id;
var collector = output.createReactionCollector(filter, {time: 60000});
collector.on("collect", (reaction, user) => {
if (collector && !collector.ended) collector.stop();
switch (reaction.emoji.name) {
case "❎":
reaction.users.remove(user).catch(console.error);
output.delete()
break;
default:
reaction.users.remove(user).catch(console.error);
break;
}
});
collector.on("end", () => {
output.reactions.removeAll().catch(console.error);
});
error DiscordAPIError: Unknown Message method: 'delete',
wrong in output.delete()?
it's trying to remove all the reactions although the message doesn't exist anymore
that's why it says unknown message
yeah so the message event still doesnt fire on message
const client = new discord.Client({
ws: {
intents: ["GUILD_MEMBERS", "GUILD_MESSAGES"]
}
});
```here are my intents
also i have the GUILD_MEMBERS intent enabled
and the bot is in one server only
nothing appears in console?
@pure lion you don't need to mention them in current version
Discord api v6 don't need them to be mentioned
Once they shift to V8 then maybe we need to mention it
can someone remind me how to send files without using the MessageAttachment constructor
welcomeChannel.send({attachment: { something like thi-
send({ files: [{ attachment: <Buffer>, name: "image.png" }], embed: { image: { url: "attachment://image.png" } } });
TypeError: Cannot read property 'id' of undefined
at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Unhandled promise rejection: TypeError: Cannot read property 'id' of undefined
at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
why does this happen?
let trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`));
console.log(trole.id);
if(trole){
return message.channel.send("back")}
message.guild.roles.create({ data: { name: 'ME', permissions: ['VIEW_CHANNEL'], mentionable: true } });
trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`));
``` the first times it works, the second times, does not work
and it works in my first server, but not in my seconf server
@pale vessel ```js
async function processArray (array) {
let files = [];
await files.push(array)
for await (const contents of files) {
console.log(contents)
}
}
processArray([2,3,4,5,5])
this could work, right?
there more await the better 🤷♂️
it will probably just log the array itself lol
TypeError: Cannot read property 'id' of undefined at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19) at processTicksAndRejections (internal/process/task_queues.js:97:5) Unhandled promise rejection: TypeError: Cannot read property 'id' of undefined at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19) at processTicksAndRejections (internal/process/task_queues.js:97:5)why does this happen?
let trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`)); console.log(trole.id); if(trole){ return message.channel.send("back")} message.guild.roles.create({ data: { name: 'ME', permissions: ['VIEW_CHANNEL'], mentionable: true } }); trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`)); ``` the first times it works, the second times, does not work
@tired panther the ME role doesnt exist
can you show a screenshot of the role?
and you don't need await for cache.find(), what is it with you people and await lmao
They're awaiting life 
await reaction.message.guild.members.cache.get(user.id).roles.add('777041754268368917');
}
if(reaction.emoji.name === '🎮'){
await reaction.message.guild.members.cache.get(user.id).roles.add('777041546787815424');
}
if(reaction.emoji.name === '777164612197941288'){
await reaction.message.guild.members.cache.get(user.id).roles.add('777162743382933504');
}
if(reaction.emoji.name === '🎁'){
await reaction.message.guild.members.cache.get(user.id).roles.add('777162589095723018');
}
if(reaction.emoji.name === '777165284418387988'){
await reaction.message.guild.members.cache.get(user.id).roles.add('776353743155232778');
}```
why does it only work with the default emojis?
bcs the default emojis are unicode. custom emojis are a little bit annoying to work with
and you look for emoji name not id
I programmed a shop in my bot, but with the categories and pages it has, it now takes 1-2 secs. to answer, cuz I have it all in shop.js
any tips to reorganize it?
I am using a lot of Switches
I have an online DB, but I am using a .json for the shop items so I don't overuse the DB
yea thats the issue i guess
the problem is
json is slow
I don't pay for the host, neither the DB
rip
got no money for that yet
what db did you use? Mongo?
cache it
^
your Shop items
all your items from json
its the same
you just store values in the cache there is no real difference
how is you strategy for reading the Json file?
let me give you a snippet
How do u request if a web site link is there? I mean if it exists?
you want to check if a URL is valid?
yes
@outer perch use hastebin for a ton of code
you need to make a request to the url to check if it's valid
case 'cores':
petHudColorsEmbed = new MessageEmbed(mainEmbed)
.setTitle('Loja Incrível - PetHUDs (Cores)')
.setDescription(`\`${prefix}shop buy pethud [Nome do Item]\` para comprar ou \`${prefix}shop view pethud [item]\` para ver.`)
.setFooter('Página 1 de 1')
.spliceFields(0, mainEmbed.fields.length, [
{ name: 'Black', value: `Preço ¤${items.petHuds.black.price}`, inline: true },
{ name: 'Blue', value: `Preço ¤${items.petHuds.blue.price}`, inline: true },
{ name: 'Brown', value: `Preço ¤${items.petHuds.brown.price}`, inline: true },
{ name: 'Green', value: `Preço ¤${items.petHuds.green.price}`, inline: true },
{ name: 'Orange', value: `Preço ¤${items.petHuds.orange.price}`, inline: true },
{ name: 'Pink', value: `Preço ¤${items.petHuds.pink.price}`, inline: true },
{ name: 'Purple', value: `Preço ¤${items.petHuds.purple.price}`, inline: true },
{ name: 'Red', value: `Preço ¤${items.petHuds.red.price}`, inline: true },
{ name: 'Yellow', value: `Preço ¤${items.petHuds.yellow.price}`, inline: true },
]);
Message.channel.send(petHudColorsEmbed);
break;
use node-fetch as example and call the URL, if you get a valid return it exist, if it errors out the URL is invalid
yea cache your json will probably help. each field will call the json
yep true
so require doesn't cache?
not really
wait nvm require caches
A better approach would be to instead use a combination of fs.watch, fs.readFile and JSON.parse to reload the changing data. No need to fiddle with the cache or restart the server.
An even better approach would probably be to use a database of some sort instead of the filesystem.```
so the problem here may be the amount of Switches and Cases it has
how did you make the pages change? i use it in one of my bots and its fine there
but i also use a Paid Host and run a Database on a 2nd Paid host
so you use commands to show new pages?
the bot goes online on discord?
then the bot is online
or did you want stuff like uptime?
js?
client.guilds.cache.size()
will only update when the bot restarts
hi, i just did something that gives the position to happen. but I would like to do more and have something that gives the name of the user who joined before and after how to do
function getJoinMember(ID, guild) {
if (!guild.member(ID)) return;
let arr = guild.members.cache.array();
arr.sort((a, b) => a.joinedAt - b.joinedAt);
for (let i = 0; i < arr.length; i++) {
if (arr[i].id == ID) return i;
}
}```
Guys, I wanted to ask about your opinion...
I want to make my bot multilingual
So it supports 2 languages
Is it a good way to just make 2 different command for one, but in different languages?
make a json file
Oof
like
{
"WELCOME_MESSAGE": "Welcome message here",
}
That’s dict
But...
What I mean is
Command /help
And command /хелп (the same but in another language)
They work same
But they have different phrases
Maybe not the best way
But I want these 2 commands work at the same time properly
But aliases work the other way?
Like they are just different names for one same command
hi
Like they are just different names for one same command
@strong fractal yes and its easier to do aliases then have loads of commands
much better to maintain and organise
im new to py.. and i have this question
list = [[1, 2, 3], [2, 4, 6], [3, 6, 9], [4, 8, 12]]
if i have something like this

@vale garden 4 lists in a list
yep
ik
so does anyone know, how i can make a new list out of the first terms of each of the inner lists
@honest perch I have no idea how can I work with json etc to make it support 2 languages
XD
C:\Users\nsapo\OneDrive\Desktop\Bot\Revange-Bot>npm run dev
Revange-Bot@1.0.0 dev ``C:\Users\nsapo\OneDrive\Desktop\Bot\Revange-Bot
nodemon ./src/bot.js
'nodemon' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Revange-Bot@1.0.0 dev: nodemon ./src/bot.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Revange-Bot@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\nsapo\AppData\Roaming\npm-cache\_logs\2020-11-14T16_24_52_937Z-debug.log
help ?
does anyone have the answer to my ques?
First term of each list?
Does somebody in here have a good example of a code of multilingual bot?
Like it’s hard XD
help ?
Like it’s hard XD
@strong fractal nah
like this
const userlang = //somehow get the user language from a db
const en = require('./data.json')
message.channel.send(`${userlang}`.WELCOME_MESSAGE);
something like that but i doubt the syntax works
you can use dicts```py
langs = {
"en": {
"welcome": "Welcome"
},
"ja": {
"welcome": "ようこそ!"
}
}
lang = langs["en"]
print(lang["welcome"]) # Welcome```
But...
"en" would be the user language that you fetch from your database/cache
Soo...
i suggest mongodb for things like this
Should I store a language for servers or for users?
depends
users can take quite a space
servers are easier to maintain and only take one document for every server
pymongo is a good one, i heard
not sure since i don't code in python
if shivaco has time, he can probably help you with mongo
best not to disturb him though
Yes
@pale vessel I am so

Is it ok if I just stick with writing different commands with just dame languages
Then I will try to use a json with dictionaries in one command?
Is it possible to send a message to the owner guild when the bot joined the server ?
@sand dune guildCreate event
how can i have the number of file in a folder with fs?
@raw stream try reinstalling the module that is breaking
if this doesnt work make sure the Build tools are installed and install the module that is breaking again
@sand dune owner should be guild.members.cache.get(guild.ownerID) but i recommend fetching it: const owner = await guild.members.fetch(guild.ownerID) (your function needs to be async)
how can i have the number of file in a folder with fs?
@wicked pivot you can usefs.readdirSync(path).length
it's guild.members, not guild.users @sand dune
@sand dune ?
Is it ok if I just stick with writing different commands with just different languages
?
Then I will try to use a json with dictionaries in one command?
?
Sorry wrong person XD
@earnest phoenix use `, not '
Ok
@wicked pivot you can use
fs.readdirSync(path).length
@pale vessel thx

so does anyone know, how i can make a new list out of the first terms of each of the inner lists
@vale garden so out of that 4D you want a one dimension list like [1,2,3,4,5,6,7,8,9]?
or
oh
just flat it or something
[1,2,3,4]?
guys do you know how can i get video thumbnail with ytdl-core
i cant get it can you help me



