#development

1 messages · Page 969 of 1

pale vessel
#

and now they won't read the docs

green yarrow
golden condor
#

lmao that is my new favourite site

vale garden
#

.

slender thistle
#

-dotpost

gilded plankBOT
#

Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam.
If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.

vale garden
#

here

#

see

#

my command

#

follows the exact same code

pale vessel
#

ok?

#

what's wrong with it

vale garden
#

im getting an error

pale vessel
#

and what could it be, i wonder...

vale garden
#

execute(message, args) {
^^^^^^^

SyntaxError: Unexpected identifie

#

getting this

slender thistle
#

function before execute? 👀

green yarrow
vale garden
#

bruh

#

bruh

pale vessel
#

it's an object

#

you can't just put a function like that

green yarrow
#

multi is a baboon, if you ask a question, you need to actually listen to the responses.

vale garden
#

no

#

u

#

lol

pale vessel
#

ok but did you read what i said

vale garden
#

ok im honestly confused

#

no

#

who

green yarrow
#

are you 12

pale vessel
#

see?

slender thistle
#

Rule 1

pale vessel
#

it's an object

#

do you know how to work with objects?

vale garden
#

ok i got that

pale vessel
#

you have to define it like other properties name: value

vale garden
#

but the thing is

#

ok then why do all my other commands

#

work

#

without that

pale vessel
#

you didn't notice the difference, probably

green yarrow
#

are they arrow functions?

pale vessel
#

probably

vale garden
#
module.exports = {
    name: 'bal',
    description: "for check a user's balance",
    aliases: ['balance', 'cash'],
    execute(message, args) {
#

command that perfectly works

pale vessel
#

oh gosh

green yarrow
#

those don't work

pale vessel
#

that shouldn't work

vale garden
#

what

#

but it does?

slender thistle
#

A JSON consists of key and a value

vale garden
#

lol what

#

but it works

green yarrow
#

it doesn't.

#

right..

pale vessel
#

ok ruby you do this

green yarrow
#

no way

#

i tag out. @slender thistle you do this.

vale garden
#

just ran the command

#

and it does

#

work

green yarrow
#

no

vale garden
#

yea

green yarrow
#

..no

vale garden
#

see

#

right now

green yarrow
#

no

vale garden
#

wdym no

green yarrow
#

didn't work

vale garden
#

bruh i have proof

green yarrow
#

no you don't

vale garden
#

just showed you

#

come to my server and do the command yourself

#

if you want

green yarrow
#

nope

vale garden
#

wdym

#

dude

#

it works

slender thistle
#

You are creating a JSON that can't work when there's only a key or a value present

vale garden
#

but it does

slender thistle
#

In this case you are not creating a valid JSON

vale garden
#

why does it work

#

lol

slender thistle
#

Probably because you didn't restart your code to apply the change

green yarrow
#

if it was working, you wouldn't be here.

vale garden
#

no

#

that is a diffeent command

#

and that works

green yarrow
#

are you 12

slender thistle
#

a JSON only consists of key: value structure and you cannot do

{x: y,
myfunction()}```
vale garden
#

what is your point

green yarrow
#

actual question not rule 1

slender thistle
#

crap

vale garden
#

it works

#

and

#

you cannot say otherwise

#

now

#

im hella confused

#

lol

pale vessel
#

that's not really json but still

green yarrow
#

it's not working

#

your bad

vale garden
#

ill be honest im super confused

#

and yes it works

green yarrow
#

no

vale garden
#

dude wdym no

#

it does

green yarrow
#

it doesn't

vale garden
#

wdym by it doesnt

slender thistle
#

flaze I'm not a JS dev, cut me some slack KEKW

vale garden
#

i just showed you

autumn summit
#

anyone know how to get items from an array in mongodb for discord.py?

pale vessel
#

have you tried reading the docs?

green yarrow
#

me

autumn summit
#

can you link me the docs ive searched everywhere

vale garden
#

and it works

pale vessel
#

what guide is that

#

oh looks like the official one

vale garden
#

ye

slender thistle
#

Dear lord what

green yarrow
#

that's a mistake in the docs then

slender thistle
#

What do you call {x: y} in JS

green yarrow
#

object lmaooooooooo

slender thistle
#

KEKW Could you be more precise please

vale garden
#

but how does it work

#

for me

green yarrow
#

it doesn't

#

try again

vale garden
#

reran the code

#

and did the command again

#

still works

green yarrow
#

no it doesn't

slender thistle
#

this isn't getting anywhere

pale vessel
#

thanks ecmascript

green yarrow
#

that's the point, I hope they actually try the solution given to them, or leave.

pale vessel
#

kill me

vale garden
#

that is what i did

hasty sparrow
#

Exactly, no clue why peeps are saying it's wrong or whatever

pale vessel
#

i was definitely in the wrong on this one lul

pure lion
#

hey fellow interneters

green yarrow
#

ok what

#

since when

hasty sparrow
#

Imagine having it work on your machine and somebody else tells you it doesn't

pale vessel
#

true

#

i'm ashamed

green yarrow
#

i never knew that was added in es5 lol

pale vessel
#

me neither

hasty sparrow
#
execute: function (message, args) {
  message.channel.send('Pong.');
},

Same thing

still merlin
#

anyone know why I'm getting a error? it says expected ',' but idk where to put that. ;-;

pale vessel
#

oh

green yarrow
#
execute: (message) => {

}```
#

es6 ftw

pure lion
#

you fucked up

hasty sparrow
#

What is that break doing there?

still merlin
#

Who are you talking to @pure lion

pure lion
#

no idea

still merlin
#

oh I coppied the embed thing from a command-

green yarrow
#

you can't use break without the scope of a proper thing

#

also wack formatting

plucky heart
#

@still merlin })

still merlin
#

I removed it

hasty sparrow
#

Yep, too many closing }

vale garden
#

yo im back

green yarrow
#

pls ctrl+b or beautifier key whatever

#

oh no

#

still wrong

pale vessel
#

yo

vale garden
#

i still have a question

#

of course

pale vessel
#

ask

green yarrow
#

doesn't work

vale garden
#

lol why am i getting an error

green yarrow
vale garden
#

that was my first question

#

and still is my question

pale vessel
#

idk, you won't show me what the error or code is

hasty sparrow
#

Probably due to incorrect code

vale garden
#

i did

pale vessel
#

oh

hasty sparrow
#

Let me quickly consult my crystal ball

vale garden
#

i showed both the code and error

pale vessel
#

well then

green yarrow
#

Probably due to incorrect code
@hasty sparrow

^ biggest understatement over

vale garden
#

wait one sec

#
const Discord = require("discord.js");
const client = new Discord.Client();
const Eco = require("quick.eco")
const eco = new Eco.Manager()
let shop = new Eco.ShopManager()

module.exports = {
    name: 'buy',
    description: "for buying items in the shop",
    execute(message, args) {

      let water_bottle = args[0];

      let add = shop.getItem(message.author.id, "water_bottle");
      let subtract = eco.removeMoney(message.author.id, 750);

      if (!args)
      return message.reply("Please enter an item to be bought like this for example:\n2t!buy water_bottle")

      if (args[0])

      return message.reply(`You have bought a ${getItem.item.Name} for ${removeMoney.amount}`)


    }
}

my code ^
and im getting this error

execute(message, args) {
  ^^^^^^^

SyntaxError: Unexpected identifier

@vale garden

#

this

green yarrow
#

is a lovely site

pale vessel
#

sometimes .com is broken. if that's the case you have to use hasteb.in

#

or like anything else that's not pastebin

hasty sparrow
green yarrow
#

oh that's me

vale garden
#

ok

#

nice that worked

#

thnx

green yarrow
#

wow who knew

vale garden
#

wait

hasty sparrow
#

Which version of Node are you using?

vale garden
#

lmao

#

v12

green yarrow
#

has es6 but not es5 syntax

#

what

#

whats process.versions say

vale garden
#

what

green yarrow
#

@vale garden

#

console.log(process.versions)

#

run that

#

@vale garden

vale garden
#
{
  node: '12.16.3',
  v8: '7.8.279.23-node.35',
  uv: '1.34.2',
  zlib: '1.2.11',
  brotli: '1.0.7',
  ares: '1.16.0',
  modules: '72',
  nghttp2: '1.40.0',
  napi: '5',
  llhttp: '2.0.4',
  http_parser: '2.9.3',
  openssl: '1.1.1g',
  cldr: '36.0',
  icu: '65.1',
  tz: '2019c',
  unicode: '12.1'
}
green yarrow
#

yeah es5 should work then

vale garden
#

ok

#

cool

#

bruhhh

green yarrow
#

no

vale garden
#

now there's no error but the command doesn't work

#

lol

green yarrow
#

rewrite your entire bot

#

you did something wrong

#

somewhere

vale garden
#

its probably

#

something wrong with the command itself

#

cuz i pretty doubtful writing it

earnest phoenix
#

Is here anyone who can help me setting up shards?
I have created shards but i need help in getting data from all the shards like users, channels by id and sending embeds

green yarrow
#

@earnest phoenix lang?

earnest phoenix
#

js

green yarrow
earnest phoenix
#

aight lemme follow it

#

thx

gaunt blade
#

I use ubuntu to host my bot, and I tried using the DBL webhook thing to get votes

#

but... the vote event doesnt trigger

#

and the ready event triggers soo hmm

#

can it be the ubuntu firewall blocking it, do I need to allow something?

modest maple
#

well yes

#

You need the port open

earnest phoenix
#

Fr

gaunt blade
#

You need the port open
@modest maple well, the thing is.. it opens when any service requires it

#

and it is open according to some werbsite which checks it

modest maple
#

🤔

gaunt blade
#

but.. hmm maybe imma enable on vps-side too

modest maple
#

a FR really shouldnt do that

#

if it opens any port that a service wants thats very dangerous

#

do sudo ufw status

earnest phoenix
#

anyone know all the classes for the bot page

#

as editing mine ive done the bot-name and short description so far

#

wait i think ive figured it out

loud horizon
#

hello

#

i made a new bot to test a currency system

#

but i got this error

#
Error: ENOENT: no such file or directory, scandir './commands'
    at Object.readdirSync (fs.js:872:3)
    at /home/runner/DullSereneVolume/index.js:11:25
    at Script.runInContext (vm.js:131:20)
    at Object.<anonymous> (/run_dir/interp.js:156:20)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
cinder dove
#

You don't have a directory named ''commands'' @loud horizon

gaunt blade
#

i enabled ufw lol

loud horizon
#

oh

#

ohhh

#

thanks

cinder dove
#

np

still merlin
#

I get this error and idk what i would replace with the code.. any ideas? (SyntaxError: await is only valid in async function is the error)
the code that trys to make the mute role.

if(!muterole){
  try{
    muterole = await message.guild.createRole({
      name: "SpiderBot Mute",
      color: "#000000",
      permissions:[]
    })
    message.guild.channels.forEach(async (channel, id) => {
      await channel.overwritePermissions(muterole, {
        SEND_MESSAGES: false,
        ADD_REACTIONS: false
      });
    });
  }catch(e){
    console.log(e.stack);
  }
}
pale vessel
#

Try making the main function async. [@still merlin]

#

lol

gaunt blade
#

I have tried serveral times

#

and asked my friends to vote..

#

and the vote event doesnt trigger

#

://

hasty sparrow
#

Did you open the required/correct port?

earnest phoenix
#

and after trying for about 2 hours, i am still unable to send an embed by getting a channel from shards ;-;

#

if i use normal text in code, it sends that text... but embed...
can anyone show me any example to send an embed to a channel by getting a channel from shrds?

#

shards*

pale vessel
#

the guide told you how to do that

earnest phoenix
#

i tried it

#

but still unable to send "embed"

#

i can send texts but i am not getting how to send embed

hasty sparrow
#

Do you know how to send an embed?

earnest phoenix
#

ofc i know xD
in bot without shards, i can easily do that...
but i am facing problem in shards...

#

i just added shards today

vale garden
#

hi

earnest phoenix
#

because bot was facing ping issues and ppl suggested me to use shards

vale garden
#

wait

#

wrong server lmao

hasty sparrow
#

I'm guessing you don't know which guild has the channel you are looking for?

earnest phoenix
#

ik

#

:/

loud horizon
#

heloo

#

i have another problem

earnest phoenix
#

when i try to send normal text, it sends it... but in embed, i am facing problem

loud horizon
#
/home/runner/DullSereneVolume/index.js:52
    bot.commands.get('test').execute(message, args);
    ^^^

SyntaxError: Unexpected identifier
 




#

im getting this

hasty sparrow
#

@earnest phoenix Show your code

earnest phoenix
#
const embed = new Discord.RichEmbed()
    .setTitle("Suggestion!")
    .setColor("GREEN")
    .setTimestamp()
    .setDescription("We got a new Suggestion!")
    .addField("Suggested in Server:", message.guild.name)
    .addField("Suggested by user:", message.author.tag)
    .addField("Suggestion Details:", suggestion);
    client.shard.broadcastEval(`
    const channel = this.channels.get('${args[0]}');
if (channel) {
  channel.send(embed);
true;
}
else {
  false;
}`)

this is what i tried recently

loud horizon
#

someone help me plz

earnest phoenix
#

using args[0] (through that guide) and also using the id of server at it's place

#

channel*

#

not server :p

#

but still unable to send embed

loud horizon
#

someone hellp

earnest phoenix
#

send your code @loud horizon

hasty sparrow
#

djs v11 or v12?

earnest phoenix
#

11

#

11.5.1

loud horizon
#
const Discord = require('discord.js');
const keep_alive = require('./keep_alive.js');
const PREFIX = "t!"
const bot = new Discord.Client();
const token = process.env.DISCORD_BOT_SECRET;


const fs = require('fs');
bot.commands = new Discord.Collection();

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
    const command = require(`./commands/${file}`);

    bot.commands.set(command.name, command);
}




bot.on('ready', () => {
    console.log('YOO boi im active lol LMAOOO');
    console.log("Bot is ready with username: " + bot.user.username);
    bot.user.setActivity(`I am a test bot for testing a currency system using my own database in only one server lol`, {
        type: "STREAMING"
    });
    setInterval(function () {
        var u, user;
        for (u in bot.users) {
            user = bot.users[u];
            if (user instanceof Discord.User)
                console.log("[" + u + "] " + user.username);
        }
    }, 10000);


});

bot.on('message', message => {

if (!message.content.startsWith(PREFIX)) return;

let args = message.content.slice(PREFIX.length).split(" ");




    
    switch (args[0]) {

    case 'test'
    bot.commands.get('test').execute(message, args);
    break;

    }});
    bot.login(token);

earnest phoenix
#

there should be :

#

case "test":

loud horizon
#

ok

#

thnks

earnest phoenix
#

np

#

now someone solve my issue xD

pale vessel
#

ronak

earnest phoenix
#

yes i am here xd

pale vessel
#

the guide is v12 now by default. did you switch to v11?

hasty sparrow
#

embed is undefined

earnest phoenix
#

yep i did

pale vessel
#

all right

earnest phoenix
#

meanwhile me waits for someone to send me a solution

hasty sparrow
#

channel.send(embed);
You aren't passing the actual embed

earnest phoenix
#

hmm

#

then... what should be it?

#

anyone know how to change button colours on top gg

#

ive changed most the info and colours

hasty sparrow
#

The same way you are passing args[0] I guess

earnest phoenix
#

and i totally forgot about making my top.gg bot's page look gud

#

i tried that as well xD
lemme try it again once

#

@earnest phoenix ive forgot how to change the buttons lolllllllll

hasty sparrow
#

Inspect element

earnest phoenix
#

well, i am new to top.gg xd about 3 days ago bot was added

#

got trending new bots #3 for a day then BOOM it disappeared from trending xD

#

@hasty sparrow ive looked in inspect element i got the class just i cant seem to change the box colour i can change the text know

#

}
.titleandvote{
-webkit-background-clip: text;
-webkit-text-fill-color: black;

hasty sparrow
#

background-color: ...?

earnest phoenix
#

tried that it dont change it

clever tree
#

How could i make my bot not respond to prefix only ? He should respond to p!hello with wrong command but not to p! only.

earnest phoenix
#

nope still it is not working

hasty sparrow
#

Don't send a reply if no command is found

ancient lichen
#

i got the worst error from google.... 429.... anyone that knows how to let proxies work? ;D

summer torrent
clever tree
#

@hasty sparrow Yea. But my users should know they used a wrong commmand

summer torrent
#

ratelimit :^)

ancient lichen
#

ik

#

that's why i need proxies ;P

#

but i never used one

#

so freack me

hasty sparrow
#

Then check if the message contains anything after the prefix

clever tree
#

@hasty sparrow But how ? Im lost xd

earnest phoenix
#

then make it like that after return :
return message.reply("Reply goes here")
@clever tree

#

after returning, it will reply to the user whatever u want

hasty sparrow
#

@earnest phoenix .btn-orange has the colour (which isn't even orange, amazing devs)

clever tree
#

@earnest phoenix Thats not really my problem but thanks too. I want my bot to not respond to prefix if nothing is after the prefix.

hasty sparrow
#

When you try and find the command, check whether the command name is empty, if it is, return nothing

earnest phoenix
#

like this xd

#

now depends on what value u gave to "command" const tho

still merlin
#

my friend just joined my server for a test. I have a logging method if you have a log channel yet it didnt log it.
logging command

client.on("guildMemberAdd", (member) => {
  const channel = member.guild.channels.cache.find(
    (ch) => ch === serverlogchannel
  );
  if (!channel) return;
  let serverembed = new Discord.MessageEmbed()
    .setTitle("New Member")
    .setColor("#fff98e")
    .addField(`User`, `${message.member}`)
    .addField(`Joined At``${message.member.joinedAt}`)
    .addField(`Total Members Now`, `${message.guild.memberCount}`)
    .setFooter(`👋 🤯`);

  return message.channel.send(serverembed);
});
#

the set log command is

client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");

  switch (args[0]) {
    case "setlogchannel":
      if (!message.member.hasPermission(["ADMINISTRATOR", "MANAGE_CHANNELS"]))
        return message.channel.send(
          "**error** You need the manage channels or administrator permission to do this!"
        );

      if (!message.guild.me.hasPermission(["ADMINISTRATOR", "MANAGE_CHANNELS"]))
        return message.channel.send(
          "**error** I don't have the correct permission to do this, Please give me the manage channel's permission"
        );

      serverlogchannel = message.channel.id;

      const channel =
        message.channel.id +
        message.channel.send(`I have set this channel to the log channel!`);

      break;
  }
});```
hasty sparrow
#

message.channel.send(...)
Shouldn't it just be channel.send(...)?

still merlin
#

o

lethal hawk
#

yep

still merlin
#

thanks!

earnest phoenix
#

should not it be (ch) => ch.id ==== server.logchannel
that "id" as u are saving the ID in database

still merlin
#

Im not using a database

earnest phoenix
#

i mean, u r saving thre id...

#

xd

still merlin
#

;-; im dumb

cinder patio
#

then you can save the channel in the cache, not the channel ID, that way you won't have to find it every time

earnest phoenix
#

habit of using db everywhere xD

#

@hasty sparrow done it thanks mate all tho it dont look like a box now hahaha

hasty sparrow
#

@earnest phoenix Quick search in the d.js guild suggests stringifying the embed

earnest phoenix
#

i am not in that server i suppose

clever tree
#

@earnest phoenix @hasty sparrow Ok yea. I got it :
`var command = args[0].toLowerCase();

if(!command) return;`
earnest phoenix
#

aight

#

now time for me to get my brain fried up with shards else my bot gonna loose servers quickly ;-;

#

how many servers you got @earnest phoenix

still merlin
#

then you can save the channel in the cache, not the channel ID, that way you won't have to find it every time
confused nosies how does one to that

earnest phoenix
#

1053

#

;-;

#

oh

#

im nearly at 1k

#

nice

clever tree
#

lulw. I have 16 and i jsut want that Badge xd

earnest phoenix
#

i heard sharding is recommended at 2.5k

#

we got 1k+ 2 days ago.... gained like 700+ in a day cuz of being trending in top.gg for a day xD

#

but its 1k per shard strange lol

#

ik but few people suggested me to do it rn as my bot was getting slow

#

it has bunch of features tho...

#

alright lets go to google to search for my queries

#

hey

#

I need help

#

when i wanna add a custom help command it wouldnt let me cos there is a standard help command, how can i cancel it out?

hasty sparrow
#

More likely that the code is at fault than the shard count

clever tree
#

@earnest phoenix But. When my bot is on the botlist website. How long u think it takes to get the bot developer badge ? xd

hasty sparrow
#

Don't register the default help command

modest maple
#

@earnest phoenix bot.remove_command('help')

earnest phoenix
#

ayy thx :))

#

i use client so will edit it

#

but ye i get the point

#

g'day

#

@earnest phoenix But. When my bot is on the botlist website. How long u think it takes to get the bot developer badge ? xd
@clever tree well, cant say... if u advertise your bot in servers, it might take a week or two else maybe a year without reaching people xD

clever tree
#

Uff. I hope I get the 75 Servers fast. I mean my bot is not bad at all xd :P

earnest phoenix
#

it took almost a week to get 75+ servers WITHOUT ADVERTISING
what i did was i just hosted some events using my bot's games in my server and people invited it to their server byself xD

clever tree
#

xd

#

So i know my bot could use every emoji from every Server my bot is on. But is that with animated Emojis the same ? :o

earnest phoenix
#

and then... for badge i applied for verification and after 4 days, they stopped verifying cuz of Memorial day so, i had to wait extra xd

#

So i know my bot could use every emoji from every Server my bot is on. But is that with animated Emojis the same ? :o
@clever tree yep

#

bots can use animated emojis without any NITRO xd

#

bots are having INFINITE NITRO
richer than humans kannasip

clever tree
#

Lul. Thats frkn nice. Then I could use soo many cooö emojis to let my Bot look cooler. Thanks xd

earnest phoenix
#

xd

#

alright i am completely lost in shards now

visual swallow
#

Is there anyway that I can code the bot so it reacts to a message and if you react to it also, it will send a message?

hasty sparrow
#

Yes

visual swallow
#

Ok thank you

earnest phoenix
#

and i am gonna pause the work of sharding in main bot now until i find a solution... if anyone finds it, please either ping me or DM me if possible ;-;

misty sigil
#

how do i make

#

args with spaces?

hasty sparrow
#

@earnest phoenix Solution to what?

sinful belfry
#

@misty sigil wdym

misty sigil
#

well

#

i'm making 8ball for my bot

#

and i want the arguments to include spaces so it doesn't get cut off

sinful belfry
#

javascript?

misty sigil
#

yea

sinful belfry
#

if your args are in an array, you can do args.join(" "); to put all the args together, with spaces in between each element in the array

#

if that is what you mean

misty sigil
#

ah

#

cool and good

tight plinth
#

alright i am completely lost in shards now
@earnest phoenix f

misty sigil
#

another question

#

say, there are no arguments for the command

tight plinth
#

How do you handle args in general with your bot?

misty sigil
#

commandhandler

#

this might help

sinful belfry
#

@misty sigil what is your other question

misty sigil
#

dw got it

sinful belfry
#

ok nice

misty sigil
#

now im gonna make ab!choose

earnest phoenix
#

if i use normal text in code, it sends that text... but embed...
can anyone show me any example to send an embed to a channel by getting a channel from shards?
solution of this
@earnest phoenix Solution to what?
@hasty sparrow

misty sigil
#

can i just make args split on ; and join the " "s

earnest phoenix
#

if you split args on ; you gotta join them on ;

misty sigil
#

makes sense

tight plinth
#

Or learn js and how to use discord.js

#

It works too

woeful pollen
#

Do you know how to link other code
E.g if I have a website and I want when the website button is clicked something to happen in discord?

earnest phoenix
#

you make an api endpoint

#

and that button calls that endpoint

#

and the endpoint sends a message or makes a role, whatever

woeful pollen
#

Ah okay thanks

#

you make an api endpoint
@earnest phoenix
You say that like it's so easy

cloud vortex
#

hi guys

earnest phoenix
#
app.get("/whatever/the/fuck",function(req,res){if(!req.query["msg"]) return res.status(400).send("Invalid request");res.status(200).send(JSON.stringify({status:200,msg:req.query["msg"]}))}) 
``` @woeful pollen echo endpoint
#

call like this:

woeful pollen
#

Is that meant to go into a .js file in the root directory??

earnest phoenix
#
yourapp.com/whatever/the/fuck?msg=lol
#

where you have your express app

woeful pollen
#

Ah

#

I dont

earnest phoenix
#

mm yes

#
let app = require("express")();
app.listen(8080)
app.get("/api/echo",function(req,res){if(!req.query["msg"]) return res.status(400).send("Invalid request");res.status(200).send(JSON.stringify({status:200,msg:req.query["msg"]}))})
#

run that on your machine

#

and go to localhost:8080/api/echo?msg=hi

#

magik

woeful pollen
#

Ok I'll test it

#

Ty

#

how do I go to localhost:8080/api/echo?msg=hi

#

I just typed it into the search bar

golden condor
#

That should work

woeful pollen
#

ah its a .js file

short siren
#

@earnest phoenix thanks

earnest phoenix
#

@short siren what

woeful pollen
#

uh I think I got an error

earnest phoenix
#

npm i express eventually?

#

what does the error say

woeful pollen
#

I cant reach the page localhost:8080/api/echo?msg=hi

earnest phoenix
#

Is the .js file running

#

like did you run it with node.js

woeful pollen
#

I put it into my index.js

#

Error: listen EADDRINUSE: address already in use :::8080

earnest phoenix
#

bruh

#

change the app.listen(8080) to app.listen(8081)

#

and call the page under localhost:8081/api/echo instead of localhost:8080/api/echo

woeful pollen
#

ok ty

#

lol still cant reach the page

earnest phoenix
#

wtF

#

try annother .js file

#

like make annother one and run that one

misty sigil
#

whats that gonna chnage

earnest phoenix
#

wait @woeful pollen is the node.js process running on your pc or some hosters vps

woeful pollen
#

pc

earnest phoenix
#

hm

woeful pollen
#

oh wait

earnest phoenix
#

BRUH

woeful pollen
#

can I run it from vsc

earnest phoenix
#

So, my question is, Is it possible to see if user A removed user B's reaction in DIscord.js

#

audit log

#

i think

#

Even if the auditlog in server doesn't show it?

#

ok then no

#

alright. thanks. :o

hasty sparrow
#

@earnest phoenix I already gave you the solution

woeful pollen
#

can I just ask

#

how tf do I run the code

earnest phoenix
#

node <yourjsfilehere>?

woeful pollen
#

I did and it can't find modle

#

module

#

even tho its in the right folder

earnest phoenix
#

npm i <module1> (<module2> <module3>...)

#

in your case npm i express

woeful pollen
#

ah thanks I think I did it

#

yay it worked

#

so is that an API endpoint?

earnest phoenix
#

it can be an endpoint for everything

#

you can make a website out of it

#

you can use it as an api

woeful pollen
#

how do I use it for the api

earnest phoenix
#

if it gets called you make something based off the parameters

plucky heart
#

Hey i used .addField(`Roles [${roles.length - 1}]`, roles.length < 10 ? roles.join(', ') : roles.length > 10 ? "\n more.." : "None") and i don't know how show first 10 roles and "more..." text :v

earnest phoenix
#

for example if you call /send with parameters channelid and message you send message to channelid

rain fulcrum
#

hey

woeful pollen
#

oh okay

rain fulcrum
#

what is the command to add a game activity to your bot? ,_,

earnest phoenix
#

client.user.setActivity ig

rain fulcrum
#

thanks

earnest phoenix
woeful pollen
#

o frick is it possible for me to host .html pages as a website?

earnest phoenix
#

Yes

#
app.get("/somesite",function(req,res){res.sendFile("C:/absolute/path/to/html/file")})

OR

app.get("/somesite",function(req,res){res.sendFile(__dirname+"/htmlfile.html")})
woeful pollen
#

thanks

earnest phoenix
#

@hasty sparrow u mean that stringify thingy?

signal radish
#

hello! can anyone here tell me how to get my bot's online status and/or server count just by using the discord api?

hasty sparrow
#

Yes

earnest phoenix
#

well, i saw on google and there too it was channel.send(embed)

hasty sparrow
#

Could build the embed in the eval

earnest phoenix
#

@signal radish you mean how to change the bot's status and show in howmany servers it is in inside that status?

#

Could build the embed in the eval
@hasty sparrow already tried it xd

#

i was not sitting doing nothing for 2 hours xd

signal radish
#

nah just just actually know if the bot is online without having to go to discord

#

kinda like top.gg has an online indicator for the bots

earnest phoenix
#

u can use console.log("Bot is online") inside the ready event

signal radish
#

i mean for outside use my idea is to put it on my smart mirror

earnest phoenix
#

oh

signal radish
#

something like thids

earnest phoenix
#

then idk
i am not a web dev so, i don't have any idea about it...

signal radish
woeful pollen
#

bot.guilds.cache.size for server count

signal radish
#

that online status

misty sigil
#

bot.guilds.cache.size for server count
@woeful pollenyes

signal radish
#

like how does top.gg know that my bot is online

woeful pollen
#

bot.presence

misty sigil
#

it checks

#

obviosuly

#

luca does somthing maybe

signal radish
#

it checks
@misty sigil well yeah thats what i wanna know

#

how does it check

#

x)

misty sigil
#

luca?

#

or discord server list?

signal radish
#

how does the website check if a bot is online

#

thats what i wanna know

restive furnace
#

i think luca just listens to presence updates

woeful pollen
#

yes

signal radish
#

ahhh

woeful pollen
#

that is likely

signal radish
#

fair enough

#

i thought there would be an api link that would tell your the application statusd

#

:/

#

would be easier

restive furnace
#

nah

signal radish
#

might just make a 2nd bot and run it on the same pi as my mirror

#

and then the bot pings my othe rbot

#

🤷

woeful pollen
#

for what purpose

signal radish
#

i want to have my bot status on my smart mirror

restive furnace
#

u dont need to ping them

#

just add listener to PRESENCE_UPDATE event, on most libs it is presenceUpdate

signal radish
#

yh but this way i can also use my server counter command and display the server count on my mirror 😉

#

if it receives a reply then it means it's online and displays the counter, else it means the bot is offline and it'll tell me it's offline

hasty sparrow
#

Why not send the data from the bot to wherever you need it or add a tiny web api to your bot and have that return your data?

signal radish
#

not a bad idea either

chilly bison
#
.addField(`Roles [${roles.length - 1}]`, roles.length < 10 ? roles.join(', ') : roles.length > 10 ? "\n more.." : "None")

Shouldn't you be using roles.size?

#

Because roles is a collection, not an array

#

@plucky heart

sudden geyser
#

also nesting ternary expressions is hard to read

amber fractal
plucky heart
#

I would like to show the roles, not the number of roles
@chilly bison

chilly bison
#

?

#

What I'm saying is [${roles.length - 1}] wont work here

#

because length does not work for collections

earnest phoenix
#

mine 1057 @earnest phoenix kannasip
and this is not the place for chatting so, better no vhat here xd

chilly bison
#

and neither will "join" work

#

those are array-only

restive furnace
#

map them then

earnest phoenix
#

u will need to use map() to show all the roles

chilly bison
#

also if you just join the roles

#

the roles are not an array of ids, an array of objects

earnest phoenix
chilly bison
#

your code would only work if the structure looked like this

restive furnace
#

spoonfeed?

chilly bison
#

["role one", "role two", "role three"]

restive furnace
#

ok good

chilly bison
#

what you're probaby getting is js {119298: { name: "role", perms: {...}, id: "2222" }, 11199: { name: "role two", perms: {...}, id: "022020"} }

earnest phoenix
#

well, in simple words, @plucky heart you should use this code :-

#

const roles = member.roles.filter(r => r.id !== message.guild.id).map(r => r).join(", ") || 'none';

restive furnace
earnest phoenix
#

amd then, you can use roles to send all the roles the member has.

#

here, i have defined member as message.mentions.members.first()
so, be sure about this.

sudden geyser
empty owl
#

how do i turn that off

sudden geyser
#

What is it

empty owl
#

vs studio coe

plucky heart
#

My code is ok but i don't know how show first 10 roles and "more" text in this - > roles.length > 10 ? "\n **more..**" @earnest phoenix

chilly bison
#

I think you need two ??

plucky heart
#

He won't show me all the roles because

embed.fields [4] .value: Must be 1024 or fewer in length.```
I want the first 10 roles to show and the text "more"
empty owl
#
const fetch = require("node-fetch")
async function apiFetch(apikey, path) {
    fetch(`https://api.hypixel.net/${path}?key=${apikey}`, {
        method: "GET"
    })
    .then(response => response.json())
    .then(data => {
        return data
    })
}
module.exports = class {
    constructor(apikey) {
        this.apikey = apikey
    }
    async getPlayerCount() {
      let playerCount = await apiFetch(this.apikey, "playerCount")
      return playerCount
    }

}

For some reason, "data" returns an object with the correct number, but when I console.log playerCount it returns undefined

sudden geyser
#

You need to add return to the actual fetch request.

turbid bough
#

cause that is not how async functions work

green kestrel
#

Anyone mind giving me feedback on my premium page?

turbid bough
#

wow a moderator advertising his website 👀

#

smh

green kestrel
#

I used to design bespoke online shops a few years ago so I've taken a few things from that into it

#

It's not live yet so I'm only going to share a screenshot of anyone wants to critique

empty owl
#

o thanks

green kestrel
#

@turbid bough it's not advertising if I'm seeking feedback on a design in progress 🙃

earnest phoenix
#

hey I use a mention prefix for my bot but with commands that fetch a mentioned user it just gets my bot's mention

#

because message.mentions.users.first() is your bot in this case

#

Logik

#

I have tried using .last() if there is a mentioned user but then my check to see if there is a mention isn't needed

#

because message.mentions.users.first() is your bot in this case
@earnest phoenix no shit

#

alr

blazing portal
#

Is there a way to get the available voice channel bitrate limit for a guild? (d.js v12)

ocean socket
#

This is a repost since yesterday after asking the question I deadass fell asleep

#

Hey uhm so I am using discord.py, and when you do (prefix)help command, it shows my (almost) actual code, it shows the arguments, like this: ?kick <name> [reason=No Reason given]. How do I get rid of that? I would like it to just have an explanation. I already tried specifying help= and brief= in the command decorator. Doesnt help.

slender thistle
#

Try settings usage to an empty string

ocean socket
#

Oh wow thank you so much

#

I couldnt find the solution anywhere in the docs or in forums and it was so simple in the end xD

slender thistle
#

:p

hardy vector
#

how do i make a loop cmd with erela.js

empty owl
#

how do you compare arrays to check if theres one thing simlar between those two? discord.js javascript

earnest phoenix
#

how do i make a loop cmd with erela.js
@hardy vector you can use .setTrackRepeat(true) or .setQueueRepeat(true)

hardy vector
#

aight

#

thanks

empty owl
#

i figured it uy

lean pumice
#

@surreal sage sent you a friend request please we need to chat

merry shuttle
#

is there something wrong with bots rn?

#

my bot keeps saying it leaves servers but it's not???

slender thistle
#

Outages in this servers

still merlin
#

I'm getting a error saying I need to type a "}" and whenever I do it gives me 2 new errors. Anyone know the correct bracket thing for:

earnest phoenix
#

delete a '}'

still merlin
#

;-;

earnest phoenix
#

})}} try this?

spare lintel
#

You did not close your opening brackets

#

client.on( <-- You didn't close that, that's why the error says expected ')'

#

On your first screenshot

#

Also on your seconds screenshot this ) goes last

#

}}}}) instead of }})}

still merlin
#

still a error

spare lintel
#

Send me your code I'll fix it

still merlin
#
client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");
  switch (args[0]) {
    case "cat":
request('http://edgecats.net/random', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    let serverembed = new Discord.MessageEmbed()
          .setImage(body)
          .setColor("#00ff00")
          .setTitle("Here is your random cat")
          return message.channel.send(serverembed);

          break;
        }}}})
magic jackal
#
client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");
  switch (args[0]) {
    case "cat":
      request('http://edgecats.net/random', function(error, response, body) {
        if (!error && response.statusCode == 200) {
          let serverembed = new Discord.MessageEmbed()
            .setImage(body)
            .setColor("#00ff00")
            .setTitle("Here is your random cat")
          return message.channel.send(serverembed);

          break;
        }
      })
  }
})```
#

This should be right

spare lintel
#

Better

plucky harness
#

ok so i basically reinstalled windows

#

and my code which used to work earlier is now giving this error in newly installed windows

#

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

still merlin
#

I have a command in my bot that someone can report something like a bug ETC and the bot goes and gets the message and trys to send to a channel in the support server. would this send to the support server channel or look in that guild for the id
bot.channels.get("720734167557472358").send(contact);

sudden geyser
#

Depends. What do you want the warn command to do? You need to be specific and try yourself.

silent berry
#

what would i use in eval to fetch an invite to a server, i think my bot may be abused in it. discord.js v12.2

sick cloud
#

could anyone with typescript knowledge help me work out why this is being highlighted

silent berry
#

@sick cloud wdym highlighted

sick cloud
#

well ts thinks its errored

#

but they're config values that exist

silent berry
#

the red underline?

sick cloud
silent berry
#

that lost me

sick cloud
#

that's why i said with typescript knowledge

silent berry
#

im sorry

#

wish i could help, good luck

wicked pivot
#
if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply("Vous n'avez pas les permissions pour faire cela !");
    if (args[0] && !message.mentions) {
        message.channel.bulkDelete(args[0]).then(() => {
            message.channel
                .send(`J'ai supprimé ***${args[0]} messages*** dans ce salon pour vous !`)
                .then(msg => msg.delete(5000));
        })
    } > else if (message.mentions) {
        if (!args[1]) return message.channel.send(helpembed);
        message.channel.fetchMessages({
            limit: 100,
        }).then((messages) => {
            const filterBy = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
            messages = messages.filter(m => m.author.id === filterBy).array().slice(0, args[1]);
            message.channel.bulkDelete(messages)
                .catch(error => console.log(error.stack))
                .then(() => message.channel
                    .send(`J'ai supprimé ***${args[1]} messages de ${filterBy.user.tag}*** dans ce salon pour vous !`)
                    .then(msg => msg.delete(5000)))
        })
    } else if (!args[0] || !message.mentions) return message.channel.send(helpembed);``` the clear user does not work ![Detente_ref](https://cdn.discordapp.com/emojis/547849405210951708.webp?size=128 "Detente_ref") then it was executed but nothing
amber fractal
#

@sick cloud can you show the ../../config file's exports?

magic jackal
amber fractal
#

@magic jackal is client.resource defined?

#

if it isnt you'll need to client.resource = {} first

sick cloud
magic jackal
#

yes I just wonder if its smart to put a map inside a map or should I just add to the existing map

#

maybe I'll make a new one

#

easier that way

white anvil
#

@sick cloud try Object.freeze on ur exported object

#

or using an enum

#

Object.freeze is probably more relevant here

magic jackal
#

@amber fractal How do you clear a map? is it <Map>.clear()

#

yeah thats it

#

thanks

amber fractal
#

uh, you're welcome?

snow urchin
#
module.exports = {
    name: "guildMemberAdd",
    type: "client",
    run: (client, member) => {
      if(member.guild.id == "710276382202134549") {
        client.channels.get("710521303601250354").send(`Hello ${member}, welcome to **${member.guild.name}**!`)
      }
   }
}

Is there something I am missing, this just does not seem to work.

#
            files.forEach(file => {
                const props = require(`../Events/${file}`);
                props.type == "client" 
                                    ? client.on(props.name, (...args) => props.run(client, ...args)) 
                                    : process.on(props.name, (...args) => props.run(client, ...args));
            });
sudden geyser
#

Do you get an error? Is the error Cannot read property 'send' of undefined?

snow urchin
#

No, I do not.

sudden geyser
#

Then what happens. Did you try debugging or logging to see if the run method is actually being called.

modest maple
#

In JS,

How can i format 100000 to -> 100,000?

quartz kindle
#

you can try .toLocaleString() but it depends on your language settings

sudden geyser
#

You could also use a regular expression.

quartz kindle
modest maple
#

that works very well

#

Ty tim

#

Is there a round function or somthing similar btw?

quartz kindle
#

like Math.round()?

modest maple
#

yeah just found it lol

quartz kindle
#

nice

topaz fjord
#

now do it in kotlin react mmLol

modest maple
#

hell fucking no

#

lmao

topaz fjord
#

why not

#

type safe html is lit

modest maple
#

Other than this is a python backend and react no like that

topaz fjord
sullen prairie
#

do any of you know bd.js here?

topaz fjord
#

what is bd

sullen prairie
#

@topaz fjord it's a coding language

quartz kindle
#

its not a language

topaz fjord
#

it's a module

#

seems like a new

#

closed source lib

#

it's actually called "discord-script"

#

can't find a git repo for it

quartz kindle
#

its not a lib

#

its a framework

#

it uses discord.js

topaz fjord
#

oh god

#

why

#

please

#

quick.db

sullen prairie
quartz kindle
#

im pretty sure this is bot designer

topaz fjord
#

so its basically just discord.js

quartz kindle
#

its a discord.js framework with a small interpreter for "bd script" which is basically replacing placeholders with code

#

and that bot designer app has an option to use js or "bd script"

#

it uses discord.js v11 lmao

valid gyro
#

im having an issue with map functions where if the field is empty it causes a full stop on the command and doesnt send anything, is there A way Around this. Node.js

quartz kindle
#

dont add an empty field

valid gyro
#

im pulling off an api, so not my choice

quartz kindle
#

it is your choice which fields to add

#

if you're talking about embed fields

magic jackal
#

Forgive my ignorance but I haven't sleapt much, I was to clear a Map() then after I want to reload my commands, is this the correct way of doing it?

<Map>.clear().then(()=>{
  reloadCommands(client)
})```
quartz kindle
#

but if you're talking about reading fields off of a json response, then add validation, ie: check if the field exists and is of expected type before processing it

valid gyro
#

Gatcha, its the second one

quartz kindle
#

@magic jackal Map.clear() is not a promise

magic jackal
#

oh yeah, in stupid

sick cloud
#

how about you just

#

mymap = new Map()

#

just re make the map

white anvil
#

because that’s slower

magic jackal
#

You cant just clear the existing map? that seems really redundant for no reason

quartz kindle
#

let me microbench this lmao

white anvil
#

You are destructing old object and constructing a new one

#

instead of just altering an existing one

magic jackal
#

thats stupid

#

dont be lazy

white anvil
#

what

#

what are you referring to lol

magic jackal
#

making a new one can cause issues because if you do that in like 30 files then its useless

#

it's easier to have it made once and use accompanying functions to modify it unless you really need a new one

seems like lazy coding to me idk

white anvil
#

it’s not lazy it’s just bad practice

magic jackal
#

my issue is that my reloading command is not promise based right now which it needs to be so I can wait for the loop to finish

#

oh yeah

#

agreed

white anvil
#

just more work for garbage collection

quartz kindle
#

micro benchmarks were inconclusive

magic jackal
#

lol

quartz kindle
#

both perform the same

white anvil
#

well functionally they are identical

#

but in terms of readability it’s better to just not redefine if you can avoid it

#

it kinda suggests that your variable could be something else at any time

brisk surge
#

its another alloc

quartz kindle
#

under the hood they probably both do the same, so yeah

#

as jacher said

#

creating and maintaining one class instance is more human-friendly and readable than dereferencing a variable and reassigning it a new instance lol

magic jackal
#
const myPromise = new Promise((resolve, reject) => {
    if (client.commands) {
        resolve('Wow I found your command map, it exists!');
    }
    reject(new Error('sorry, nothing was found for command map'));
});```
#

is this correct?

white anvil
#

yea but it’s kinda redundant

magic jackal
#

hmm

white anvil
#

you aren’t doing anything blocking

#

promises should be used when a return value isn’t guaranteed at any given time

#

with synchronous code like this it is

magic jackal
#

here maybe this will help

#

let me upload this to github nvm I'll figure it out, I'm kinda tired of coding today

steel drum
#

check to see if its online lol

valid gyro
#

const TRAITS = body.special_abilities?.map(({ name, desc }) => `**${name}**: ${desc}`).join(" ");
so I have this, and vs code says its proper syntax, but glitch insists ive done something wrong

amber fractal
#

optional chaining probably isnt supported in glitches node version

#

your ?. is only in testing rn

quartz kindle
#

optional chaining is node 14+ afaik

valid gyro
#

ugh thats gonna be rough

#

ok thanks!

trim spire
#

I know a 24/7 host

#

Wait nvm your already using it xd

#

Yh

amber fractal
#

you can use the harmony flag on node 13 if glitch allows that or just use node 14

trim spire
valid gyro
#

harmony flag is a nope it looks like

#

glitch's newest node version is 10.0.0

white anvil
#

v10?!?

#

LOL

quartz kindle
#

pretty sure glitch can do v12

#
Glitch explicitly supports the latest minor (point) release of each major LTS (even-numbered) Node.js version.
You can specify the major version on Node you'd like to use as follows:
"engines": { "node": "10.x" }
#

so v10 v12 and v14 once 14 becomes LTS

#

which should happen later this year

valid gyro
#

v12 works yeah

earnest phoenix
#

Is there any way to get the total server count across all shards without using the stats event from eris-sharder? Because it suddenly says that my bot has 0 servers when it said that it has 3000 before.

quartz kindle
#

broadcastEval

#

or fetchClientValues

#

idk what eris-sharder has

digital ibex
#

why are you even using eris-sharder

#

u can get the total server count using eris

amber fractal
#

That would only give guilds in a shard

empty owl
#
async function fetchMore(apikey, path, parameters) {
    let para = parameters.replace(/\s/g, "%")
    console.log(parameters)
    return fetch(`https://api.hypixel.net/${path}?key=${apikey}${para}`, {
        method: "GET"
    }).then(response => response.json())
}```
 "cannot read property 'replace' of undefined
its defined doe
amber fractal
#

above para, console.log(parameters)

#

guarantee you it's undefined

empty owl
#

WOOOH

#

i see the typo

#

ty

earnest phoenix
#

can anyone teach me API
discord.js v11

#

Js is so wierd

#

I would recomment python :/

#

well , that didint help

#

but thanks

#

there's no point in using v11 and under

#

they're going to stop working very soon due to discord forcing intents and stateless design

#

use latest

#

i am new to discordjs

#

ok

#

i dont know if i can understand v12 or not

#

ok

#

but thanks

quartz kindle
#

v12 is the same thing as v11 with a few changes

earnest phoenix
#

ohhhh

#

nice

#

that helped a lot

quartz kindle
#

learning v12 is only difficult if you already know v11 and are too used to v11

earnest phoenix
#

well

quartz kindle
#

or if you already have a lot of v11 code and need to convert it to v12

#

if you're starting, go for v12

earnest phoenix
#

well that is the main prob

#

but i think embed work the same in v12

quartz kindle
#

they work the same, only the class name changed

earnest phoenix
#

yes

#

Discord.EmbedMessage

#

right?

quartz kindle
#

MessageEmbed

earnest phoenix
#

oh

#

well

#

thanks tim

warm nest
#

dot

fiery hill
#

Hey guys, just a quick question... Is it okay to not use MySQL to hold guild data if the bot i'm using is meant for a restrained amount of servers ? I would continue using json this way.

earnest phoenix
#
const Discord = require('discord.js');
const client = new Discord.Client();
const fetch = require('node-fetch');
const { Client, DiscorsMessageEmbed } = require('discord.js');
const Prefix = "t!"

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setStatus('available')
  client.user.setPresence({
      game: {
          name: 'Varibalites',
          type: "PLAYING"
      }
  });
});

if (command === 'cat') {
    const { file } = await fetch('https://aws.random.cat/meow').then(response => response.json());

    message.channel.send(file);
}

SyntaxError: await is only valid in async function

#

idk why is that error

#

anyone help?

empty owl
#

uh

#

read the error?

earnest phoenix
#

i did

#

i didint understand tbh

clever tree
#

How could i make a leaderboard command with using a JSON file to save the level data. So fs. How could i get all data from the guild the command is asked on and how could i sort it from high to low and only for 10 members ? I knwo its very much imput. But maybe someone is able to help me :)

empty owl
#

also ```js
if (command === 'cat') {
const { file } = await fetch('https://aws.random.cat/meow').then(response => response.json());

message.channel.send(file);

}``` is not in an event

earnest phoenix
#

i got this from discordjs.guide

empty owl
#

dont just copy and paste code

earnest phoenix
#

well i was testing it

#

i am just trying to use API

empty owl
#

You need to put that in an event with a async function to use await

earnest phoenix
#

and what is async?

light laurel
#

brUh

earnest phoenix
#

dont judge me , i am new to js

empty owl
haughty night
#

client.on('ready', async () => {

fiery hill
#

I believe that if you use await or then, it's either one or the other. Async and so await and then are meant to be used with functions that take time to resolve

glossy elk
#

hi

empty owl
#

How could i make a leaderboard command with using a JSON file to save the level data. So fs. How could i get all data from the guild the command is asked on and how could i sort it from high to low and only for 10 members ? I knwo its very much imput. But maybe someone is able to help me :)
@clever tree https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

glossy elk
#

who is the person that copies code

clever tree
#

@empty owl Thanks i will try my best ;)

empty owl
#

you can get all the people's spot from a certain guild

#

wait

#

you can filter out people who arent part of the guild

#

and sort after

#

dont judge me , i am new to js
@earnest phoenix Also, you have to define command, and put that in a message event

earnest phoenix
#

ty

digital ibex
#

anyone know why the lines still show underneath the words when i have ```css
text-dectoration: none

broken shale
#

look at how you spelled it @digital ibex

digital ibex
#

pretend its spelt correctly lul

earnest phoenix
#
if(command === Prefix + 'meme') {
  let msg = await message.channel.send("Fetching");
  fetch('https://meme-api.herokuapp.com/gimme')
      .then(res => res.json())
      .then(json => {
          let embed = new Discord.RichEmbed()
              .setTitle(json.title)
              .setImage(json.url)
              .setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
          msg.edit(embed)
      });
}

SyntaxError: await is only valid in async function

#

pls help

lyric mountain
#

You can't use await outside an async function

sudden geyser
#

didn't someone already point out the issue

earnest phoenix
#

how do i add a async function?

lyric mountain
#

async somefunction() {
stuff
}

earnest phoenix
#

tysm

#

@earnest phoenix the Message event should be like this client.on("message", async(message) => { codes here });

#

u probably doesn't have "async" in the first line

#

ohhh , right

#

thanksssss

lyric mountain
#

Idk if an async message listener would be a nice thing to have

earnest phoenix
#

well, i have it in my whole code...

lyric mountain
#

Wouldn't it slow down the execution?

earnest phoenix
#
client.on("message", async(message) => {
if(command === Prefix + 'meme') {
  let msg = await message.channel.send("Fetching");
  fetch('https://meme-api.herokuapp.com/gimme')
      .then(res => res.json())
      .then(json => {
          let embed = new Discord.RichEmbed()
              .setTitle(json.title)
              .setImage(json.url)
              .setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
          msg.edit(embed)
      });
}

@earnest phoenix is this right?

#

it's hid to have it to perform some actions such as createMessageCollector() createReactionCollector() etc

lyric mountain
#

Because....yknow.....async doesn't allow parallel processing

earnest phoenix
#

where have u defined "command" @lyric mountain

lyric mountain
#

Me?

earnest phoenix
#

oops

#

wrong pong xd

#

ping*

lyric mountain
earnest phoenix
#

@earnest phoenix

#

in if (command === COMAND)

lyric mountain
earnest phoenix
#

THE SECOND LINE

lyric mountain
#

That's a comparison

earnest phoenix
#

sry caps

lyric mountain
#

Not a definition

earnest phoenix
#

sorry if i am dumb , i am new to js

lyric mountain
#

Just a question

earnest phoenix
#

yes

lyric mountain
#

Where did you get that code?

earnest phoenix
#

oof i meant, you would have defined command as const command = message.content....... or something like this somewhere... right?

#

uhhhhhhh

#

one sec

lyric mountain
#

Did you copy it from somewhere?

earnest phoenix
#

if not, your code will not work cuz it doesn't know what "command" is

#

so, i prefer this :-

#

lemme write the code xd

#
const Discord = require('discord.js');
const client = new Discord.Client();
const fetch = require('node-fetch');
const { Client, DiscorsMessageEmbed } = require('discord.js');
const Prefix = "t!"

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setStatus('available')
  client.user.setPresence({
      game: {
          name: 'Varibalites',
          type: "PLAYING"
      }
  });
});


client.on("message", async(message) => {
if(command === Prefix + 'meme') {
  let msg = await message.channel.send("Fetching");
  fetch('https://meme-api.herokuapp.com/gimme')
      .then(res => res.json())
      .then(json => {
          let embed = new Discord.RichEmbed()
              .setTitle(json.title)
              .setImage(json.url)
              .setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
          msg.edit(embed)
      });
}

client.login('TOKEN');
#

this is the full code

lyric mountain
#

Did you copy it from somewhere?

earnest phoenix
#

no

#

its mine

#
const command = message.content.toLowerCase();
if(command === Prefix + 'meme') {
  let msg = await message.channel.send("Fetching");
  fetch('https://meme-api.herokuapp.com/gimme')
      .then(res => res.json())
      .then(json => {
          let embed = new Discord.RichEmbed()
              .setTitle(json.title)
              .setImage(json.url)
              .setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
          msg.edit(embed)
      });
}```
#

gud for beginning coders...
jist made "command" have a value message.content.toLowerCase()

#

oh ok

#

ty

#

amma try it

#

np

#

tysm ✨

lyric mountain
earnest phoenix
#

the moment i realised my bot is not working in this server

#

error SyntaxError: Unexpected end of input

#

just a sec

#

i put in the same code

#

of ye

#

at last, add });

#

k

#

amma try it

#

tysm ✨

#

np again xd

#

not working

#

same error

#

Mhm..

#

lemme go through ur code once again

#
client.on("message", async(message) => {
  const command = message.content.toLowerCase();
  if(command === Prefix + 'meme') {
    let msg = await message.channel.send("Fetching");
    fetch('https://meme-api.herokuapp.com/gimme')
        .then(res => res.json())
        .then(json => {
            let embed = new Discord.RichEmbed()
                .setTitle(json.title)
                .setImage(json.url)
                .setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
            msg.edit(embed)
});
#

sorry that i am disturbing u or bothering u

#

i am just have been trying to get it to work for 2 days

#

so yeah

#

sorry

#

ok u replaced } with });

#

lemme send ya complete code

#

k

#
  const command = message.content.toLowerCase();
  if(command === Prefix + 'meme') {
    let msg = await message.channel.send("Fetching");
    fetch('https://meme-api.herokuapp.com/gimme')
        .then(res => res.json())
        .then(json => {
            let embed = new Discord.RichEmbed()
                .setTitle(json.title)
                .setImage(json.url)
                .setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
            msg.edit(embed)
}
});```
#

amma test

#

now i got 2 errors 🤣

#

u didn't have to replce } with });
u had to add }); in new line xd

#

lol what errors now?

#

SyntaxError: missing ) after argument list

#

at line number? it should be written there

#

?

#

nvm

#

i get it...
i should have saw ur code completely again xd

#

so u want to code?

#

the*