#development
1 messages · Page 1490 of 1
wierdchamp
weird
to that stacktrace
and this works fine locally?
It works fine regularly but this error occurs randomly sometimes but rare
But I'm pretty sure its crashing the whole bot (aka 1 shard) which isn't good
this feels like a weird case
I read one site it said maybe its cause I'm not making it ignore the bot in a voiceStateUpdate event but idk if that's the case
maybe make a github issue on the repo of discord.js
pretty sure discord.js has a repo
they probably have answers
maybe ask in the Discord developers discord. there are people that know more
it seems like a known issue
is there a bot which shows live timer with the numbers being updated
it's called a clock
and no, there is no bot that will show time in realtime due to discord ratelimits
Is autoReconnect for the options inside of new Discord.Client(<>) still a thing in V12?
RTFM
where then for you?
It's literally on one site and on other sites it isn't a thing
Don't assume I haven't already read any
It's not even a v11 feature, it's v5 feature at least
So no, it's not a thing, it's supposed to do that by default automatically
😱
I don't usually mix server with bot, I put code for that separately as I like it that way but it's your choice, in your case, it'll be better to put inside ready event I guess since the bot must be ready to fetch the user when they vote
ok
I need an extra set of eyes to make sure i'm not doing something dumb
ok sure
This is where I'm getting the error "Cannot find property: username of Undefined"
for(let u = 0; u < 9; u++) {
let userName = msg.channel.guild.members.get(sortedVotes[u].id).username;
let discrim = msg.channel.guild.members.get(sortedVotes[u].id).discriminator;
topTen.push(`#${u + 1} - ${userName}#${discrim} - ${sortedVotes[u].total} votes`);
}
and this is the sortedVotes array
[
{
"id": "282134235924660234",
"total": 10
},
{
"id": "378842879050776576",
"total": 1
},
{
"id": "547882440711077888",
"total": 1
},
{
"id": "145980073332310016",
"total": 2
}
]
Each of those IDs is a user ID that is on the server, so nobody has left
So I'm not quite sure why its getting this error if it works for some users but not all
It works for me but not for another user
It's members.cache.get, yes, members.get was a thing in discord.js v11 but that can't be used anymore I guess
I haven't touched bots in so long
I'm not using d.js
but should be the same on eris
oh that's eris?
yee
Looks same as djs lol
:>
Are you sure that the member is cached
I'm going to make sure rn by just caching them all
oh I can't read
I am playing a podcast over a vc for users. I have a reaction menu for stopping and playing, and I want this embed message to keep updated w/ how far into the podcast the user is. I currently plan on having a loop update messages with current time played every 40 seconds, plus an additional 20 seconds to the loop for every 2 active players. Is this considered API abuse, or am I in the clear? Should I perhaps increase the intervals at which the messages are updated? @ me when responding please.
remember that discord disabled the guild members intent by default
so your bot no longer gets the online member cache on login like before, unless you explicitly enable server members in your dev portal
Except for members in VC iirc
This bot is only going to be on a single server so I'll make the owner do that
yes, except the bot itself and members in vc
And also you need permission from discord if your bot is in 100+ servers
Like they have to give you access to guild members intent explicitly, not sure whether they do that when verifying bots
when you apply for verification, you need to tell them which intents you need
and if you need members or presences, you need to tell them why you need it
then they will either accept or reject your application
they can for example accept the verification but reject the intent, if they feel like your use case doesnt justify it
If you ask for presence intent/guild members solely for "statistical reasons" (e.g. for a userinfo command), they will most likely decline your request
just say your help command requires both intents and they'll surely accept it
💯
lmao
@opal plank btw i ended up picking a name for my lib, i went with ftset
because fts (full text search) + set
i still think TimmyLib was the better option
lmao
or TimTheDevelopmentMan
Can anyone suggest me a GOOD mongoDB handler for node (something like Keyv)
no idea, i dont use mongo
me neither
then suggest a better Database
"mongoDB handler" 
PostgreSQL/SQLite
i like sqlite
yeah, heroku has free postgres hosting
of course
I use mongoose
same
just an fyi, postgreSQL might be the equivalent of this for you, postgres is great but if you need something simple it might not be the best option, as its a bit too advanced @near stratus
lmfao
can it do mostly everything and scale? absolutely. Do you just need a simple db? go for something else
I'm definitely going for scaling and not simple
then thats the right tool for your job
Cuz last time I did that I ended up with Firebase
i havent used firebase, though i've heard good things abut it
i'll still use postgres though. Cassandra was the only other thing i personally would put on par with postgres simply due to scalability and speed
iirc discord is using cassandra
i think discord moved
I'll try postgre then
they used mongo, moved to cassandra, then idk what happened after
i think they moved to scala
scylla
yo
so
hmmm im not really sure
i havent played with it at all so i cant give any feedback on that
if i require a typescript file would node autocompile it for me
what
no
no?
import for ts
rquire() for js
require() doesnt work on ts
cuz its expecting a module
hmmm im not sure tbh
anyone here using windows terminal
probably not

write everything in ts then transpile to js
I can't type W wtf
mixing js/ts is usually not a good move
W
ts compiles to something i call weird js
in windows terminal
its called optimized js
if you wanna call it that thats fine
lul
but i'm still gonna call it weird js because it's weird
@opal plank well how could i write commands in ts now
make a command struct 
define commands?
i assume bot commands
me too, but i dont get what the issue is
@opal plank the command handler i have literally just requires the file and sets the command data in bot.commands by reading from module.exports
if its module.exports its not ts
if i cant require a ts file... well
its js
i wanna rewrite my bot in ts
COMPILE ALL THE FILES
module.exports is js
basically this is what in tryna do
ight
not require()
you can dynamically call files just like you do with js require, just switch it to import
i should rewrite my commands first tho
recommendation: AllowImplicityAny, and set everything as any
then start switching up after you ported everything
thats just js with extra steps
did you read what i said?
yes i did
clearly not
i was joking
port your code to be lax ts, then add the interfaces after you got everything working into a running state
realistically you'd enable strict and set allowImplicityAny and AllowJs all to false, but doing that mid way of a project is shooting yourself in the foot, you'll be in a whole lot of rewriting if you do that
time to slave away for hours rewriting code
someone writing an essay
typing
@opal plank so if i have this rn:
// Command file
module.exports = { /* ... */ };
// Command handler
for (let filename of fs.readdirSync("./commands")) {
let data = require("./commands/" + filename);
bot.commands.set(data.name, data);
};
kids always remember to put semicolon after object literal and loops
would this be sufficent:
// Command file
export default { /* ... */ };
// Command handler
for (let filename of fs.readdirSync("./commands")) {
import * from "./commands/" + filename as data;
bot.commands.set(data.name, data);
};
pretty new to ts
should do
wont
and yes i did just type my command handler instead of ctrl c ctrl v
aw fuck i lose
import cannot be used like that
h
import() not import

h
wat
like i said, just like require()
import() ?
yes
i've never seen it used in that way ever before.
thanks for saving me
also would i have to compile all my command files before i could use them
right
i forgot the exact error code
well time to do
for (let filename of fs.readdirSync("./commands")) {
if (filename.match(/\.ts$/)) {
// compile the file by running
// tsc filename
// using child process exec
continue;
}
}
¯\_(ツ)_/¯
just compile everything when you compile
what the hell is this
just do regular imports smh
no need to do an index.ts inside a folder
oh are you making a command handler
wrong again
why do you want to call an uncompiled ts file from a js program?
because my command files are ts and i dont want to compile them every single time my bot restarts
make all the bot files ts or none of them
don't mix the two
i already gave code the answer for his problem, dunno whats the holdback at this point
k
you dont have to compile on every restart
you compile once
and then you run the compiled js files
ts files
how about ts-node 
dynamic handler
node.ts
ez
so... only compile index.ts and it can handle the other ts files on its own
how about we dont recompile shit everytime we need to reload commands or restart the bot, like sane people?

yes
i legit said that above
reload commands
use import
webpack + babel and you're set
just like require
ok
oh I wasn't reading the entire conversation
import is promisifyed
if you using babel and webpack to transpile ts dynamically you are doing it wrong
tsc should compile all your ts files and long as you are importing them in your main file
tsc > babel
before we do anything else to my command files
git add .
git commit -m "Pre-Apocalypse Backup"
that's how i got my workflow for my electron app
babel + webpack packs the main and renderer files
and then i obfuscate it all
or you could just use import like i said which is the equivalent of require() without none of the extra stuff you doing
i call that bloating
jsfuck™️
brain got fucked by jsfuck
lmfao
i use webpack-obfuscator which is just a wrapper around javascript-obfuscator
god settings
typescript + webpack for me
@pale vessel how do you update avatars on veldchat when someone changes it?
It's under user:update
uhh
It just gives the new user object
no errors in my code but it seems to hate on discord.js
200 servers before new year perhaps?
no
the genshinutils one
still got around 9h
more for me
ah ok
tsc --no-check-lib or smth
Laughs in ts
wanna know what has good types
ourcord
OU
fuck
auto generated types when
Yea just let ts generate the types
matthew if I rewrite the entire thing will you merge it?
like ourcourd is hardly typed 🧠
as long as it works
why are you making a fake map
well how do i fix it then
idk
@earnest phoenix checkout some compiler flag like --no-lib-check from tsc docs
show your tsconfig file
doesn't exist
{
"compilerOptions": {
"target": "ES2015",
"module": "commonjs",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Recommended",
"exclude": ["node_modules"]
}
hmmm... what's $schema for
other than that everything looks fine to me... I have all those settings enabled and I don't get such errors. Is only discord.js affected?
the exclude part is different tho
no other modules?
Only stinky djs
I dunno
read up you bongo
lazy
cuz u likely didnt install the types
npm i @types/discord.js
Pretty sure discord.js comes with types already
im not sure about that
Hm
it comes with types
importing
and putting @types/discord.js in the repl packager says no results

hey guys. i wanted to add an eval command to my D.py bot. anyone know a good place to find one?
Just use eval()
Use jishaku
rly?
If you want more use jsk
yeah
wow
Best of all code it yourself
It's on python
nice. thx
seperate question. is discord.js better than discord.py?
No
!!Yes
and discord.py is not better than discord.js
they are both trash :^)
can i need a new invite link to use slash commands?
hover over the red dot
What?
use your mouse to hover over the red dot
Why LOL?
what the fuck is that indentation
did you have a seizure on the tab key
It’s saying
SyntaxError: Identifier 'Discord' has already been declared
So uh what do I remove?
and probably copypasted code
bad
@earnest phoenix from the guide
Discord.js guide
🙄
Or library
I just need help...
SyntaxError: Identifier 'Discord' has already been declared ^^^^
Sp what do I remove?
take a guess
“Discord”
correct
Oh yeah lemme show you
Looks like a new error

lmfao
@earnest phoenix don’t you think I tried removing discord before?
lol
this is painfully hilarious
if you took the time to read over the links we sent you...
i mean, the first chapter on evie's guide talks about variables
He said to me to remove discord....
variables cannot be redeclared
you already have a const Discord somewhere in your code, which means which means the name Discord is now taken, you cant use it again anywhere in your program
and you shouldnt need to
So why is it showing error now?
because if you already have Discord somewhere, you just use the one you already have, you dont need to duplicate it
OOOH I GET IT
ding
oh so close
if you already have them somewhere else, yes
because you only need those names once in your entire file
I’m sorry I’m new and I am very dumb I always forget stuff
once you declared them, there is no need to duplicate them
But Tim wanna see something? @quartz kindle
Santa you may want to spend more time learning JavaScript
you're basically trying to write a book in chinese without knowing how to draw the characters
xD
My bot is sending multiple messages when its supposed to send 1, How is this
It just spammed my dms 47 times with hello when I sent 1 message aka 1 command
Inspect your code with a debugger for cases where the same function may be called multiple times.
For example, see if you have listeners nested without properly handling multiple cases of listeners.
We don't know your code base, nor would we like to see it since it may be large.
https://cdn.discordapp.com/attachments/272764566411149314/794286220955877407/image0.png what the fuck is this
js 100
lmao
honestly
its kinda amazing
that some people can't figure this out
and some people can make shit like phones
shows the differences between people
First 500 people will get 2 months of Skillshare free: https://skl.sh/polymatter4
Patreon: https://patreon.com/polymatter
Twitter: https://twitter.com/polymatters
Reddit: https://reddit.com/r/PolyMatter
Discord: https://discord.gg/polymatter
It’s become popular to encourage anyone and everyone to code. But there simply won’t be unlimited deman...
some people just can't think logically, it's a good sign programming isn't for them and they should seek a different career/hobby
programming is part of math and science, which bot of those were created to make more sense of the world
so its a bit strange to me for someone to not understand it at all
im not talking about like C or assembly, I mean js or py
const = require('discord.js')
let client = new const.Client()

I feel like when people pick up coding they think it'll be easier then they think
its hard to jump right into advanced projects
this
its hard what though
people should 100% start with java or some C
people overestimate their abilities because they want to feel smart
^
I prefer the word challenging to the word hard
hard makes no sense
what about it is hard
Yeah
Cry, have you suddenly realised there's such a thing as the Dunning-Kruger effect? lol.
i don't think everyone should code but everyone can code
if they put enough work into learning
and not just ctrl c ctrl v
i actually discovered the topic a few weeks ago lmao
um, any ideas why this happens in console sometimes lol
just randomly on different logged info?
you have a console log somewhere that outputs that 😂 ¯_(ツ)_/¯
are you holding down s?
use the search, luke.
ssssssssssstatus
i have a random log on my bot in a random file and i still have not found it it haunts me
no wait, its my host, its just changed to 'status'
lol, ill report it as bug
It's not a bug it's parseltongue
oh
🙄
ive not seen a harry potter reference for a while
i found the random log it was in my index from a way weeks ago when i was debugging
i always use it
actually my logging function is broken so I do use it once in my index
but otherwise I don't
how is it broken?
well 2 issues
first is that I named logger.js Logger.js in the file
and second is that I need to set defaults for everything
so without method: console.log it breaks
@earnest phoenix I'm late but did you try setting the "allowJs" option to true
where are you from
Antarctica
How use fs and foreach for make handler of commands with subfolders
Hi
Who can help me
You can read all files in a folder and sub-folders using recursion
For example:
function getFiles(folder) {
const filePaths = [];
const allFiles = fs.readDirSync(folder);
for (const file of allFiles) {
const fileStats = fs.readDirSync(`${folder}/${file}`);
if (fileStats.isFile()) filePaths.push(`${folder}/${file}`);
else filePaths.push(...getFiles(`${folder}/${file}`));
}
return filePaths;
}
heroku is real bad don't host my bot for1 week Others servers start removing and kicking my bot
the problem i have no card or paypal
that why i use heroku
ok
there any host for free
if you want a successful bot buy a vps
if you treat your bot as a side-project, continue hosting on heruko
there aren't any good free hosts
good and free host don't go together
.setColor isn't accessing anything
It's not chained to anything
line 113 ends with a semicolon, so it's like the computer asking you want you want to set that color to
not that removing the semicolon will do anything but like
You might want to take a look at what you're doing in that screenshot and rewrite it a bit
Now why is this showing an error..
I want it like dyno reply
Like ?avatar
And an embed text comes and says “AVATAR and shows a picture”
@tame kestrel
And btw why does that have an error?
Thats not how js works
lmfao
Just send an embed with the display avatar url as the image
i admire your perseverance but i cant help to laugh at your attempts to shoot in the dark
@quartz kindle happy to make you laugh LOL
i know you're trying your best, but you're ending up doing some very weird shit
I agree with Tim, I think your best option is to learn more about javascript before you interact with a library like discord.js
embeds have a setImage() method
Wait can I send you the coding and then you can edit it a bit?
nope
Oh
Alr lol
@quartz kindle so if it’s an embed
It’s
In the description LMAO?

dude wtf
😬
@earnest phoenix
the same way there is setTitle and setDescription, there is also setImage
🤔
.setimage?
Use the setImage method
Under setititle?
Thats all
But I don’t know the coding for it
you should learn js basics
Yeah
thats why displayAvatarURL() exists
Add a size to the options
just because its ugly, doesnt mean its not working
You can pass a size to the method options
It has to be a bit nice looking dosent it?
Look - I don't think there's a way to tell you how to do it without giving the code directly to you. So, learn javascript basics first and then start making a discord bot
@mellow kelp how?
@cinder patio fine give me the document today I’ll study on it seriously
yes, but that has nothing to do with your idea that you're setting a fixed url
if you use displayAvatarURL, you're not setting a fixed url
Learn javascript first and foremost
you're setting the person's avatar url, just like you want
I know, but I want a embed reply not just a link and a small picture
If you don't know what that means, learn js
Fine, let’s try
@cinder patio do I read allllll of the documents?
Or just the first top ones?
How much js do you know
Not much ^
The probably start at the introduction
All of it would be best, but I think Introduction, Javascript basics and Data Types are the most important
Alr thanks...
and objects

@earnest phoenix
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics
You probably only need to learn these in order to get what you want done.
And someone wrote a guide here on embeds. https://discordjs.guide/popular-topics/embeds.html
If you have any questions you can ask here or on my dms.
This chapter discusses JavaScript's basic grammar, variable declarations, data types and literals.
Congratulations, you've reached the end of our first JS objects article — you should now have a good idea of how to work with objects in JavaScript — including creating your own simple objects. You should also appreciate that objects are very useful as structures for storing related data and functionality — if you tried to keep track of all the ...
@tame kestrel @cinder patio @mellow kelp Alr thanks! A lot of documents but ok lol @quartz kindle happy to make you laugh and you guys too LOL

good luck xD
I'm glad you're happy to learn :)
Thanks lol you too :)!
it sounds like you'd do better with a full time teacher tho
Cya ima study tomorrow since its new year today

Yea I learn very well with a teacher @quartz kindle
The docs are free real estate
Is this self-advertising 
yes :^)
@earnest phoenix no advertising
looking for reviewers 😐
Good, you can't look here.
This is for #development
which channel should i go to?
We don't really have channels here for users to promote usage of their own services or anything
ok that's fine then
hopefully the top gg reviewers will approve my bot eventually 😄
well you can ask if someone is willing to help you test it, but you need to phrase it like "help me test xyz" instead of "please try my xyz"
sounds better and less advertisy that way
Fax

What my code isn’t damn working???
troubleshoot it? 🤔
debug it
or that
im just gonna go ahead and say it
its not working because you have no idea what you're doing
you're following 13 different recipes and then wondering why the food doesn't taste good

and mixing the worst bits
I need a handler for a folder with subfolders commands
I need that the handler catch all commands of the folders
shouldnt be hard to do if you read over the fs docs.
sure, google would have it.
they are just the nodejs docs right?
isnt the nodejs docs considered good.
Yes node js
yeah
hmm
time to see how that should work
how would you interact with the object
in the class
this.property?
yeah
pretty sure a long long long time ago i did some extension on members for balances
on djs members?
yeah
This have fs ?
smh
👍🏻
Do I need a new invite link for slash commands?
should I extend an object or just create a new class and use this.object
np
i dont think theres really a problem with extends, since its pretty common to use.
ok ima do that
Inheritance gang
everything is a fake map in js 😔
shhh
I just want an object with a .set and .delete ability
seemed like it would make caching super easy
i did something similar but it's a prototype method
so i can obfuscate getting and setting
closed source program
and a lot of people just waiting to steal my code
lmfao
javascript-obfuscator is heaven for this
all the code ive ever written is open sourced
wait
why can module.exports = { AnyClass } work
its not an array
idk
bruh
:(.
but you're exporting an object but not giving it a name and value
Yeah but
Es6
You dont need to explicitly set a name for an object property if it has the same name as the value you're assigning it to
module.exports = class FakeMap extends Object {
constructor(object = {}) {
super();
}
set(key, value) {
this[key] = value;
return this.object;
}
delete() {
delete this[key];
return this.object;
}
toString() {
return JSON.stringify(this);
}
}```
code p good?
I want learn javascript...
or even https://learnprogramming.online/
loggers
roles: m.roles.map(r => ({
name: r.name,
id: r.id,
hexColor: r.hexColor
}))
I have no idea how to fix this after legit 20 google searches on how to do role list displaying of a guild user.
TypeError: m.roles.map is not a function
Thats the error ^
It's not Google searches you should be looking for. It's the library documentation you should be looking at.
m.roles I assume returns a roles manager, so you'll need to use the .cache property to get the underlying collection.
So, m.roles.cache has the Collection which you can call map on.
What’s a KeyError in Python?
It means a key you tried accessing doesn't exist.
You can often find the meaning of an error by searching it up on your favorite search engine.
How would it not exist if I can literally see it in the endpoint?
Just look at the docs, also to display roles would be ```js
message.member.roles.cache.map(r => ${r}).join("|"))
Because it doesn't exist.
It does exist
I do a manual pull that has the same API endpoint and it runs fine
It worked, but now It won't list more than one member and I'll have to talk to the dashboard devs about that and how to fix that.
how can I clone a Map, effectively??
First result for "javascript clone map"
isn't it just new Map(oldMap);
K
I wonder, by what means effective? Performance? The easiest/most primitive way to do it? Both? 
How do i even make a bot
Read #502193464054644737
async with aiohttp.ClientSession() as cs:
async with cs.get("https://api.weatherbit.io/v2.0/alerts?lat=40.72&lon=-73.71&key=[REDACTED]") as r3:
res3 = await r3.json()
**Alert(s):** {newline.join(alert['title'] for alert in res3['alerts']) or None}```
Produces: ```Unhandled exception in internal background task 'weatherembed_loop'.
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/pi/Documents/Room_Sealer/cogs/room-sealer-weather.py", line 90, in weatherembed_loop
**Alert(s):** {newline.join(alert['title'] for alert in res3['alerts']) or None}
KeyError: 'alerts'```
RAW DATA:
{'country_code': 'US', 'lon': -73.71, 'timezone': 'America/New_York', 'lat': 40.72, 'alerts': [], 'city_name': 'Floral Park', 'state_code': 'NY'}
I'm trying to create a command where it sends a screenshot of a website
and how would I create an else statement when a user doesnt enter a website?
@client.command()
async def ss(ctx, *, args):
if args:
URL = args.lower()
urln = f'https://image.thum.io/get/width/1920/crop/675/ maxAge/1/noanimate/{URL}'
r = requests.get(urln, allow_redirects=True)
open("screenshot.png", 'wb').write(r.content)
await ctx.send(file=discord.File("screenshot.png"))
os.remove("screenshot.png")
else:
await ctx.send("Please make sure the URL is correct (ex: https://google.com)")
I tried creating an else statement, but that didn't work.
Language is Python
@hasty mulch is RAW DATA the result of logging res3?
Yes
Which surprisingly is too difficult for the d.py community to understand
No need to be rude
thats python not dpy
I asked in the d.py python help channel
I’m trying to be nice, and they are being stupid
https://cdn.discordapp.com/attachments/707097873992384563/794255400803368980/unknown.png Anyone know how to stop and prevent this error from occurring? Crashes my whole bot (aka one whole shard)
I don't see why your code is emitting that error. The only thing that looks suspicious is why what appears should be interpreted as a string ("**Alerts(s)**: {...}") is not one.
Shouldn't it be an f-string?
The reasonable way of doing things would be to try parsing the string into a URL. If it works, the URL does too. If it doesn't, it's not valid so discard it. There are ways to parse a URL, such as using the built-in library urllib (https://stackoverflow.com/a/52455972/14695788).
You should also make it impossible for the user to escape the URL by using urllib.parse.quote.
I have url from the user and I have to reply with the fetched HTML.
How can I check for the URL to be malformed or not?
For example :
url='google' // Malformed
url='google.com' // Malformed
url='...
Thank you!
elf I assume they removed some code to show what matters.
o ok
🤣
It is
urllib blocks
Yeah, alerts is in an embed
Why would parsing a string to a tuple containing info be an expensive operation?
elf is also using requests it seems and that's blocking so they may want to change that too
I know what blocking means
can we see the actual fucking error
I'm asking why parsing a string into a tuple containing URL info be a blocking operation.
Are there signs that it's blocking?
@sudden geyser Would this work? ```py
@client.command()
async def ss(ctx, *, args):
val = URLValidator(verify_exists=False)
try:
URL = args.lower()
urln = val(f'https://image.thum.io/get/width/1920/crop/675/ maxAge/1/noanimate/{URL}')
r = requests.get(urln, allow_redirects=True)
open("screenshot.png", 'wb').write(r.content)
await ctx.send(file=discord.File("screenshot.png"))
os.remove("screenshot.png")
except ValidationError, e:
await ctx.send("Please make sure the URL is correct (ex: https://google.com)")
this is what accually message.channel.send line 12
If you use the logging module it would warn you that it's blocking
I didn't get a warning myself.
I mean
At most all I found out was urlparse always return a ParseResult and doesn't throw an error, and nor will it with the all call since all properties exist.
looks like a normal console with blurred transparent background
macOS terminal with blurred background
a
Is it considered privacy breach if only I can see server names and IDs? If this isnt the right channel to ask, im sorry
server names, yes.
Oh if only you can see them? No.
The issue is publishing that information to anyone that asks.
No it only is logged in the console, so yes only me, myself, can see them
yeah that's fine
Alright thanks
args will always be available because if the user doesn't pass the url, it will raise an error MissingRequiredArgument which won't execute the function. You can either handle that error or set the default value of args to be None.
hey how can i make my bot react to a specific message that is sended days ago
get that messageId and fetch it, then react to it
yes, u can extract the messageId from the link
The messageID is in the end of the link
what's the syntax
For example, #development message
The messageID for this link is 794447204386734110
ChannelID is 272764566411149314
GuildID is 264445053596991498
not that whats the syntax for adding reaction like message.add_reaction("❤️")
where will the id go
What app or page do you recommend to make a bot with bdb.js?
@jade juniper nice pfp 👍
pfp?
profile picture
so u using python?
yes
quality above all
@rocky hearth i am also from india wdy
Hi xd
hi
in djs I would hv did this.
const messageToReact = await <TextChannel>.messages.fetch('message-id');
await messageToReact.react('love');
You need to fetch to get the message object first, to fetch a message object, you'd need channel object. Then you can use that add_reaction method. But you can also use the lower level function as well where you don't need to fetch the message object, just need channel id and message id.
Assuming you're using discord.py, something like this would do ```py
emoji = discord.Message._emoji_reaction('😳')
await bot.http.add_reaction(channel_id, message_id, emoji)
null.react() => error
y would it return null?
if you provide ABC, a wrong id (bad regex or something), or a message id you dont have access to
it may either fail or pass
what do you think will happen ?
i mean it will generate error, if id is not correct
messages.fetch('/16725417542') //bad regex
messages.fetch('178264812') // no access to channel
all those examples and some more will fail
like i said, good example, bad execution
the example points them towards the right direction, but its also good to let them know to address those issues that'll happen
hmmm, I'm bit lazy, to address all of that 😜
that's rude
what part of that is rude?
Promises can always fail to execute. Not a thing to mention, every single time
make sure they are all Numbers then just use -
let value = Number(2000)
let Calc = 7000-value
the number thing is just to make sure if you pass a String into it
you want to get x
such as
but that will only work if i already writet the id in code
i want it get id from the link user sends
then calc 7000-5000
i made giveaway bot i want to change time of giveaway but it didn't change
then i want function to this.endat - x = options.addtime
that way i want to know how?
where did you get x from
how to we know the value x
suchas
Guys how to handle error if channel doesn't has SEND_MESSAGES permission.
Just parse it, either using regex or general split by ('/'), the last 2 would be the channel_id and message_id
.catch(error){console.log(error)}
this will print an error in the console but the process wont crash
Already did. It says Missing Permission in console log
i want change that value to 2m
like that
just overwrite the value?
well you handle the error then. if you want you can send a error message into the chat
If SEND MESSAGE is disabled it displays that error in log.
this where not for you
It's not possible if SEND MESSAGES is denied.
well then send it into the channel where the command is used. if this doesnt work use the system channel if this doesnt work use Reaction if this doesnt work give up, if they cant set up permissions you cant work around it
I dm user but it keeps executing even when user is not executing command.
so its an issue with your command handler
Nope. The process doesn't stop
Example
-help
well it executes commands without respecting the prefix
then typing any thing after that is executing command
Yes
so it is probably an issue with your command handler
did you use a message collector for your help command?
Nope
there is somewhere a part of the code that is flaky then
I think it's not returning only once
The command keeps executing everytime I type.
sounds like your command handler is ducked
hey guys, ive been wanting to make a discord bot recently? any ideas?
How do I make a decorator? Python
find a niche or something where other bots are lacking.
or just jump the Hypetrain for recent games
iirc Genshin bots grew like crazy before the hype died down
just make a function that takes a function and returns a function, that's what decorator does, actually could be class as well
whats that @lusty quest
the game?
oh
like what
idk, i do not suggest making a Music bot there are already to many. maybe make one that gives users the Ability to play minigames in chat with others
maybe make a D&D bot
i don't suggest a music bot either
yeah lmao
but i've used import * from <> as <> before
