#development

1 messages · Page 1907 of 1

tardy hornet
#

did not see

#

my bad

proven lantern
#

like a bot that allows the user to create their own bot that only responds to their message.

#

there is probably a better way

spark flint
proven lantern
modest maple
proven lantern
#

ez pz

spark flint
#

nah not doing that KEKW

spark flint
slender thistle
#

L

spark flint
#

I can't find how to download ffmpeg

modest maple
spark flint
#

and thats what it says I need online KEKW

modest maple
#

hmm it definitely is

boreal iron
#

lol

split hazel
#

how to make economy bot ??

boreal iron
#

Cheap licenses are available at 10,99 on the international market

split hazel
#

I wish to be a sole trader

quartz kindle
#

or just use hax

spark flint
#

yup

thorny flume
quartz kindle
#

its stupid easy

empty pier
#

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?
spark flint
#

also remove try and except, then run the command. that blocks console error logging

hollow depot
#

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

empty pier
#

always nothing

lyric mountain
hollow depot
#

oh

#

thank you!

lyric mountain
#

first result for the article

stray gulch
#

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

spark flint
stray gulch
#

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

lyric mountain
#

you could try a homemade algorithm

stray gulch
#

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

lyric mountain
#

like, levenshtein distance + array of desired words is a good start

stray gulch
#

now with the training script released it'd be possible

modest maple
#

what are you trying to do?

stray gulch
#

Detect someone saying my bot's name so I can pass the following audio into dialogflow/eventually a custom system :)

modest maple
#

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

stray gulch
#

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

lyric mountain
#

levenshtein dist

#

easiest and probably fastest one at it

#

just set a high threshold so u dont get as many fase positives

woeful pike
#

pretty sure this is supposed to based on voice

lyric mountain
#

ah, that makes more sense

stray gulch
#

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)

modest maple
#

but yes

#

simple

earnest phoenix
#

How would the bot know if a message was sent in a certain channel?

spark flint
#

which language?

earnest phoenix
#

Like a stick message

#

Djs

spark flint
#

ah

#

not my expertise

#

if it was py i would do if ctx.channel.id == channelid

#

not sure about js

wheat mesa
#

it's basically the same

lyric mountain
#

the issue comes at bigger arrays

#

and using ai for a single word fuzzy search would be overkill af

quaint rampart
#

does anyone know how to use font styles in canvas?

solemn latch
#

I used to 👀

errant perch
#

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

lyric mountain
errant perch
#

so every server has to reauthorize?

lyric mountain
#

not all

#

those which had ur bot before the scope will automatically get it

restive willow
#

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
spark flint
#

Add @commands.cooldown(4, 86400, commands.BucketType.user)

#

Underneath the @client.command()

restive willow
#

yeah I got that one, but I need the 2h bit too

spark flint
#

Ah

#

That makes no sense

#

The min time apart they can be is 6 hours

restive willow
spark flint
#

@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

restive willow
#

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

spark flint
#

Ah

#

Gotcha

hasty mulch
#
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

earnest phoenix
#

SQL injection goes brr

hasty mulch
hasty mulch
native walrus
# hasty mulch ```py Ignoring exception in command gather: Traceback (most recent call last): ...

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}*')
hasty mulch
#

Noted

native walrus
#

that way all your exit conditions are at the top and the code that runs when everything goes correctly is at the bottom

hasty mulch
#

Right now, though, I have it slated for possible future expansion

native walrus
#

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

hasty mulch
#

I'm kinda of a newbie at this stuff, so...

native walrus
severe perch
#

Is there a way to cache and send a log if AutoPoster(top_gg_token, client) causes an error?

earnest phoenix
#

How to require node fetch v2 for dont get es module error

stray gulch
#

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

onyx torrent
lament rock
pale vessel
#

Don't use 1.7.3...

#

Use the latest v2

earnest phoenix
#

I need for fetch reddit memes github status etc

lament rock
#

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

pale vessel
#

The built-in one is simple enough if you don't need to handle redirects

lament rock
#

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

pine nova
earnest phoenix
cinder patio
#

wait that uses node-fetch

#

smh

earnest phoenix
#

why will you bundle an api that already exists in the browser

cinder patio
#

read the readme?

earnest phoenix
#

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

pale vessel
#

You don't have the right to say that since you use Windows 7

lament rock
#

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

old cliff
#

can anyone suggest me some fun projects?

lament rock
#

a modular discord voice lib

#

preferably in js

old cliff
#

hmm no

#

something aside from discord?

lament rock
#

was worth a shot

#

lets see

#

how about a radio station

old cliff
#

copyright issues if I play random songs

lament rock
#

Then just dont lol

#

hand pick some songs for free use and crank it

shadow obsidian
lament rock
#

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

clear marlin
#

papi

spark flint
#

@rose warren

earnest phoenix
#

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

empty pier
# empty pier always nothing
@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.

earnest phoenix
#

because python uses indentation it took me a long time to realize the difference between the two fs

empty pier
#

?

earnest phoenix
#

You're registering the event to a stateless Bot object

#

Use the listener decorator instead

empty pier
#

ah yes, i've forgot this

#

but i know, it isn't the problem source

earnest phoenix
#

How did you setup the webhook?

#

You're using topggpy, aren't you?

empty pier
#

yes

empty pier
earnest phoenix
#

You should instantiate WebhookManager, or otherwise, it won't fire at all

empty pier
#

do i need to have a webhook on each server?

#

and can i create the webhookmanager directly in my bot?

earnest phoenix
#

It's not Discord webhooks if you meant so

empty pier
#

ok

#

thank you!

#

it works on a vps normally?

earnest phoenix
#

Yeah, you'd need an open port btw

empty pier
earnest phoenix
#

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

empty pier
#

ok

#

nothing else is needed?

earnest phoenix
#

That's all, iirc

#

Ping me if it didn't work

empty pier
#

ok, i'll try it now

grand bramble
#

Hwl cn i make an apii

austere scaffold
novel jetty
#

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]})
  }
boreal iron
#

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.

old cliff
#

can someone suggest me some fun projects?

split hazel
#

among us 2

old cliff
#

no u 3

nova basin
#

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

earnest phoenix
nova basin
empty pier
#

FRENCH POG

nova basin
old cliff
hollow depot
#
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
woeful pike
#

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

woeful pike
#

what about it

earnest phoenix
#

Everything :: $ <> <-

woeful pike
#

:: is just a type definition

#
function main(): IO<void> {}
earnest phoenix
#

$ jquery in c++

woeful pike
#

$ is just function application

earnest phoenix
#

is that your real face

woeful pike
#
runDiscordBot $ DiscordContext {token, configs}

same as

runDiscordBot (DiscordContext {token, configs})
#

actually in this case I don't even need parentheses

earnest phoenix
#

wat

#

the amount of code reduction is destroying my mind

woeful pike
#

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

earnest phoenix
#

I thought you hated haskell

woeful pike
#

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 })
}
cinder patio
#

looks so much better

woeful pike
#

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

lament rock
#

any form of net i/o can destroy type safety which is "totally awesome"

earnest phoenix
#

Do you guys use haskell for top.gg?

earnest phoenix
quaint wasp
#

uhh... 😅

#

its been verified for the gateway intents...

earnest phoenix
#

gateway intents?

woeful pike
quaint wasp
#

like guild memmbers

#

as well as now every time I invite it it crashes my discord

earnest phoenix
woeful pike
#

it's the correct tool for the problem it's solving

split hazel
#

for/againsts storing binary (images) directly in a database (e.g. mysql) as opposed to a file?

modest maple
#

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

signal estuary
lavish osprey
#

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

empty pier
#

According to the error, the Discord API encounter an issue
Wait and see if it works
Maybe it's not that

lavish osprey
#

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 🤡

empty pier
#

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?

lavish osprey
#

Jv test merci

empty pier
#

ok

rustic nova
#

Question

lavish osprey
empty pier
rustic nova
#

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?

modest maple
#

err not massively

rustic nova
#

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

earnest phoenix
#

so you need ttl too?

earnest phoenix
modest maple
#
  1. performance and caching
  2. organisational purposes
  3. persistence and redundancy
  4. snapshot and backups
earnest phoenix
#

cool terms but that's not how the real world works

modest maple
#

🤨 mmm no it really is how it works lol

wheat mesa
#

Seems like that’s how it works to me chief

earnest phoenix
#

storing images in a db is not a good practice

modest maple
#

err no?

#

again, read my message lmao

wheat mesa
#

Why not?

#

Small images seem fine

sterile brook
#

cuz u can save links on imgs

modest maple
#

for small images there is zero reason not to use a DB

sterile brook
earnest phoenix
#

a lot of things are fine and can be done but are they good practices?

sterile brook
#

but this all shit just depends on ur needs lol

modest maple
#

yes

earnest phoenix
#

this one isn't one of them

modest maple
#

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

earnest phoenix
#

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

modest maple
#

Sip yes and you think a database doesnt have this?

earnest phoenix
#

when you do it yourself, what people tend to do is usually use the 64bit of the images and just render it

modest maple
#

you mean the base64 encoding of said image?

wheat mesa
#

Am I stupid or the fuck is a “64bit of the images”

modest maple
#

never heard that term used before bloblul

earnest phoenix
#

I'm a bit sleepy ignore 64bit lmao

modest maple
#

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

native walrus
#

Isn't an object storage basically just all of that?

modest maple
#

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

stray gulch
#

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

lucid prawn
#

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
coral sigil
lucid prawn
coral sigil
lucid prawn
#

sure

spark flint
#

aight hello people

#

is there a way to make my bot rejoin the voice channel if it restarts

#

the bot is a 24/7 radio bot

#

so i want it to autorejoin the vc if it crashes

native walrus
#

make it check if it needs to join a channel when you start the process

spark flint
#

alr

spark flint
#

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

coral sigil
spark flint
#

ah epic

coral sigil
#
app.get("/:id", (req, res) => {
   const id = req.params.id;
});
spark flint
#

that worked

coral sigil
#

Nice!

spark flint
hollow depot
#

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

spark flint
hollow depot
hollow depot
spark flint
#

thats Woo's referral

hollow depot
#

thank you :))

#

oh mods were fast

spark flint
#

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

pale vessel
#

Use a library to fetch the data from the API

spark flint
#

which library

#

i don't usually use js

pale vessel
#

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()?

spark flint
#
app.get("/:id", (req, res) => {
   const id = req.params.id;
   res.send(id)
   res.redirect()
});
#

thats my code rn

#

literally nothing

pale vessel
#

Wait

#

You have an API that fetches data from another API?

spark flint
#

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

#

so it gets either "bot" or "server" from the api i've made and then redirects from there

#

yes

pale vessel
spark flint
#

true

spark flint
pale vessel
#

Where do you get the data?

spark flint
pale vessel
spark flint
#

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)

coral sigil
spark flint
#

yeah

coral sigil
#

Oh, how are you getting that response?

spark flint
pale vessel
#

I'm assuming you have some sort of database to store the ID and type?

spark flint
#

Yep

coral sigil
#

If you have a response object, just do res.data.code and res.data.type

spark flint
pale vessel
#

Check your code for syntax errors

coral sigil
#

js doesn't usually complain about ";"...

spark flint
#

hmm

#

weird

coral sigil
#

Can you show a bigger snippet of the code

spark flint
#

thats it so far

coral sigil
#

you need to initialize data

#

const data =...

spark flint
pale vessel
#

Callback needs to be async

#

You're using await

coral sigil
#

that is also true

#
   const id = req.params.id;
});``` add async like this
spark flint
#

I have

pale vessel
#

Also you're closing the callback scope too early

spark flint
#

now more errors

pale vessel
#

Get rid of that }); after const data

spark flint
#

ok

#

omfg

#

i see

#

how tf am i so retarded

coral sigil
#

:D good job though

spark flint
#

ty

#

i should have just stole my code from that

pale vessel
#

You're using cjs

#

You can't use import

spark flint
#

ah

#

its require isn't it

#
const fetch = require('node-fetch');```?
pale vessel
#

Run npm i node-fetch@cjs and do that yeah

#

V3 doesn't support cjs

#

Which is stupid

spark flint
#

ah ok

pale vessel
#

Barely anybody uses ESM, what are they thinking

spark flint
woeful pike
#

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

spark flint
#

brb installing vs code again to my coding shit in

woeful pike
#

you don't have to run your code to see if it works lol

spark flint
#

i mean i'm using cpanel

#

so i can't see the errors

woeful pike
#

no I was talking about my workflow

spark flint
#

ah

lament rock
#

errors you can't see won't hurt you :)

coral sigil
#

:D

empty pier
#

Hello,
How I can find with python the bot own role?

spark flint
#

wdym

empty pier
#

Wait 2sec

#

Like this role

#

The bot default role

spark flint
#

pls help

coral sigil
#

But then again, that name can be changed so

coral sigil
# spark flint

The error says it all, you tried to use import when you should've used require

spark flint
#

i've not tried to import tho

coral sigil
#

oh that's weird

#

Maybe it is actually the other way around

#

You are trying to import a file that needs to be required

spark flint
#

fixed

coral sigil
#

I think the other guy that was helping said that if you install a specific version of node fetch it has to be imported

spark flint
#

downgraded to node-fetch 2.6.1

coral sigil
#

yep

coral sigil
empty pier
#

Ok thanks!

coral sigil
hybrid cargo
# spark flint

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

spark flint
#

I fixed it

hybrid cargo
#

Ohh alr

#

Yeah that was one of the fix aswell, downgrading

spark flint
#

Yup

coral sigil
#

Is there an other fix?

hybrid cargo
#

Yeah, the way how u impot it

#

I forgot tho

spark flint
coral sigil
#

oh

hybrid cargo
#

Like import default and smth

coral sigil
#

yea

#

I cant remember which one but that was a thing with other packages aswell

hybrid cargo
#

But that was too much unwanted works for me. I also just downgraded it

coral sigil
#

Is there a reason you chose node-fetch over axios?

spark flint
hybrid cargo
#

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

coral sigil
#

would you use node fetch if it wasn't "broken"

coral sigil
hybrid cargo
#

Depends, axios is my first preference always

coral sigil
#

I too like axios more

hybrid cargo
#

But don't take my words. My mind is unpredictable by myself 😂. I just sometimes make dumb decisions

coral sigil
#

I think on this one it made the right decision :D

spark flint
#

i need some help now

#

Is the code

#

but requests are still being sent

#

when its just localhost:3000

#

@coral sigil ideas?

hybrid cargo
#

Wait

#

Braah

#

type is not defined

spark flint
#

i know why

hybrid cargo
#

Cuz u did not define what "type" is but used it in the res.redirect

spark flint
#

its because its getting a request when i go to localhost:3000 not localhost:3000/id

floral stone
hybrid cargo
#

^^

spark flint
#

data.type

coral sigil
#

the type is on the data

spark flint
#

not type

coral sigil
#

the data is the json response and it has a type

spark flint
#

epic it worked

coral sigil
#

oh sorry i got it now :D

spark flint
#

because the API linked the id test to the type bot

coral sigil
#

perfect

floral stone
spark flint
#

with vanity urls

floral stone
#

fair enough

#

btmc better get the first one or im coming for you

spark flint
#

it is getting oen

#

dw

#

i'm gonna set it up now

floral stone
#

cool cool

spark flint
#

i jsut need to fix my stupid mistakes

floral stone
#

anyways time for me to go back to nowplaying

spark flint
#

lmao

earnest phoenix
#

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?

tribal crow
#

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 :)

lyric mountain
#

Just cache working as it should

earnest phoenix
#

But everything worked well, now it does not work

#

The command that shows all the servers also does not work correctly

lyric mountain
#

Well, things doesn't error out of nowhere, did you change anything?

earnest phoenix
#

No

#

I just did a bot reset as I usually do

lyric mountain
#

Nothing? Like, not even an additional space or anything else?

earnest phoenix
#

No

lyric mountain
#

Show the code related to such count

earnest phoenix
#

the code that shows how many people are on all servers?

lyric mountain
#

Whatever is the code that's not working as expected

earnest phoenix
#

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

coral sigil
#

Please show the code so we can look at it and see if something's wrong...

earnest phoenix
#

But everything works well in code

#

🤦‍♂️

coral sigil
#

I think you wouldn't be here asking if it worked

earnest phoenix
#

This is not a code problem

#

This is a problem through Discord/api to bots

coral sigil
#

How is everyone else's bots online and working then

earnest phoenix
#

Because it's just a problem with the code that shows all the people and with a command that shows all the servers

coral sigil
#

Okay, could you show the code?

earnest phoenix
#

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(),

boreal iron
#

And it shows NaN as result?

earnest phoenix
#

Yes

#

More than 30 minutes ago everything was fine

boreal iron
#

Well that’s indeed strange.
Seems like something has gone wrong on the ready event.

boreal iron
#

The memberCount per guild is accurate transmitted in the ready event

woeful pike
#

o no wait js has the arguments the other way around

earnest phoenix
#

This server added my bot

#

Is there a possibility that it is through this server?

coral sigil
#

What if it's still counting the users :D

earnest phoenix
#

I'm trying to enter this server but I can not

woeful pike
#

looks like a bot farm

earnest phoenix
#

Yeah

boreal iron
hybrid cargo
earnest phoenix
#

Why?

hybrid cargo
#

Using your bot to join it's server is against tos

coral sigil
#

Discord can ban you for being a part of a scam for example

earnest phoenix
#

Hmm

woeful pike
#

imagine inviting a bot and some random dude joins your server lol

#

would ban both immediately

hybrid cargo
#

Creepy

earnest phoenix
#

It's good to know that this is against tos XD

hybrid cargo
coral sigil
#

:D

hybrid cargo
#

actually happened to me in my test server

coral sigil
#

rly?

woeful pike
#

lol

hybrid cargo
#

Yep

boreal iron
spark flint
#

I mean my friend has a command log

boreal iron
#

That’s the reason to not grant bots any permission until it necessary needs it

coral sigil
#

I think there's nothing wrong about command logging, but if you generate an invite through your bot, that's not so good

spark flint
#

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

coral sigil
#

That's handy

spark flint
hybrid cargo
coral sigil
#

I agree

spark flint
#

I just use my blacklist module to check if a user is blacklisted

hybrid cargo
spark flint
hybrid cargo
#

This was during the test stage, dont mind the pfp

boreal iron
#

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

spark flint
#

Yeah

#

Sus

#

Time to make a sever blacklist module

#

If serverid is blacklisted, leave server

earnest phoenix
spark flint
#

I mean a module for others to use as well

earnest phoenix
#

Hahaha succeeded

boreal iron
#

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

earnest phoenix
#

I left this server and everything is fine

spark flint
#

Nice

earnest phoenix
#

Just a pity that I lost the server which had 23k

coral sigil
#

Well there were 0 online

hybrid cargo
#

Quality over quantity, dont even bother if your bot is in a server with 23k inactive dead accounts

earnest phoenix
#

Yea

proven lantern
#

i think i found a troll server with ~23k users

#

they have typed help 126 times today and done nothing else

hybrid cargo
#

another one here, its a bot farm and we just had a discussion about that server like an hour ago

stray gulch
#

tl;dr: Don't assume that actions are rate limited by Discord, like changing your server name

proven lantern
#

time to create a blacklist

stray gulch
#

server blacklists are a slippery slope though

#

better to fix any issues they cause lol

proven lantern
#

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

earnest phoenix
#

Consider it a free stress test for Discord /s

woeful pike
#

adding a loop construct to a parser is harder than it seems

proven lantern
wheat mesa
earnest phoenix
#

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?

stray gulch
#

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

lament rock
#

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

earnest phoenix
#

um guys I need help w loading commands from other files in d.js

#

how do I do it

earnest phoenix
earnest phoenix
earnest phoenix
earnest phoenix
#

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
});
earnest phoenix
earnest phoenix
#

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

earnest phoenix
#

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
#

@earnest phoenix w should be capital

#

And why are you still using prefixes for commands instead of slash commands

tulip cradle
#

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: '' }```
earnest phoenix
earnest phoenix
earnest phoenix
#

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);
})
coral sigil
#

What does your ping command's execute function look like? And I think nowadays we should listen to messageCreate instead of message

spark flint
feral aspen
#

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)
coral sigil
#

Are you trying to register slash commands?

coral sigil
spark flint
#

The green name

coral sigil
#

Ohh, yeah it wasn't green earlier..

spark flint
#

Yep

#

Also ty for the help yesterday

earnest phoenix
coral sigil
earnest phoenix
coral sigil
earnest phoenix
#

still not working

coral sigil
#

yeah

earnest phoenix
#

yep so what do I do

spark flint
coral sigil
#

Does it log to the console that it loaded a ping command?

earnest phoenix
#

yes

coral sigil
#

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)
});

earnest phoenix
#

let me try

#

it doesn't print anything

coral sigil
#

So it doesn't get the command from client.commands, hmm

earnest phoenix
#

yes

#

I think

coral sigil
#

Can you send the whole file so I can test it out? Don't send your token.

earnest phoenix
#

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!`);
    }
}
coral sigil
#

Thank you, give me a sec

earnest phoenix
#

take your time

coral sigil
#

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?

earnest phoenix
#

the new one

#

latest one

coral sigil
#

Perfect

earnest phoenix
#

I forgot how do you check the version

coral sigil
#

it is in package.json, under depencies

earnest phoenix
#

13.2.0

#

there

earnest phoenix
coral sigil
#

Okay

earnest phoenix
#

yes also I tried looking for the message intents but I couldn't find it

#

I tried the GUILD_MESSAGES but didn't work

coral sigil
#

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

earnest phoenix
#

o

#

let me do that

#

rq

#

OMG

#

IT WORKS NOW

coral sigil
#

Nice!

earnest phoenix
#

was it the array

#

or the

#

intents

coral sigil
#

Both

earnest phoenix
#

I see

#

also

coral sigil
#

You need the message intent to be able to listen for message events

earnest phoenix
# earnest phoenix also

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

coral sigil
earnest phoenix
#

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

coral sigil
#

Oh okay, do you know what intents does the default give in d.py?

coral sigil
earnest phoenix
earnest phoenix
#

theres a method called cleanContent

#

does it clear the prefix part

coral sigil
#

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."

earnest phoenix
#

if yes then its really useful for me since I'm a beginner

#

I see

#

so the mentions

coral sigil
#

So it replaces the user ids to usernames

earnest phoenix
#

will get converted to the username#21312 right

coral sigil
#

You got it

earnest phoenix
#

hm what abt the

#

invalid user ids

#

what will it do

coral sigil
#

"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

earnest phoenix
#

so it wont be converted

coral sigil
#

yep

hollow tundra
#

@spare goblet

earnest phoenix
#

hm

#

alright alright

#

also

coral sigil
#

But if you want to get the mentions out of a message easily, there's message.mentions

earnest phoenix
#

I wanted to ask how do you take multiple arguments in js

coral sigil
spark flint
earnest phoenix
#

so it should take each user in each user variable

hollow tundra
coral sigil
#

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?

earnest phoenix
coral sigil
#

yes

earnest phoenix
#

cause I've seen in a lot of vids they take args and then use args[1] upto args[n] according to their use

coral sigil
#

Yea so you mean that what i wrote

earnest phoenix
#

yes

coral sigil
willow mirage
#

what the fuck

#

I just copied from discord

coral sigil
#

Where would you put that, if I get context I could help further

earnest phoenix
coral sigil
#

Then you just do hello(argument1, argument2) and so on

earnest phoenix
#

hm got it

#

thank you very much

coral sigil
#

No problem, please let me know if you have more questions/problems

coral sigil
willow mirage
coral sigil
willow mirage
coral sigil
#

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?

earnest phoenix
#

a question

#

how do I separate the command from the other arguments

#

so like if someone says !help Hello it should only take help

coral sigil
#

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?

boreal iron
coral sigil
#

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]

earnest phoenix
coral sigil
#

Okay

coral sigil
#

No problem

boreal iron
earnest phoenix
#

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.`)
    }
});
tribal crow
boreal iron
coral sigil
#

It changes mentions from user ids to usernames

earnest phoenix
#

*^

coral sigil
#

So it doesn't complain about anything but doesn't work?

#

How did you test it?

earnest phoenix
#

yes

earnest phoenix
coral sigil
#

How do you know it doesnt work if you didn't send it a message or something?

earnest phoenix
#

im not that dumb

#

i did send a message

#

with the prefix

coral sigil
#

hmm

#

Did you try logging some of those like arguments or command to see what it sees

boreal iron
earnest phoenix
#

nothing at all

boreal iron
#

If not did you enable the message intent?

earnest phoenix
#

like you told me to use message create

#

i think thats

#

where the problem

#

started

coral sigil
#

Yep we talked about the intent earlier

boreal iron
#

On which djs version are you?

earnest phoenix
#

13

#

latest one

boreal iron
#

Nope then the event name is fine

earnest phoenix
#

13.2.0 to be exact

boreal iron
#

GUILD_MESSAGES is added to your intents?

coral sigil
#

it is

earnest phoenix
#

yes

#

it is

coral sigil
#

It might be on the prefix part, because it stops running if it cant see a prefix

earnest phoenix
#

let me remove that rq

coral sigil
#

arguments is a reserved word in js

boreal iron
#

Just log the message right above your prefix check.

coral sigil
#

you cant use that name on your variables

earnest phoenix
#

let me rename it

#

nope

coral sigil
#

hmm

earnest phoenix
#

i think its the prefix

#

idk

boreal iron
#

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?

coral sigil
#

Yep I am testing that rn and the command is properly saved and all, the message event just isn't firing somehow

boreal iron
#

Isn’t firing on your end or on his?

#

Since he said it logs the message, it is

coral sigil
#

Oh I'm sorry, didn't notice that message.

earnest phoenix
#

okay I fixed the prefix error

#

now i have the

#

command not found error

coral sigil
#

Good!

coral sigil
#

Nice job!

earnest phoenix
#

well I mean I have the ping command but idk why its not executing it

boreal iron
#

And your key is the command name?

coral sigil
#

You have a small typo

earnest phoenix
#

yes

earnest phoenix
coral sigil
#

client.commands.get(command).excute(client, message, args); excute should be execute

earnest phoenix
#

oh my god

#

okay its working now

#

thank you sm

#

also how do I disable the mention author while replying

#

to a message

boreal iron
#

You may wanna check if your collection has the key stored instead of using try directly

#

Each error will cause a command not found

earnest phoenix
#

oh yeah

#

ur right

#

is there not a keyword like pass in js

boreal iron
#

if(!client.commands.has(command)) return command not found;

earnest phoenix
boreal iron
#

Before try and catch

#

But keep in mind to switch to slash commands in the future

#

Or use the bots mentionable name as prefix

earnest phoenix
#

is there a way I can use both

boreal iron
#

For any other messages you receive through the event no content will be available anymore after April 22

earnest phoenix
#

like ? and @bot

coral sigil
#

Make it that your bot will only answer when it is mentioned

earnest phoenix
coral sigil
#

there you could use the cleanContent

#

But slash commands are the way to go for sure

earnest phoenix
#

wait so if we won't be able to get the message content aafter april 22 how will the private bots work

boreal iron
#

Bots in less than 75 guilds can still enable it in the dev portal

#

Like any other intent

earnest phoenix
#

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

coral sigil
#

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 (?)

earnest phoenix
#

hm

boreal iron
#

Just check if the current prefix is used or the client.user.tag is used

earnest phoenix
#

oh yes

#

lemme try that

coral sigil
#

nic use the cleancontent

#

because the message content at the time of a mention will be <@your_bot_id>

earnest phoenix
#

thats what I was gonna ask lmao

earnest phoenix
#

wait so

#

will it print it like @username#1200 or just username#1200

coral sigil
#

the latter

#

i have to test that

boreal iron
#

Just use the OR operator on the prefix check and check if the message content starts with `<@${client.user.tag}>`

earnest phoenix
#

or is ||

#

right

coral sigil
#

it will print ``@username#1234`

boreal iron
#

That’s the OR operator, yes

earnest phoenix
#

neither of them is working

#

WAIT

#

THE PREFIX ONE IS WORKING

#

THE MENTION DOESN WORK

boreal iron
#

What did you enter ?

#

Well we can’t see it if it’s blurred lol

earnest phoenix
#

the bots name is Sample User#1209

coral sigil
#

What are you checking on the first if

earnest phoenix
#

with a space

#

I think