#development
1 messages · Page 1907 of 1
like a bot that allows the user to create their own bot that only responds to their message.
there is probably a better way
still no clue what you mean then that
automate creating a new bot for each user.

ez pz
nah not doing that 
L
I can't find how to download ffmpeg
it definitely is
lol
how to make economy bot ??
Cheap licenses are available at 10,99 on the international market
I wish to be a sole trader
or just use hax
yup

its stupid easy
Hello,
I try to send a message (and other stuff) when an user upvote the bot, but nothing working.
My code:```python
@commands.Cog.listener()
async def on_dbl_vote(self, data):
try:
user = data['user']
exp = random.randint(49, 101)
with open('users.json', 'r') as f:
users = json.load(f)
users[str(user)]['experience'] = exp
with open('users.json', 'w') as f:
json.dump(users, f)
user = await self.client.fetch_user(int(data['user']))
await user.send(f":flag_fr: Merci d'avoir voté pour le bot! Vous avez reçu {exp} EXP\n:flag_us: Thank you for upvote the bot! You recieved {exp} EXP")
except:
user = await self.client.fetch_user(int(data['user']))
user.send(f":flag_fr: Impossible de vous donner votre récompense\n:flag_us: Unable to give you your reward")
No errors in the console, nothing
Can anyone help me please?
await user.send
also remove try and except, then run the command. that blocks console error logging
on linux, i installed both ffmpeg and ffmpeg-static with npm, but when i play something with my bot (i am using DisTube if that could matter) i get this error:
i tried doing sudo yum install ffmpeg but it says no matches
ok thanks
always nothing
anyone?
first result for the article
Weird question, anyone know of any hotword detection libraries?
There's Porcupine (not free, 30 day limit on models) and Snowboy
Snowboy is "not maintained", but the training script was released
any specific language?
Go, but honestly as long as I can interface with it with C or similar that's fine too
Tried getting in contact with the Porcupine/Picovoice devs and they never replied... lol
you could try a homemade algorithm
Honestly, it takes a lot to get it right
I really don't have the time or patience for that LMAO
I used to use Snowboy, but since they discontinued it I've been looking for another option
like, levenshtein distance + array of desired words is a good start
now with the training script released it'd be possible
what are you trying to do?
Detect someone saying my bot's name so I can pass the following audio into dialogflow/eventually a custom system :)
if you already have the STT then implementing something like python's difflib algo should work
oof v old package
meh the algo isnt too hard to transfer over
Yeah STT isn't exactly efficient
sadly
I could use deepspeech and try to compare it for words, that's how the original detection worked
but the problem is when there's lots of people talking you need a way to detect it quickly, without translating all the data, and just checking for patterns
which is what porcupine and snowboy did
levenshtein dist
easiest and probably fastest one at it
just set a high threshold so u dont get as many fase positives
pretty sure this is supposed to based on voice
ah, that makes more sense
Yep, lol. Should've clarified that, sorry
I've already overcome the issue of not getting voice activity events...
(they removed them about a year ago and now only send a single "Speaking" packet for the first time the bot sees the user speaking, to map the ssrc)
Leveinstein slow
but yes
simple
How would the bot know if a message was sent in a certain channel?
which language?
ah
not my expertise
if it was py i would do if ctx.channel.id == channelid
not sure about js
it's basically the same
but like, a single word so leven would run pretty quickly
the issue comes at bigger arrays
and using ai for a single word fuzzy search would be overkill af
does anyone know how to use font styles in canvas?
I used to 👀
in order to register slash commands on all servers my bot is in do i have to make everyone reinvite the bot or is there a better way
u can re-authorize using the same invite if it has a new scope
so every server has to reauthorize?
py (discord.py/nextcord):
how can I implement two cooldowns on a command? e.g.:
- 4 uses per 24h allowed
- each use must be at least 2h apart
Add @commands.cooldown(4, 86400, commands.BucketType.user)
Underneath the @client.command()
yeah I got that one, but I need the 2h bit too
someoen could do 4 commands in 10 seconds which would be allowed by this rule, since it allows 4 per 24h, not 1 per 6h
@commands.cooldown(1, 21600, commands.BucketType.user)
One every 6 hours
That means it can’t be used more than 4 times within 24 hours
And is over 2 hours apart
thanks but still not exactly what I'm looking for, i need them to be at least 2 hjours apart, not at least 6 hours apart
e.g.: someone could do a command at 9 am, 11 am, 1 pm, then 3 pm, but NOT at 5 pm since they've already gone over the 4 per 24h limit
Ignoring exception in command gather:
Traceback (most recent call last):
File "C:\Users\###\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "D:\Room_Sealer\cogs\room-sealer-gather.py", line 38, in _gather
await db.execute(f"UPDATE inventory_mhs2 SET [silver cricket] = [silver cricket] + 1 WHERE character = {character}")
File "C:\Users\###\AppData\Local\Programs\Python\Python38\lib\site-packages\aiosqlite\core.py", line 184, in execute
cursor = await self._execute(self._conn.execute, sql, parameters)
File "C:\Users\willy\AppData\Local\Programs\Python\Python38\lib\site-packages\aiosqlite\core.py", line 129, in _execute
return await future
File "C:\Users\###\AppData\Local\Programs\Python\Python38\lib\site-packages\aiosqlite\core.py", line 102, in run
result = function()
sqlite3.OperationalError: no such column: Atlanta
Code:
@commands.command(name='gather')
@commands.guild_only()
async def _gather(self, ctx, island = None, character = None):
items = ['a silver cricket']#, 'an antidote herb', 'a herb', 'some honey', 'some hakolo honey', 'some heftcorn', 'a carpenter bug', 'a toadstool', 'a blue mushroom', 'a nitroshroom',
#'a iron ore', 'an earth crystal', 'a lightcrystal', 'some stone', 'a small clutter of monster bones', 'a medium-sized clutter of monster bones', 'a small clutter of brute bones',
#'a medium-sized clutter brute bones', 'a bitterbug', 'a thunderbug', 'an insect husk', 'a sleepyfish', 'a speartuna', 'a trap tool', 'a throwing knife', 'some stone',
#'some woemill wheat', 'an ivy', 'an aloe leaf', 'a sap plant', 'a paintberry', 'a spiderweb', 'an insect husk']
rare_items = ['a kelbi horn', 'a stinkshroom', 'a whetstone', 'a shiny beetle', 'a pelagicite ore', 'a goldenfry', 'a large collection of monster bones', 'a large collection of brute bones',
'a pittance fang', 'a golden fragment', 'some girthy garlic', 'some snakebee larva', 'a duskshroom']
high_rank_items = ['a machalite ore', 'a manyberry', 'a unique mushroom']
rare_high_rank_items = ['a dragonite ore', 'some mixed honey', 'a king truffle']
if ctx.channel.category_id in [740625967143452673, 740723809069564056, 740622346800463974, 741754307216408656, 741750821871550562]:
await ctx.send(':x: | This command can only be used in rp!')
print(f'Command r!{ctx.command} used in a non-rp channel by {ctx.author.name}')
else:
await ctx.message.delete()
if ctx.channel.id == 894483796555087933:
if character == None:
await ctx.send('(Please state which character is gathering an item)', delete_after=7)
else:
if island == 'hakolo' or island == 'Hakolo':
async with aiosqlite.connect('D:\Room_Sealer\db\inventory.db') as db:
item = random.choices([items, rare_items, high_rank_items, rare_high_rank_items], weights=[100, 0, 0, 0])
finalitem = random.choice(item[0])
if finalitem == 'a silver cricket':
await db.execute(f"UPDATE inventory_mhs2 SET [silver cricket] = [silver cricket] + 1 WHERE character = {str(character)}")
await ctx.send(f'*{character} has grabbed up {finalitem}*')
else:
await ctx.send('(Island name was spelled incorrectly. Current available island names: `hakolo`)', delete_after=20)
Command:
r!gather Hakolo Atlanta
Language: Python
Idk why it's trying to find the column, instead of the row
SQL injection goes brr
No point because the bot is in a gated private server
Fixed with adding quotes to the f-string
fyi you can refactor this messy pyramid by using guard clauses where you return from the function early instead of using else branches
if ctx.channel.category_id in [740625967143452673, 740723809069564056, 740622346800463974, 741754307216408656, 741750821871550562]:
await ctx.send(':x: | This command can only be used in rp!')
print(f'Command r!{ctx.command} used in a non-rp channel by {ctx.author.name}')
return
await ctx.message.delete()
if ctx.channel.id == 894483796555087933 and character is None:
await ctx.send('(Please state which character is gathering an item)', delete_after=7)
return
if island != 'hakolo' and island != 'Hakolo':
await ctx.send('(Island name was spelled incorrectly. Current available island names: `hakolo`)', delete_after=20)
return
async with aiosqlite.connect('D:\Room_Sealer\db\inventory.db') as db:
item = random.choices([items, rare_items, high_rank_items, rare_high_rank_items], weights=[100, 0, 0, 0])
finalitem = random.choice(item[0])
if finalitem == 'a silver cricket':
await db.execute(f"UPDATE inventory_mhs2 SET [silver cricket] = [silver cricket] + 1 WHERE character = {str(character)}")
await ctx.send(f'*{character} has grabbed up {finalitem}*')
Noted
that way all your exit conditions are at the top and the code that runs when everything goes correctly is at the bottom
Right now, though, I have it slated for possible future expansion
this makes modifying your code much easier too
can't think of any reason why you'd want to have it the other way around unless you're my intro to computer science professor from college
I'm kinda of a newbie at this stuff, so...
https://refactoring.guru/replace-nested-conditional-with-guard-clauses take a look at this
Problem: You have a group of nested conditionals and it’s hard to determine the normal flow of code execution.
Solution: Isolate all special checks and edge cases into separate clauses and place them before the main checks. Ideally, you should have a “flat” list of conditionals, one after the other.
Is there a way to cache and send a log if AutoPoster(top_gg_token, client) causes an error?
How to require node fetch v2 for dont get es module error
HUGE breakthrough on the detection stuff...
Mycroft Precise is an option
I thought "Oh, that's just Python"
It uses a binary file for the detection engine... that's insanely easy to wrap in Go
usage: precise-engine [-h] [-v] model_name [chunk_size] < audio.wav
precise-engine: error: the following arguments are required: model_name
Use node-fetch v1.7.3
you have to use the import statement. I forgor if node supports it by default or if you have to enable it with a launch flag. Look it up.
Alternatively, node fetch sucks. Use something more lightweight and not bloated
What you suggest ?
I need for fetch reddit memes github status etc
I personally use centra if I don't want to use the built in http libs, but I mostly use the built in http libs.
http and https just offer a lot of control
The built-in one is simple enough if you don't need to handle redirects
auto body parsing is kind of a bad thing to do, but if you expect data to always be in a format, sure ig
even if you properly read the response header content type and parse accordingly. Should be something done on a per req bases
I dealt with an http lib that auto parsed. God that was a shit ton of bugs to track to not actually being my fault

what if I don't want to learn a new http package instead of using the Fetch API I already use on frontend
why will you bundle an api that already exists in the browser
read the readme?
why the fuck do people still use internet explorer
why doesn't someone use windows 7 vulnerabilities to create a worm that deletes internet explorer
You don't have the right to say that since you use Windows 7
Then create your own packages to eliminate the bullshit design decisions a lot of developers make. That's what I do and while it is painful to maintain all of them, it's good to know that errors are my fault and that I can fix them whenever I want and make my own design choices which are extensible and user friendly, because I'm not just making packages for myself.
If you don't want to do that, then either deal with it and use what you have or suck it up and learn a new lib because there's most likely a package which does what your old package does, but better both user end wise and performance wise
I've shied away from a lot of common libs because they're just bloat and can easily be done manually
can anyone suggest me some fun projects?
copyright issues if I play random songs
?
Another project idea: Unity/Unreal game dev or building a scene. That would include 3D modeling and texturing and UV mapping and lighting and material setup and perhaps some cs or cpp scripting depending on what rabbit hole you go down
bonus points if your scene isn't static
papi
@rose warren
hi im making a role command i want my bot to send a error message if the specified role's position is higher than the bot's role i tried using
if role.position > self.client.user.top_role.position:
await ctx.send("This role is above my league!!")
but it says client.user has no attribute top._role (discord py)
You need a Member object
Use Context.me instead of Client.user
oh
Yuh
ctx.me.top_role.position
will this work?
You don't necessarily need the .position btw
thanks
ty so
@earnest phoenix@earnest phoenix you da god ty sooooooo much
wkjgrfusaggfgasbufguiqgausgugasfugiugwuagigdfasgfugsa
Np
Are you okay doe
literelly 1 month
i was searching for dis
oasjofjahsf9aos
Learn how to read API references and you'll be good
@bot.event
async def on_dbl_vote(self, data):
user = data['user']
exp = random.randint(49, 101)
with open('users.json', 'r') as f:
users = json.load(f)
users[str(user)]['experience'] = exp
with open('users.json', 'w') as f:
json.dump(users, f)
user = await self.client.fetch_user(int(data['user']))
await user.send(f":flag_fr: Merci d'avoir voté pour le bot! Vous avez reçu {exp} EXP\n:flag_us: Thank you for upvote the bot! You recieved {exp} EXP")
Nothing works, no errors.
because python uses indentation it took me a long time to realize the difference between the two fs
?
Did you instantiate another bot object in a Cog
You're registering the event to a stateless Bot object
Use the listener decorator instead
yes
webhook?
You should instantiate WebhookManager, or otherwise, it won't fire at all
do i need to have a webhook on each server?
and can i create the webhookmanager directly in my bot?
It's not Discord webhooks if you meant so
Take a look at this example https://github.com/top-gg/python-sdk#using-webhook
Yeah, you'd need an open port btw
oh thank you a lot!
From that example, the URL you're gonna put on the site is http://YOUR_SERVER_IP:5000/dblwebhook. Don't forget to put password as the Authorization
ok, i'll try it now
Hwl cn i make an apii
Whats hwl lol
Any idea why this is showing the global prefix? Even though i have changed the prefix
import { client, prefix, commands, aliases, db } from '../index'
import Discord, { MessageEmbed, Collection } from 'discord.js'
import ms from 'ms'
export async function messageFunction(message: Discord.Message) {
const dbPrefix: string = await db.fetch(`prefix_${message.guildId}`) || prefix;
if(message.content === `<@!${client.user?.id}>` || message.content === `<@${client.user?.id}>`) {
let embed = new Discord.MessageEmbed()
.setAuthor('Angelus')
.setDescription(`**Prefix:** \`${prefix}\``)
.setColor('GREEN')
message.channel.send({ embeds: [embed]})
}
That code doesn’t even include the prefix check anywhere.
You declare dbPrefix as var but I don’t see any check if the content actually obtains that prefix or not.
can someone suggest me some fun projects?
among us 2
no u 3
Hello I am making a website for my bot and I would like to make something like the one of MEE6 when you press "Login in" the bot makes you connect in the site with your discord account
An embed generator
Learn OAuth
FRENCH POG

eh?
user ~$ sudo yum install ffmpeg ffmpeg-devel
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 3:26:47 ago on Sat 23 Oct 2021 10:31:53 AM UTC.
No match for argument: ffmpeg
No match for argument: ffmpeg-devel
Error: Unable to find a match: ffmpeg ffmpeg-devel```
this isnt supposed to happen
god lazy evaluation fucks with my mind so much
main :: IO ()
main = do
configs <- fromRight (error "Could not read bot configuration") <$> getBotConfigurations
-- print configs
runDiscordBot $ DiscordContext {token, configs}
this doesn't error, but this does
main :: IO ()
main = do
configs <- fromRight (error "Could not read bot configuration") <$> getBotConfigurations
print configs
runDiscordBot $ DiscordContext {token, configs}
fetching the data errors but because configs isn't being used when print is commented out it doesn't even bother running getBotConfigurations lmfao
anyone?
the fuck is that syntax
what about it
Everything :: $ <> <-
$ jquery in c++
is that your real face
runDiscordBot $ DiscordContext {token, configs}
same as
runDiscordBot (DiscordContext {token, configs})
actually in this case I don't even need parentheses
yeah haskell has a ton of infix operators
not a huge fan
<- is just await but it works for more than just promises. <$> is Array.map but it works on more than just arrays
I thought you hated haskell
I don't
there are parts of it that are kinda annoying
but for what I'm doing it's easily the best language choice
that would probably be something like this in rust
fn main() -> io::Result<()> {
let configs = getBotConfigurations().unwrap();
println!("{:?}", configs);
runDiscordBots(DiscordContext { token, configs })
}
looks so much better
rust isn't as typesafe as haskell though
when your code compiles in haskell you can be fairly sure you're not going to get a runtime error
but getting your code to compile is a nightmare
any form of net i/o can destroy type safety which is "totally awesome"
Haskell is supposed to prevent errors
Top.gg seems like it's written in PHP 
gateway intents?
not using it for anything internally. I'm just using it to work on a separate tool to help bot reviewers https://github.com/top-gg/cyclone
uh gd luck then,haskell is pain 
it's the correct tool for the problem it's solving
for/againsts storing binary (images) directly in a database (e.g. mysql) as opposed to a file?
if its under 1MB its considerably more efficient to store in DB, anything over it becomes a bit more iffy, anything over 10MB is definitely more suited to file
not that MySQL is on the dbs i'd use list
generally Postgres performs well with it, Mongo also does a semi-reasonable job surprisingly.
Cassandra/Scylla just struggle, they have such a tight timing allowance that large inserts like that just generally cause it to timeout and abort without editing it's server config which is regarded as a cardinal sin
if you have a very high frequency of image rates e.g. creates alot, deletes alot. Redis works well in append only mode
https://discordjs.guide/interactions/registering-slash-commands.html#subcommands
How can I set sub commands without SlashCommandBuilder?
Like this:
https://cdn.discordapp.com/attachments/824411059443204127/901508613292572712/unknown.png
Hello
I am getting discord.errors.DiscordServerError: 500 Internal Server Error (error code: 0): 500: Internal Server Error with the following code:
@BOT.event
async def on_raw_reaction_add(payload):
channel = BOT.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
# Other things but the error comes from above
I checked the dev portal and the Member intent is set to yes, and the intents are:
intents = discord.Intents.default()
intents.members = True
intents.reactions = True
My bot has 113 guilds so I think that it could be an issue with the > 100 guilds intent thing, but I remember submitting that request more than a month ago, and it looks like it is still set to yes anyway.
I might be in the wrong section/server but i'm still asking for any help please, thanks
According to the error, the Discord API encounter an issue
Wait and see if it works
Maybe it's not that
I checked if someone else was encountering this error about the discord API and I didn't find anyone, that's why i'm worried about doing shit 🤡
While re-reading your code, I've found a thing:
channel = BOT.get_channel(payload.channel_id)
This function is a coroutine. You need to do channel = await BOT.get_channel(payload.channel_id)
But, is the message exists at this time?
Jv test merci
ok
Question
👀

is it practical to serialize something to json for storing something large to a database to then be able to parse that back into an object?

err not massively
What would you suggest regarding storing entire "packs" of certain data?
Context is, currently making a bot for a specific server that manages anime nights, issue is that each anime night should be stored for longer durations to be able to check past voting sessions
Stuff it would contain is:
- A unique id assigned to that vote
- at least 2 ids from a certain anime info website
- Ending time
- Results
and results are value - key objects containing the user id and the chosen vote
so you need ttl too?
why on earth would you save images in a db my man..
- performance and caching
- organisational purposes
- persistence and redundancy
- snapshot and backups
cool terms but that's not how the real world works
🤨 mmm no it really is how it works lol
Seems like that’s how it works to me chief
storing images in a db is not a good practice
lmao
cuz u can save links on imgs
for small images there is zero reason not to use a DB

a lot of things are fine and can be done but are they good practices?
but this all shit just depends on ur needs lol
yes
this one isn't one of them
hence why we've built systems that manage millions of images backed on databases
what do you think s3 is? Some random file system?? lol
S3 is an append only database under the hood, would you consider that bad practice
of course not but you comparing s3 with 'storing into db' is a bad practice
s3 has an entire system to back it up and how it works and provides you with output data
yes and you think a database doesnt have this?
when you do it yourself, what people tend to do is usually use the 64bit of the images and just render it
Am I stupid or the fuck is a “64bit of the images”
never heard that term used before 
I'm a bit sleepy ignore 64bit lmao
and I mean I've built systems that deal with hundreds of gigabytes a second egress lol
a single postgres instance can pretty easily tank 7,000 images a second on serving
I literally don't know where people get the stigma of going "ooh no blob storage bad" the statement has been false for a good 1 and a half decades now
even MySQL which is where that original idea came from improved its system enough for it to be perfectly operable lol
although their blob system is still a bit weird
the only reason you'd want to use the standard filesystem for storage images now days is because they go beyond the size of most database buffer pools which hurts performance just enough for the OS to be a more performant option.
what you dont get with a raw file system by default is:
- Atomic writes
- File change protection
- Smarter caching
- Incremental snapshots
- Compression (although this doesnt really apply for images)
- Distribution support
- Replication
And by the time you do have that, you basically made a database anyway
Isn't an object storage basically just all of that?
Well yes, object storage are databases
generally they're append only in order to maintain a fast index, and then every so often you can force a re-index and purge the old data
this is equally the same principle with databases in general but generally it's less apparent and / or the database will implicitly run this
Time to wire up mycroft with the binary...
Pretty much the way their engine works is it's a binary (that you can compile yourself, 100% open source) and it passes the data in, reads a response
how do I fix this?
const { executor, createdAt, createdTimestamp } = ChannelLog;
const ChannelLog = FetchingLogs.entries.first();
C:\Users\oka------;-;\Pictures\Mellie-Inc-main\index.js:849
channel.guild.member(executor.id).ban({
^
TypeError: Cannot read property 'ban' of null
Try: channel.guild.members.ban(executor.id, <options>) Replace <options> with your appropriate options.
it's works but after ban it crashes
Hmm, can I help you in the DMs?
sure
aight hello people
is there a way to make my bot rejoin the voice channel if it restarts
i'm using d.py
the bot is a 24/7 radio bot
so i want it to autorejoin the vc if it crashes
make it check if it needs to join a channel when you start the process
alr
is there anything in ejs which can get whatever is after the /
in flask I can do py @app.route("/<id>") async def redir(id):
is there an ejs alternative
It's /:id, and you can get it in the function with req.params.id
ah epic
app.get("/:id", (req, res) => {
const id = req.params.id;
});
that worked
Nice!

anyone can suggest me a nice 24/7 discord.js hosting service? i have to fix my vps as its driving me crazy, and in the meanwhile i need the bot to be online, but i'd like to avoid shitty things like heroku or replit
pls this is important
what is wrong with your VPS?
I would recommend either https://mvps.net or https://galaxygate.net
MVPS is a European VPS company which aims to offer high quality VPS services by using high performance hardware. Get your cheap VPS for only 3 EUR!
idk every aws vps i activate seems to have some OS issues for some reason lol
Try a different provider
thank you, i'll check this out
now i need more help
how to get data from an api in node.js
i need to get "code" and "type" from my json api output
Use a library to fetch the data from the API
Node-fetch (v2 if you're using cjs require) or axios
Could also use something lightweight like centra or phin
I'd say node-fetch
But I'm assuming you're using require()?
app.get("/:id", (req, res) => {
const id = req.params.id;
res.send(id)
res.redirect()
});
thats my code rn
literally nothing
no
this isn't an api
this is a site that uses its api to get the type related to the id and redirects based on that
its a top.gg link shortener
so it gets either "bot" or "server" from the api i've made and then redirects from there
yes
instead of https://top.gg/bot/866364881917837312 i could have https://dbl.tf/blacklister
Blacklister is a Discord Moderation Bot with a fully functional built in user blacklist. https://blacklister.xyz
What do you mean by this then
true
lemme send a ss of my api output
Where do you get the data?
api.dbl.tf (linking cname now)
So basically this?
my api doesn't get data from anywhere else
just the db storing the type related to the id
and the code output (either 404 or 200)
What do you mean? You have a json response and you are trying to extract data from it?
yeah
Oh, how are you getting that response?
I'm assuming you have some sort of database to store the ID and type?
Yep
If you have a response object, just do res.data.code and res.data.type
Check your code for syntax errors
js doesn't usually complain about ";"...
Can you show a bigger snippet of the code
ah
Also you're closing the callback scope too early
now more errors
Get rid of that }); after const data
:D good job though
ty
i mean i made https://api.capybara.bar with express
i should have just stole my code from that
ah ok
Barely anybody uses ESM, what are they thinking
man refactoring shit in haskell is such a breeze once you get through setting up the initial code
I think I'm close to getting this discord bot to work and I've sent a total of 6 messages on discord to test
brb installing vs code again to my coding shit in
oh epic
you don't have to run your code to see if it works lol
no I was talking about my workflow
ah
errors you can't see won't hurt you :)
:D
Hello,
How I can find with python the bot own role?
wdym
You could go through the bot's roles on a server and find the role which has the same name as the bot
But then again, that name can be changed so
The error says it all, you tried to use import when you should've used require
oh that's weird
Maybe it is actually the other way around
You are trying to import a file that needs to be required
fixed
I think the other guy that was helping said that if you install a specific version of node fetch it has to be imported
downgraded to node-fetch 2.6.1
yep
you could look into Role.is_bot_managed()
Ok thanks!
No problem!
Node fetch's new update is fucked up. It's not with your code, it's with the package. I remember seeing some fix for that in stack overflow tho, u could search there
I fixed it
Yup
Is there an other fix?
I just downgraded in package.json and redid npm i
oh
Like import default and smth
But that was too much unwanted works for me. I also just downgraded it
Is there a reason you chose node-fetch over axios?
i was recommended it
I just didn't want to rewrite my codes, was lazy then when I searched for those fixes
But moved to axios the next day iirc
would you use node fetch if it wasn't "broken"
Okay
Depends, axios is my first preference always
I too like axios more
But don't take my words. My mind is unpredictable by myself 😂. I just sometimes make dumb decisions
I think on this one it made the right decision :D
i need some help now
Is the code
but requests are still being sent
when its just localhost:3000
@coral sigil ideas?
i know why
Cuz u did not define what "type" is but used it in the res.redirect
its because its getting a request when i go to localhost:3000 not localhost:3000/id
you also forgot to define type
^^
the type is on the data
not type
the data is the json response and it has a type
epic it worked
oh sorry i got it now :D
http://localhost:3000/test redirected to https://top.gg/bot/test
http://localhost:3000/test redirected to https://top.gg/bot/test
because the API linked the id test to the type bot
perfect
what are you working on btw?
cool cool
i jsut need to fix my stupid mistakes
anyways time for me to go back to nowplaying
lmao
Hello, I have a problem
My bot currently has
Servers: 272
Users: 145 073
But I reset the bot now and I have an error that shows me
Servers: 272
Users: NaN
How fix it?
Hey hey! I'm making a dashboard for my bot and i just added the possibility to change the color of embeds sent in your server, and everything works fine except the part where it saves the new color to the database. I get no errors and it displays a 200 status in the console. Does anyone know why/how to fix this? Thanks is advance :)
I see no issue at all
Just cache working as it should
But everything worked well, now it does not work
The command that shows all the servers also does not work correctly
Well, things doesn't error out of nowhere, did you change anything?
Nothing? Like, not even an additional space or anything else?
No
Show the code related to such count
the code that shows how many people are on all servers?
Whatever is the code that's not working as expected
But everything worked well ugh
A few minutes ago I did a bot reset
And suddenly it broke that show all people and command that shows all the servers
Sorry for my eng
Please show the code so we can look at it and see if something's wrong...
I think you wouldn't be here asking if it worked
How is everyone else's bots online and working then
Because it's just a problem with the code that shows all the people and with a command that shows all the servers
Okay, could you show the code?
Uhh yes
This is code for show all people from all servers
await this.client.guilds.cache.reduce((a, b) => a + b.memberCount, 0).toLocaleString(),
And it shows NaN as result?
Well that’s indeed strange.
Seems like something has gone wrong on the ready event.
that's not how reduce works
The memberCount per guild is accurate transmitted in the ready event
o no wait js has the arguments the other way around
This server added my bot
Is there a possibility that it is through this server?
What if it's still counting the users :D
I'm trying to enter this server but I can not
looks like a bot farm
Yeah
Yeah I hate that shit, too so confusing
You should not 👀
Why?
Using your bot to join it's server is against tos
Discord can ban you for being a part of a scam for example
Hmm
imagine inviting a bot and some random dude joins your server lol
would ban both immediately
Creepy
It's good to know that this is against tos XD
And imagine he is like "dude u were spamming commands"
"Dude I am testing ur bot tf u mean by spamming commands? Why do u even log who uses ur commands? Wtf?"
:D
actually happened to me in my test server
rly?
lol
Yep

I mean my friend has a command log
That’s the reason to not grant bots any permission until it necessary needs it
I think there's nothing wrong about command logging, but if you generate an invite through your bot, that's not so good
And we had a guy try ratelimit the bot by having him and his friends spam .help
He has a command to see what servers they are in so he could leave that server
Turns out it was a bot farm
That's handy
I just have ratelimits. Which bans the user if he is intentionally spamming commands. It would give out a warn 1st and if he still continues, bans him for 30m
That’s handy
I agree
I just use my blacklist module to check if a user is blacklisted

This was during the test stage, dont mind the pfp
That’s also a farm…
Since we got more people sharing it in here, it seems like it invites bots from topgg or generally bot lists
Yeah
Sus
Time to make a sever blacklist module
If serverid is blacklisted, leave server
I have such a thing hehe
Could you give the code? Or some video how to do it? Please
Hahaha succeeded
Just a simple check of the timestamps of the last and current message or by caching timestamps of your commands
Per user, channel, guild etc.
Whatever you want
I left this server and everything is fine
Nice
Just a pity that I lost the server which had 23k
Well there were 0 online
Quality over quantity, dont even bother if your bot is in a server with 23k inactive dead accounts
Yea
i think i found a troll server with ~23k users
they have typed help 126 times today and done nothing else

another one here, its a bot farm and we just had a discussion about that server like an hour ago
I've had people maliciously try to lag out my bot, lol
tl;dr: Don't assume that actions are rate limited by Discord, like changing your server name
that's the first time i saw one. they must be a wave happening now
time to create a blacklist
server blacklists are a slippery slope though
better to fix any issues they cause lol
they just mess up my metrics
it's not fast spam
just lots of request over the day
i noticed a lot of events today then i started logging the guild id
only help command
they must be using our bots to spam discord's api. if they have 23k bots responding to !help
Consider it a free stress test for Discord /s
adding a loop construct to a parser is harder than it seems
My bot got added to that too
I'm suddenly getting multiple minutes in lag from my bot, which is very much a new thing that happened without any change to code. I'm wondering if it's either my host service, pebblehost.com, or my database service, mongodb.com. Is anyone familiar with either of these services, or might be able to tell me how to test and see what's going on?
Not sure if it's your problem in this case, but related to what's been going on with others in this channel.. check your database queries, if you do any on actions like help commands, guild name change, etc
Might be overloading something
finally not dealing with only 8GB of ram or hard drives any more. Some choice system upgrades have totally removed major inconveniences for my workflows and it doesn't take a century for each tsc build

Now if I only I could get rid of the inconvenience of having to maintain a bunch of libs and my real life at the same time
Multiple command folder ?
so inner depth? ,precedence ?
yes
Read dirs and use forEach or map
let me try
also
the new version of d.js has this interactionCreate thing
it tells me to use that instead of the message event
Yes
how do I use it
Read guide
Its a bit harder than messages
thats what I'm saying
I did read the guide
before
fs.readdirSync('./commands/')
this returns []
why
client.guilds.cache.get("Test guild id").commands.create({name: "ping", description:"Pong!"})
client.on('interactionCreate', async i =>{
if(i.isCommand()) {
if(i.commandName === "ping") {
i.reply("pong")
}
}
i
});
Map them or use for Each
yes but it returns an empty array
if its empty the script won't execute anything
and will return
Object.<anonymous>
or something
if I'm not wrong
Do you have folders in command folder ?
nope
only one file
named
ping.js
You reading dirs
Not files
WAIT NVM I RAN THE CODE AGAIN AND IT WORKS NOW
fs.readdirSync('./commands/').forEach(file => {
if(!file.endswith('.js')) return;
else{client.commands.set(file.name, file)}
});
I don't get it
this should work right
No
oh
Ofc if you dont have folder named as some.js
Again
so how do I read files
isn't readdirSync for reading directory files
fs.readfileSync(`./commands/${file}/```
oh wait
right
okay well I made the load thing work but its not executing the command
index.js
client.commands=new Discord.Collection();
fs.readdirSync('./commands/').forEach(file => {
if(file.endsWith('.js')){
const commandFile=require(`./commands/${file}`)
client.commands.set(commandFile.name, commandFile)
console.log(`Loaded ${commandFile.name}`)
}
});
client.on("ready", ()=>{
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("message", (message)=>{
if(!message.content.startswith(PREFIX)) return;
if(message.content==`${PREFIX}ping`) client.commands.get('ping').execute(message)
})
ping.js
module.exports={
name: "ping",
description: "Returns ping ( latency ) of the bot.",
execute(message){
message.channel.send(`Pong!`);
}
}
@earnest phoenix w should be capital
And why are you still using prefixes for commands instead of slash commands
i want this code in sort form
const credentials = require("./config");
const video1 = { path: '1.mp4', title: '', description: '' }
const video2 = { path: '2.mp4', title: '', description: '' }
upload (credentials, [video1, video2]).then(console.log)
const onVideoUploadSuccess = (videoUrl) => {
console.log(`Uploading Video Done`);
}```
i did not want to add these mutiple lines
```const video1 = { path: '1.mp4', title: '', description: '' }
const video2 = { path: '2.mp4', title: '', description: '' }```
people seem to prefer prefix commands when they have a lot of bots in their servers so you know
alright alright
umm slash commands already seperate the commands by bot
and god forbid if two bots have ! prefix
yes I know but like if you wanna use a command you type / and all the bots in that server who have slash commands will pop up and ppl find it hard to find the command they're looking for
also I changed my code to this just to see if it responds if someone sends a message but this isn't working
client.commands=new Discord.Collection();
fs.readdirSync('./commands/').forEach(file => {
if(file.endsWith('.js')){
const commandFile=require(`./commands/${file}`)
client.commands.set(commandFile.name, commandFile)
console.log(`Loaded ${commandFile.name}`)
}
});
client.on("ready", ()=>{
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("message", (message)=>{
client.commands.get('ping').execute(message);
})
What does your ping command's execute function look like? And I think nowadays we should listen to messageCreate instead of message
Congrats on your bot being accepted!
What can this mean?
(node:46) UnhandledPromiseRejectionWarning: Response: Internal Server Error
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:161:15)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:46) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)
Are you trying to register slash commands?
Thanks! How'd you know?
The green name
Ohh, yeah it wasn't green earlier..
ping.js
module.exports={
name: "ping",
description: "Returns ping ( latency ) of the bot.",
execute(message){
message.channel.send(`Pong!`);
}
}
Np
let me try message create
Nice!
still not working
I think the message event should still work..
yeah
yep so what do I do
Tyty
Does it log to the console that it loaded a ping command?
yes
hmm
What if you do this, what will it log to the console? ```
client.on("message", (message) => {
const command = client.commands.get("ping")
console.log(command)
command.execute(message)
});
So it doesn't get the command from client.commands, hmm
Can you send the whole file so I can test it out? Don't send your token.
got you
index.js
const Discord=require('discord.js');
const client=new Discord.Client({ intents: Discord.Intents.FLAGS.GUILDS });
const fs=require('fs');
const {PREFIX}=require('./config.json');
require('dotenv').config();
client.commands=new Discord.Collection();
fs.readdirSync('./commands/').forEach(file => {
if(file.endsWith('.js')){
const commandFile=require(`./commands/${file}`)
client.commands.set(commandFile.name, commandFile)
console.log(`Loaded ${commandFile.name}`)
}
});
client.on("ready", ()=>{
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("message", (message) => {
const command = client.commands.get("ping")
console.log(command)
command.execute(message)
});
client.login(process.env.TOKEN);
ping.js
const Discord=require('discord.js');
module.exports={
name: "ping",
description: "Returns ping ( latency ) of the bot.",
execute(message){
message.channel.send(`Pong!`);
}
}
Thank you, give me a sec
take your time
Hey it might be on the intents, let me look into it real quick, I think you need a message intent.
What version of discord js do you have?
Perfect
I forgot how do you check the version
it is in package.json, under depencies
i used the console
Okay
yes also I tried looking for the message intents but I couldn't find it
I tried the GUILD_MESSAGES but didn't work
Initialize your client like this, I didn't test this yet, but pretty sure it'll work now.```
const client = new Discord.Client({
intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES],
});
Yea you need to put them in an array
Nice!
Both
You need the message intent to be able to listen for message events
is there not a thing like DEFAULT in the intents, I can just use it instead of calling intents different intents according to my commands
hm I get it
I don't think so, but why is initializing you client with those intents a problem? You only need to do that in that file.
no i mean its not a problem I was just wondering if theres a thing called default for the intents like they have it in d.py
also what does .cleanContent actually do
I found it.
What do you mean?
its a factory method that creates a Intents with everything enabled except presences and members.
in the message.content
theres a method called cleanContent
does it clear the prefix part
This is from discord.js website : "The message contents with all mentions replaced by the equivalent text. If mentions cannot be resolved to a name, the relevant mention in the message content will not be converted."
if yes then its really useful for me since I'm a beginner
I see
so the mentions
So it replaces the user ids to usernames
will get converted to the username#21312 right
You got it
"If mentions cannot be resolved to a name, the relevant mention in the message content will not be converted."
Then there will be the wrong id
so it wont be converted
yep
@spare goblet
But if you want to get the mentions out of a message easily, there's message.mentions
I wanted to ask how do you take multiple arguments in js
noted
Where would you like to do that?
Don’t randomly ping CMs
for a function lets say for example hello(user1, user2, user3, userN)
so it should take each user in each user variable
ok sry
So that is how you take multiple arguments, but are you trying to say that you don't know how many arguments it would take? So the function should be able to take a random number of arguments?
wait is this the correct syntax of taking multiple arguments
yes
cause I've seen in a lot of vids they take args and then use args[1] upto args[n] according to their use
Yea so you mean that what i wrote
That function will only be able to take 4 arguments. So i dont think that's the correct way
Where would you put that, if I get context I could help further
thats what i want, limited arguments
Then you just do hello(argument1, argument2) and so on
No problem, please let me know if you have more questions/problems
Did you get this working?
no, I have no clue rn
will do
Let me look into it, give me a sec
ok
Hmm, I got it working just by doing
const hook = new WebhookClient({
url: "https://discord.com/api/webhooks/<id>/<token>",
});
Do you give it some options at the end that is not visible on the pic?
a question
how do I separate the command from the other arguments
so like if someone says !help Hello it should only take help
You should parse the message and find the command name from it, let me search you a good code snippet that'll do exactly that, discordjs had a good snippet a while ago in their guide
Do you use the messageCreate now?
In this case through splitting the content by whitespaces
Here's the snippet from discord.js guide. So it gets the arguments too, for example !help arg1 arg2 it would populate the command variable with help then give all the arguments the user wrote inside args ```
client.on("message", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (!client.commands.has(command)) return;
try {
client.commands.get(command).execute(message, args);
} catch (error) {
console.error(error);
message.reply("there was an error trying to execute that command!");
}
});
Then your execute function needs to be changed a little
You need to take the args as an argument execute(message, args). You would get the first argument with args[0]
nope
Okay
thank you
No problem
Then rename the event as message is deprecated
done
also I have no errors but this code doesn't work either
client.on("messageCreate", (message) => {
if(!message.content.startsWith(PREFIX)) return;
const arguments=message.cleanContent.slice(PREFIX.length).trim().split(/ +/);
const command=arguments.shift().toLowerCase();
try {
client.commands.get(command).excute(client, message, arguments)
} catch (error) {
message.reply(`No command named ${command} found.`)
}
});
AKA only part where it saves to the database doesnt work.
Wtf is the property cleanContent?
It changes mentions from user ids to usernames
*^
yes
I just ran it
How do you know it doesnt work if you didn't send it a message or something?
Did you even get a response?
nothing at all
If not did you enable the message intent?
like you told me to use message create
i think thats
where the problem
started
Yep we talked about the intent earlier
On which djs version are you?
Nope then the event name is fine
13.2.0 to be exact
GUILD_MESSAGES is added to your intents?
it is
It might be on the prefix part, because it stops running if it cant see a prefix
let me remove that rq
arguments is a reserved word in js
Just log the message right above your prefix check.
you cant use that name on your variables
hmm
it does log the message
i think its the prefix
idk
Well if it logs it check the content
Compare it to your prefix
Did you even save your commands in a map/collection in the property commands of your client?
Yep I am testing that rn and the command is properly saved and all, the message event just isn't firing somehow
Oh I'm sorry, didn't notice that message.
Good!
Nice job!
well I mean I have the ping command but idk why its not executing it
i did
in a collection
this right?
And your key is the command name?
You have a small typo
yes
where
client.commands.get(command).excute(client, message, args); excute should be execute
oh my god
okay its working now
thank you sm
also how do I disable the mention author while replying
to a message
You may wanna check if your collection has the key stored instead of using try directly
Each error will cause a command not found
if(!client.commands.has(command)) return command not found;
ill use that
Before try and catch
But keep in mind to switch to slash commands in the future
Or use the bots mentionable name as prefix
how do i use that
is there a way I can use both
For any other messages you receive through the event no content will be available anymore after April 22
like ? and @bot
Make it that your bot will only answer when it is mentioned
oh yeah diiscord is making that an intent
wait so if we won't be able to get the message content aafter april 22 how will the private bots work
Bots in less than 75 guilds can still enable it in the dev portal
Like any other intent
oh I see
well anyway
so as I was asking how do I use both
the prefix and mention
or do I just need to stick with any one of them
If you strictly dont want to use slash commands, I think you should use the mention
because you still get the message content if you are mentioned (?)
hm
Just check if the current prefix is used or the client.user.tag is used
nic use the cleancontent
because the message content at the time of a mention will be <@your_bot_id>
thats what I was gonna ask lmao
tyty
wait so
will it print it like @username#1200 or just username#1200
Just use the OR operator on the prefix check and check if the message content starts with `<@${client.user.tag}>`
it will print ``@username#1234`
That’s the OR operator, yes
neither of them is working
WAIT
THE PREFIX ONE IS WORKING
THE MENTION DOESN WORK
the bots name is Sample User#1209
What are you checking on the first if

