#development

1 messages Ā· Page 982 of 1

stable grail
#

it worked before i just embed it

#

am i missing something?

#

oh nvm

#

i forgot value xD

earnest phoenix
#

le big brain

stable grail
#

im working on 2 bots at the same time haha

earnest phoenix
stable grail
#

so its normal to get confused or forget something

earnest phoenix
#

idk why im getting an error

#

import asyncio

#

that is throwing an error

#

idk why

spark breach
#

My bot just got muted for '"You do not have enough permissions" spam,
However it didn't happen in my server where I tested the commands...

this is the code (this shouldn't spam right..?):

    if(message.content.startsWith("Beaver post-servercount")) {
    if(!message.member.hasPermission("ADMINISTRATOR", explicit = true)) return message.channel.send("You don't have enough permissions, sorry!")
        

        dbl.postStats();
        message.react(":white_check_mark:");
        console.log("Posted server count!")
    }
})```
plucky harness
#

how to get bots icon url in py

brave rover
viral lynx
#

can someone uhh tell me 24/7 script?

plush escarp
solemn latch
#

24/7 script

spark breach
#

you can't use a script to let a bot stay online 24/7

brave rover
#

You'll want a VPS if you wanna run it 24/7 @viral lynx

earnest phoenix
#

What's happening in here , lol

solemn latch
#

looks like map is undefined @plush escarp
make sure it is defined before reading it

viral lynx
#

hm.. will this work in DBM? I only have it.

earnest phoenix
#

dbm is bad

#

we dont support bot makers

#

if you have questions or issues related to them, go complain to the developer

viral lynx
#

oh ok :I

plush escarp
#

@solemn latch But the thing is that it is defined

#

Ill send you the code, 1 min

earnest phoenix
viral lynx
#

or imma just give up, im an Animator, not a Scripter

fast glen
#

some syntax error

earnest phoenix
#

its legit just import asyncio

fast glen
#

lul

plush escarp
earnest phoenix
#

import asyncio how does this cause an error

#

you're not closing some of your statements or some shit

#

its in the first line of code

slender thistle
#

Send the rest

brave rover
#

why do you have an fstring on your first line if you're importing a module weirdsip

slender thistle
#

Oh wait

#

What's your Python version

earnest phoenix
#

3.8.3

#

i dont have an f string lmao

slender thistle
#

(If only the page actually loaded for me)

plush escarp
fast glen
#

In the code there isn't that import asyncio

earnest phoenix
#

ik

#

i removed it in the pasted one

#

idk

solemn latch
#

@plush escarp
is client.categories actually set?

fast glen
#

Pro Gamer I think that somebody would help you if they knew how

slender thistle
#

Why are field values in a set

plush escarp
#

idk

#

what do i need to set it to

#

@solemn latch

solemn latch
#

its your bot

plush escarp
#

...

solemn latch
#

looks like it should be set to the categories of commands of your bot

digital ibex
#

hi, i have this code:; ```ts
public getMember(search: string, { members }: Guild): Member | undefined {

#

any ideas?

plush escarp
#

how do i fix the error?

digital ibex
#

in typescript

solemn latch
#

have client.categories set

#

to whatever it should be, according to what you want it to be.

plush escarp
#

hmm

#

how do i set it?

solemn latch
#

client.categories = what you are setting it to

plush escarp
#

what do it set it??

solemn latch
#

i cant tell you what your bot does Hmmm

plush escarp
#

Ok, tysm

civic idol
#
client.once('ready', () => {
    console.log('Online');
    client.user.setActivity('test', { type: 'STREAMING'});
});

How come when I set streaming it doesn't work but with listening, watching, and playing works?

plush escarp
#

bc u need to put a link

#

to a twitch

#

, URL: 'LINK HERE',

civic idol
#

oh ok thank you!

plush escarp
#

šŸ™‚

plush escarp
#

@solemn latch the help command is working but all of the commands are not showing up

earnest phoenix
#
client.on('message', message => {
    if ((message.content.toLowerCase() === 'test')) {
    message.delete();
    message.channel.send(new Discord.MessageEmbed()
    .setAuthor(message.author.tag + " uyarıldı", message.author.avatarURL())
    .setDescription("**Sebep**: Reklam"))
        .then(msg => {
            msg.delete({ timeout: 20000 })
  console.log(" ")
  console.log(" • " + message.author.tag + " reklam yaptı, reklam iƧeriği: " + message.content)
  console.log(" • ID'si: <@" + message.author.id + ">")
  console.log(" ")
    })
}
});
``` Guys I want more words for this command, not only `test`. How can I add more words without making copy paste?
solemn latch
#

you can use ||
|| means or

#

if (message.content.toLowerCase() === 'test' || message.content.toLowerCase() === 'test2')

quartz kindle
#

you can also use array.includes if you want to have more than 2 or 3 options

earnest phoenix
#

What do you mean @quartz kindle?

#

I am new on these stuff...

quartz kindle
#

if([a,b,c,d,e,f].includes(message.content.toLowerCase()))

tight plinth
#

I am new on these stuff...
@earnest phoenix learn basic js, it helps a lot

earnest phoenix
#

@quartz kindle it does not work

quartz kindle
#

show code

earnest phoenix
#
client.on('message', message => {
    if(["a","b","c","d","e","f"].includes(message.content.toLowerCase()))
    message.delete();
    message.channel.send(new Discord.MessageEmbed()
    .setAuthor(message.author.tag + " uyarıldı", message.author.avatarURL())
    .setDescription("**Sebep**: Reklam"))
        .then(msg => {
            msg.delete({ timeout: 20000 })
  console.log(" ")
  console.log(" • " + message.author.tag + " reklam yaptı, reklam iƧeriği: " + message.content)
  console.log(" • ID'si: <@" + message.author.id + ">")
  console.log(" ")
    })
});``` it works like this but when I type a it starts to showing messages and doesnt stop
quartz kindle
#

you removed the block lol

tight plinth
#

{}

quartz kindle
#
if() {
  // code here
}``` not ```js
if()
  // code here
heavy pollen
#

I'm trying to open my bot with 1 commands & 2 events and sharding, but my bot not starts with v12. When I decrease version to v11, it starts very well. Any suggestion?

Command is only sends "hello" message.
Events: ready, message (clean)
Server.js: Loading only events & commands.

#

I'm seeing timeout error in v12

quartz kindle
#

what error?

digital ibex
#

hi, how can i fix SyntaxError: Cannot use import statement outside a module in ts w/o changing it to require?

tight plinth
#

Is require really a problem

#

And ts is weird

digital ibex
#

wym is require really a problem?

tight plinth
#

#development message
I had to completely u install nidejs from apt, u install node 13 & 14 from nvm and finally reinstall node 13 via nvm, what a main

summer torrent
#

@heavy pollen any error

tight plinth
#

wym is require really a problem?
Just use require lol

heavy pollen
#

what error?
@quartz kindle you know the error, I'm trying with 0 project too. Not works, my bot have 4k servers.

quartz kindle
#

@heavy pollen try this:
make a new file, like test.js
in this file put

const { Client } = require("discord.js");
const client = new Client({shards:"auto"});
client.on("debug",console.log);
client.login("your token here")

then run node test.js

lost herald
#

how would i detect in a string if a role is being mentionned, and if so replace it with the role's name

#

so i might have a string role: <@&11111111111111111111111111> but i would want the output to be role: hey

#

assuming a role exists with id 11111111111111111111111111 and called "hey"

#

python btw

quartz kindle
#

use some regex to search for a pattern that starts with <@& and ends with >

#

then use this id to get a role object from whatever roles cache/store python uses, or try to fetch it from the api

#

if it exists, use its name

lost herald
#

ill put my face into that hopefully it works

heavy pollen
#

Trying, 1 miunte..

lost herald
#

turns out thats complicated so imma just check for each role in the guild to see if its mentionned if so put it's name

quartz kindle
#

doesnt python have a way to check mentions from a message?

lost herald
#

probably but ehh

quartz kindle
#

like discord.js has message.mentions

slender thistle
#

There's also message.raw_mentions that returns integer ID

lost herald
#

yeah but im inputting a string that doesn't come from a message

surreal notch
#
    if(message.content.startsWith("&ping")) {
            message.channel.send('Pong! Your ping is `' + `${Date.now() - message.createdTimestamp}` + ' ms`!');        
    }
})```
lost herald
#

like for outputs my func detects if it can or not send embeds, if it can great otherwise make sure no pinging the role

surreal notch
#

My bot doesn't reponding

quartz kindle
long yew
#

can anyone help me with a mute command?

#

i got this so far

#
client.on('message' async message => {
    let mainrole = message.guild.roles.cache.find(r => r.name === 'Muted')
    if (message.content.startsWith(prefix + 'mute') {
  }
})
quartz kindle
#

ah if its not coming from a mention then i guess regex is your best bet

surreal notch
#

tim sir help me also

quartz kindle
#

there are many websites that can help you generate a regex for finding text in between two patterns

lost herald
#

my thing did not work lol

#

ill fix it

tight plinth
#

@surreal notch @long yew learn js & discord.js please

long yew
#

@surreal notch i know a ping command that is embeded and shows the ping in ms for the bot

#

dm me

surreal notch
long yew
#

i'll help

tulip ledge
#

I'm on a new pc and just installed node, vsc and mysql also transferred over my files but when I try to node index.js it errors then I tried to npm init but that gives me a similar error:

npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
tight plinth
#

Install npm

#

Ez fix

quartz kindle
#

are you on windows?

long yew
#

@surreal notch i sent u a friend request so i can dm u

tulip ledge
#

Yes Tim

quartz kindle
#

if so, you need to install node.js from the node.js website, then restart the computer

tulip ledge
#

Oh I already installed from website but didnt restart I'll try

#

Alright its working now but now I have this issue:

     throw err; // Rethrow non-MySQL errors
      ^

Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
#

Fixed it

earnest phoenix
#

When i'm trying do "npm uninstall <module> " or "npm i <module>" its giving me this error/warning; https://hasteb.in/ugaveyin.js

What should i do for fix this?

blissful carbon
#
if(youtube.startsWith("https://www.youtube.com/") || youtube.startsWith("https://youtu.be/"))
        {
          voiceChannel.join().then(connection => {
            const dispatcher = connection.play(ytdl(youtube, {filter: 'audionly'}));
            dispatcher.on('end', ()=> voiceChannel.leave());
          }); //voiceChannel connection & play yt
          let youtubeembed = new Discord.MessageEmbed()
            .setColor("#FF0000")
            .setTitle("ķ˜„ģž¬ ģž¬ģƒģ¤‘: " + youtube)
            .setTimestamp()
            .setFooter("http://invite.magicjipange.kro.kr", "https://i.ibb.co/mG6TX82/unnamed-1.jpg");
          message.channel.send(youtubeembed);
        }
        else
        {
          message.channel.send(":x: 유튜브 urlģ„ ė³“ė‚“ģ£¼ģ„øģš”! :x:");
        }
      }

what would be wrong with this code?

#

I'm using discord.js , ffmpeg, ytdl-core, discordjs@opus

#

and opusscript

earnest phoenix
#

use regexp

chrome olive
#

How can I delete an element in an array if there are several identical elements?
ex:

const array = [1, 1, 1, 2, 3, 4, 4];

// and I want to remove just one of the duplicates 
// something like this => array.removeOneItem(1)
// result: [1, 1, 2, 3, 4, 4]
sudden geyser
#

Use <Array>.indexOf and <Array>.splice(index, 1)

earnest phoenix
#

@chrome olive Use splice

chrome olive
#

thx

earnest phoenix
#

@quartz kindle Are you there? Can you look here?

sudden geyser
#

I mean the install "technically" worked?

deep knot
tight plinth
#

Is message even defined

deep knot
#

hm i tink yes?

tight plinth
#

You're not sure?

deep knot
#

no

#

i forgot how to define something..

tight plinth
#

Learn basic js

#

And how to use discord.js

deep knot
#

i just copyed it

tight plinth
#

You copy pasted code?

#

Dont

#

Never

deep knot
#

oh

#

one of my friends tells this to me its good to copy

#

i didnt know

tight plinth
#

Well it's not

deep knot
#

i appreciate this

#

ty man

tight plinth
#

If you code yourself you will also learn how to use the code you just written and you'll know what it does, and how to debug it if there is an error, etc

#

Np

deep knot
#

i got it

#

ty again

heavy pollen
#

@quartz kindle I think shards is loaded, but when i eval client.shard it says null, client.shard.count 'count' of null, console spams:

[WS => Shard 1] Heartbeat acknowledged, latency of 137ms.
[WS => Shard 2] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 2] Heartbeat acknowledged, latency of 142ms.
[WS => Shard 3] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 3] Heartbeat acknowledged, latency of 140ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 0] Heartbeat acknowledged, latency of 142ms.
[WS => Shard 1] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 1] Heartbeat acknowledged, latency of 138ms.
[WS => Shard 2] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 2] Heartbeat acknowledged, latency of 156ms.```
#

client.ws.shards:

  0 => [WebSocketShard],
  1 => [WebSocketShard],
  2 => [WebSocketShard],
  3 => [WebSocketShard]
}```
earnest phoenix
#

(Discord.js v12 sürümünde yapılan değişiklikler)

heavy pollen
#

I read already

#

If you are suggesting me

#

Can you help me

#

🤷

earnest phoenix
#

I'm v11

#

sorry i can't

heavy pollen
#

Are you v11????

earnest phoenix
#

yeah

heavy pollen
#

I think it works thanks @quartz kindle

earnest phoenix
#

You think so?

heavy pollen
#

no

#

I think it not works @quartz kindle :/

#

My bot is started

#

But shards is not spawned

#

When I try client.guilds.cache.size, says total guilds size

quartz kindle
#

shards:"auto" = internal sharding

earnest phoenix
#

Who can help me,too?

quartz kindle
#

if it works with internal sharding, but not with the sharding manager, then something is wrong with your shard files

earnest phoenix
#

Anyone?

#

I need help tho, i was creating role command and it shows this error (node:2692) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role at RequestHandler.execute (C:\Users\PC\Desktop\DsBot\node_modules\discord.js\src\rest\RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:97:5) (Use node --trace-warnings ...to show where the warning was created) (node:2692) 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: 1) (node:2692) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Please Help!

heavy pollen
quartz kindle
#

@earnest phoenix delete your node_modules folder and try again

heavy pollen
#

Not works sharding with your code

quartz kindle
#

also, then you do uninstall, you need to use --save

heavy pollen
#

I try lots of shard file

quartz kindle
#

npm uninstall <module> --save

earnest phoenix
#

so, it will work, right?

quartz kindle
#

@heavy pollen that was a code for testing, and it worked

#

so the problem is not ip ban, its something wrong with your shard file

hardy vector
#
const {MessageEmbed} = require('discord.js')
const querystring = require('querystring')
module.exports = {
    name: 'facts',
    description: 'make fatcs meme',

    execute(client, message, args) {
        const query = querystring.stringify(args.join(' '));

        if(!query) return;

        else {
            let embed = new MessageEmbed()
            .setColor("RANDOM")
            .setImage(`https://api.alexflipnote.dev/facts?text=${query}`)
            message.channel.send(embed)
        }
    }
}``` when i do _facts [ word ] nothing happens and no error is logged
heavy pollen
#

@heavy pollen that was a code for testing, and it worked
@quartz kindle i will try this sharding file:

const { ShardingManager } = require('discord.js');
const moment = require("moment");
const config = require('./settings/config.json');

const manager = new ShardingManager('./server.js', {
    token: config.token
});

manager.spawn();

manager.on('shardCreate', (shard) => console.log(`${moment().format("ss:mm:HH DD/MM/YYYY")} | #${shard.id} numaralı shard başladı!`));```
#

Will work right?

quartz kindle
#

yes

#

the problem is your shard files

#

server.js

#

and all the things you load

heavy pollen
#

Can you inspect my server.js file?

earnest phoenix
#
        if(!msg.member.hasPermission('ADMINISTRATOR')) return msg.channel.send(PermEmbed);


        let person = msg.guild.member(msg.mentions.users.first());
        if(!person) return msg.channel.send("Can't find user! :angry:");
        let rRole = args.join(" ").slice(1);
        if(!rRole)return msg.channel.send("Usage: ?role (@username) (role)");
        let typrole = msg.guild.roles.cache.find(role => role.name = rRole);
        if(!typrole)return msg.channel.send("Invalid role!")
        person.roles.add(typrole)
        msg.channel.send("Done!")
        return; 
``` When i type ?role @mention (role) it says done but it doesnt give role help please
heavy pollen
earnest phoenix
#

event yerine olay yazmak,krall

#

:d

heavy pollen
#

I'm Turkish so writing Turkish messages.

quartz kindle
#

the problem is not this file directly, its something that this file is loading

#

add some console.log's in your command loaders and event loaders, see if it gets stuck on a file

heavy pollen
#

Okay, I will catch everyting.

earnest phoenix
#

@quartz kindle can u help me with this pls

quartz kindle
#

no errors?

earnest phoenix
#

i have 1 error

quartz kindle
#

show

earnest phoenix
#
    at RequestHandler.execute (C:\Users\PC\Desktop\DsBot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:2692) 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: 1)
(node:2692) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
quartz kindle
#

theres your answer

earnest phoenix
#

It says Unknow Role but role is there :3

heavy pollen
#

Manager destroyed error

#

I need to spawn more shards? (It is currently auto)

#

1 minute

#

I think fixed

earnest phoenix
#

congrats!

quartz kindle
#

@earnest phoenix console.log(typrole) before adding

earnest phoenix
#

k

quartz kindle
#

@hardy vector console.log(query)

heavy pollen
#

@earnest phoenix why do you speak unnecessarily? I'm only trying to get help because I don't know how to solve error.

earnest phoenix
#

What?

heavy pollen
#

better?

earnest phoenix
#

I didn't said to u

#

I just said "Congrats!" for fixing your error.

hardy vector
#

ok

earnest phoenix
#

now shut.

heavy pollen
#

It's unnecessarily.

#

You don't need to say, I'm not speaking with you

earnest phoenix
#

Don't mouth off.

heavy pollen
#

Only English please.

earnest phoenix
#

@quartz kindle Role { guild: <ref *1> Guild { members: GuildMemberManager { cacheType: [Function: Collection], cache: [Collection [Map]], guild: [Circular *1] }, channels: GuildChannelManager { cacheType: [Function: Collection], cache: [Collection [Map]], guild: [Circular *1] }, roles: RoleManager { cacheType: [Function: Collection], cache: [Collection [Map]], guild: [Circular *1] }, presences: PresenceManager { cacheType: [Function: Collection], cache: [Collection [Map]] }, voiceStates: VoiceStateManager { cacheType: [Function: Collection], cache: Collection(0) [Map] {}, guild: [Circular *1] }, deleted: false, available: true, id: '717311333103566858', shardID: 0, name: 'GTI Hub', icon: null, splash: null, region: 'europe', memberCount: 3, large: false, features: [], applicationID: null, afkTimeout: 300, afkChannelID: null, systemChannelID: '717315684924915734', embedEnabled: undefined, premiumTier: 0, premiumSubscriptionCount: 0, verificationLevel: 'NONE', explicitContentFilter: 'DISABLED', mfaLevel: 0, joinedTimestamp: 1591090806330, defaultMessageNotifications: 'ALL', systemChannelFlags: SystemChannelFlags { bitfield: 0 }, vanityURLCode: null, description: null, banner: null, rulesChannelID: null, publicUpdatesChannelID: null, ownerID: '461243536008937472', emojis: GuildEmojiManager { cacheType: [Function: Collection], cache: Collection(0) [Map] {}, guild: [Circular *1] } }, id: '717311333103566858', name: '@!713079087761195129> Test', color: 0, hoist: false, rawPosition: 0, permissions: Permissions { bitfield: 104320577 }, managed: false, mentionable: false, deleted: false }

hardy vector
#

@quartz kindle it didnt log anything

deft condor
#

How to you make a bot dm the person who kicked the bot from the guild

quartz kindle
#

then you dont have a query

#

and if !query return

#

so nothing happens

#

@deft condor you cant

hardy vector
#

but i am providing a query for it

#

so

#

shouldnt it give me the pic

quartz kindle
#

if your code says there is no query then there is no query

hardy vector
#

but

quartz kindle
#

now you have to find out what happened with it, why is your query disappearing

hardy vector
#

ok

quartz kindle
#

the answer is probably your querystring module

#

which seems very unnecessary in the first place

#

you could just remove it entirely

hardy vector
#

but they told me i needed it to encode the spaces

quartz kindle
#

you can encode with encodeURI or encodeURIComponent

spark breach
#

what do I need to do for this because when i type in 'emitter' nothing shows up ;-;

quartz kindle
#

those are built in javascript functions

#

@spark breach console.log(client._events)

hardy vector
#
const {MessageEmbed} = require('discord.js')
module.exports = {
    name: 'facts',
    description: 'make fatcs meme',

    execute(client, message, args) {
        const fact = encodeURI(args.slice(0).join(' '));

        if(!fact) return;

        else {
            let embed = new MessageEmbed()
            .setColor("RANDOM")
            .setImage(`https://api.alexflipnote.dev/facts?text=${fact}`)
            console.log(query)
            message.channel.send(embed)
        }
    }
}```
prime cliff
#

Why do you have 11 message listener events in the first place anyway Thonkeng

spark breach
#

Why do you have 11 message listener events in the first place anyway :Thonkeng:
idk

hardy vector
#

use cmd handler

spark breach
#

Havent thought about that actually

prime cliff
#

Well if you don't know then how is anyone gonna help you debug it

earnest phoenix
#

@quartz kindle U can see log what came idk what to do :/

quartz kindle
#

@earnest phoenix do ...roles.add(...).catch(console.log)

earnest phoenix
#

i did it

#

and it is same

quartz kindle
#

it should catch a better error

earnest phoenix
#

ok i did fixes

#

and it shows diffrent

#

@quartz kindle DiscordAPIError: Unknown Role at RequestHandler.execute (C:\Users\PC\Desktop\DsBot\node_modules\discord.js\src\rest\RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:97:5) { method: 'put', path: '/guilds/717311333103566858/members/713079087761195129/roles/717311333103566858', code: 10011, httpStatus: 404

copper cradle
#

@spark breach what do you need 11 message listeners for

#

did you actually make an event listener for each command?

quartz kindle
#

@earnest phoenix thats the @ everyone role

earnest phoenix
#

I created Test role

#

and typed ?role @granite pagoda Test

#

lol

quartz kindle
#

ah

#

i see the problem

copper cradle
#

are you getting the role object from it?

quartz kindle
#

this is the problem

prime cliff
#

You know pinging roles is a bad idea for a command..

spark breach
#

did you actually make an event listener for each command?
Yeah .-.

#

Idk why tho xD

copper cradle
#

yes you know

earnest phoenix
#

@quartz kindle What should i do ?

quartz kindle
#

===

copper cradle
#

bc you don't know what an if statement is, or what a switch statement is, or what a module is

earnest phoenix
#

ok ill try with ===

quartz kindle
#

@earnest phoenix check if the channel the message was sent in matches said channel

copper cradle
#

that's why you used a message event for each command

earnest phoenix
#

@quartz kindle I tryed with === and now says "Invalid Role!" but role does exist

quartz kindle
#

console.log(rRole)

earnest phoenix
#

ok @quartz kindle i did with that and it just type @!713079087761195129> Test in console

copper cradle
#

there you go

quartz kindle
#

thats hthe name of the role its trying to find

silent berry
#

does anyone know a command manager i can use?

i an still learning js but was told i need to use a command manager.

quartz kindle
#

so you have to fix your args

copper cradle
#

@silent berry a command manager is something you make

silent berry
#

@copper cradle ik that but does anyone have any templates?

quartz kindle
#

if you're using discord.js their guide has one

silent berry
#

@quartz kindle thank you, can you link it please

quartz kindle
earnest phoenix
#

@quartz kindle Im little confused idk waht to do :/

quartz kindle
#

your code is let rRole = args.join(" ").slice(1);

#

and rRole was @weary thorn Test

earnest phoenix
#

yes

quartz kindle
#

so args.join(" ").slice(1) is converting your command to that

#

which is wrong

#

so you need to change the args

earnest phoenix
#

ok

quartz kindle
#

look at what the code is doing

#

if args is [@magic oasis,Test] then args.join(" ") will join them with a space

#

and it becomes @rustic tusk Test

#

then you do .slice(1)

#

which removes the first item

#

and it becomes @!763969376593> Test

#

so your problem is that the order is wrong

earnest phoenix
#

so i need just args.join(" ")

quartz kindle
#

that will give you @sinful walrus Test

#

which is not what you want

earnest phoenix
#

ok

quartz kindle
#

i'll give you a hint

#

you want to remove the first item, BEFORE joining

copper cradle
#

index the second element of your args

#

easier

earnest phoenix
#

osi just need Test

quartz kindle
#

role names can contain spaces

#

so he cant index

copper cradle
#

ah yes

#

then yeah

#

remove the first element

#

and then join the rest

#

what tim said

earnest phoenix
#

k

#

ty

#

I did it

#

waht i did is

#

let rRole = args.slice(1).join(" ");

#

and it shows just

#

" Test "

quartz kindle
#

alright, so now it should work

earnest phoenix
#

it works

#

Thank you šŸ˜„

#

for help

#

oh

#

i have 1 problem now again

#

so role is

#

" Good Member "

#

and what i think

#

that i cant add roles that have space

#

what i need to add at let rRole = args.slice(1).join(" ");

quartz kindle
#

that should work for spaces too

earnest phoenix
#

oh what i realised is

#

that it need to be exact name Like Good Member it cant add if i type Good member

wind kayak
#

how do you use puppeteer on a vps?

copper cradle
#

@earnest phoenix turn both things to lower case

#

then you can do RoLe NamE and it'll still work

#

change role.name === rName to role.name.toLowerCase() === rName.toLowerCase()

#

and then both will be lowercase

round garden
#

what's the official top.gg npm package?

solemn latch
#

npm install dblapi.js

earnest phoenix
#

What?

solemn latch
earnest phoenix
#

Hm

#

If the bots are accepted, then it will be necessary to connect the top.gg API?

copper cradle
#

no

quartz kindle
#

its optional

copper cradle
#

it's not required

#

their api is used for you to post your servercount

#

if you want to

quartz kindle
#

and get votes

halcyon ember
#

the channel exists but it keeps giving me this error

#

20.06 14:06:39 [Bot] Ready!
20.06 14:09:35 [Bot] undefined
20.06 14:09:35 [Bot] /commands/exchange.js:64
20.06 14:09:35 [Bot] message.guild.channels.cache.find(channel => channel.name === exchange-${state.exchange}).send('<@&713541593121947699>, <@'+message.author.id+'> wants an exchange with note: '+details)
20.06 14:09:35 [Bot] ^
20.06 14:09:35 [Bot] TypeError: Cannot read property 'send' of undefined
20.06 14:09:35 [Bot] at Timeout._onTimeout (/commands/exchange.js:64:98)
20.06 14:09:35 [Bot] at listOnTimeout (internal/timers.js:549:17)
20.06 14:09:35 [Bot] at processTimers (internal/timers.js:492:7)

earnest phoenix
#

Discord. Js?

bitter harness
#

Can someonr help me with my bot

earnest phoenix
#

@halcyon ember

bitter harness
#

Someone*

quartz kindle
#

console.log(state-exchange)

earnest phoenix
#

@bitter harness yes

bitter harness
#

U can

earnest phoenix
#

Русский или Английский знаешь?

bitter harness
#

...

quartz kindle
earnest phoenix
#

😳 šŸ‘

quartz kindle
#

lmao

slender thistle
#

Lmaooo Tim

#

Where did you even learn that

quartz kindle
#

i watch russian videos

slender thistle
quartz kindle
#

i know a few more

solemn latch
#

@bitter harness what do you mean the bot wont let you add commands?

copper cradle
#

I only know Я Узбек

halcyon ember
#

@earnest phoenix ye

rancid tartan
#

I need help with my bot, I proofread it, but nothing seems wrong, although Glitch says there is something wrong.

earnest phoenix
#

@halcyon ember 😳

#

@copper cradle 😳

prime cliff
#

Glitch says there is something wrong.
If you don't explain what the issue is noone can help you

halcyon ember
#

@quartz kindle it creates the channel without any problems

rancid tartan
#

Error: Cannot find module 'discord.js'

slender thistle
#

ŠŸŃ€Š¾ŃˆŃƒ Š¾ŃŃ‚Š°Š²Š°Ń‚ŃŒŃŃ в #memes-and-media если не ŃŠ¾Š±ŠøŃ€Š°ŠµŃˆŃŒŃŃ ŠæŠ¾Š¼Š¾Š³Š°Ń‚ŃŒ или ŠæŃ€Š¾ŃŠøŃ‚ŃŒ помощи с программированием

halcyon ember
#

guild.channels.create(`exchange-${state.exchange}`, { type: 'text', parent: '713550063145844766',}

#

that works

rancid tartan
#

I installed the package, and inserted a const

quartz kindle
#

@halcyon ember ah so thats a channel you just created? then you need to await its creation

copper cradle
#

remove it from your package.json and then re add it@rancid tartan

halcyon ember
#

await guild.channels.create?

quartz kindle
#

yes

halcyon ember
#

oh

quartz kindle
#

otherwise it will try to find it before it finishes creating

halcyon ember
#

its fine if i put it in a async function?

copper cradle
#

you'll need to

halcyon ember
#

cuz if i use await it says only available in async

#

kk

copper cradle
#

since await can only be used inside async functions

quartz kindle
#

yes but you have to put everything inside the same function

copper cradle
#

I like deno, cuz it's globally async

#

so you can use await anywhere

quartz kindle
#

you can also do that in chrome dev tools

copper cradle
#

yeah

quartz kindle
#

top-level await is a stage 3 proposal anyway

#

it should become the norm everywhere

halcyon ember
#

@quartz kindle this isnt working

    await guild.channels.create(`exchange-${state.exchange}`, {
          type: 'text',
          parent: '713550063145844766',}

setTimeout(function () {
      run()
      message.guild.channels.cache.find(channel => channel.name === `exchange-${state.exchange}`).send('<@&713541593121947699>, <@'+message.author.id+'> wants an exchange with note: '+details)}```
pale vessel
#

looks like a loop

halcyon ember
#

what

amber fractal
#

the way you sent your code makes it look like it's a loop

#

but I assume it's two parts of the code

#

It's just because of the formatting it's hard to tell what's going on

halcyon ember
#

yea

#

theres the function at the top

#

and at the bottom theres the settimeout which makes it wait for a bit and then it makes the channel

earnest phoenix
#

How i can create a messageCollector in DM

restive furnace
#

user#dmChannel

earnest phoenix
#

ok

wind kayak
#

@pale vessel didnt you have that bot taking screenshots of websites?

pale vessel
#

perhaps

wind kayak
#

puppeteer?

pale vessel
#

yeah

wind kayak
#

how did you get it to work on vps?

pale vessel
#

by doing npm i puppeteer

wind kayak
#

it just wont screenshot anything

#

but it works flawlessly on my own pc

pale vessel
#

did you get any error?

wind kayak
#

no

pale vessel
#

can you show me the code you used?

#

probably isn't the cause since it works on your local machine

wind kayak
#

the code is fine, but on my vps it just gets stuck at trying to take the screenshot

pale vessel
#

did you use catch?

modest maple
#

does it actully have a gpu

#

lol

wind kayak
#

yeah

pale vessel
#

if it doesn't you can disable it

#

it's weird since it should throw an error if something is wrong

wind kayak
#

worth a shot, how would i do that

pale vessel
#

--disable-gpu iirc

#

let me check

#

should be correct

quartz kindle
#

@halcyon ember you didnt close the channels.create function?

#

you have channels.create({}

wind kayak
#

nope, disable gpu didnt help

halcyon ember
#
      state = sql.prepare("SELECT * FROM state WHERE id = 1").get()
    guild.channels.create(`exchange-${state.exchange}`, {
          type: 'text',
          parent: '713550063145844766',
          topic: details,
          permissionOverwrites: [
              {
                  allow: 'VIEW_CHANNEL',
                  id: message.author.id
              },
              {
                  allow: 'VIEW_CHANNEL',
                  id: '647216160038977547'
              },
              {
                  deny: 'VIEW_CHANNEL',
                  id: guild.id
              },
              {
                  allow: 'VIEW_CHANNEL',
                  id: '617037497574359050'
             },
              // {
              //     allow: 'VIEW_CHANNEL',
              //     id: '569955063519510549'
              // },
              {
                  allow: 'VIEW_CHANNEL',
                  id: '713541593121947699'
              }
          ]
      })
    await message.guild.channels.cache.find(channel => channel.name === `exchange-${state.exchange}`).send('<@&713541593121947699>, <@'+message.author.id+'> wants an exchange with note: '+details)
    }```
#

i did close it lol

#

that code up there it still cant find it

#

but instead of the bot shutting down it just sends error

quartz kindle
#

where's the await now?

halcyon ember
#

await message.guild.channels.cache.find(channel => channel.name === exchange-${state.exchange}).send('<@&713541593121947699>, <@'+message.author.id+'> wants an exchange with note: '+details)

quartz kindle
#

on the channels.create

halcyon ember
#

oh both need em huh ok

earnest phoenix
#

does someone know wtf happens/is happening to glitch.com

modest maple
#

yes its dying

earnest phoenix
#

thats so annoying

modest maple
#

because people use it for free bot hosts

#

so have fun with that

earnest phoenix
#

;-;

#

i cant host it on my pc else it would destroy me bandwidth

pale vessel
#

you might be out of luck then

summer torrent
#

My code:

  const reactions = await m.awaitReactions((reaction) => {
    reaction.emoji.name === emoji 
  }, { time: 5000 });
console.log(reactions)```
Why output is `Collection [Map] {}` (empty collection)
restive furnace
#

just get pi@earnest phoenix

pale vessel
#

still bandwidth

earnest phoenix
#

pi?

restive furnace
#

oh, didnt remember that everyone doesnt have unlimited bandwith like me sad

pale vessel
#

raspberry pi

earnest phoenix
#

b r u h

#

now i wasted my money on boosting a server on glitch ;-;

#

nice

#

bruh i worked so hard for my bot

restive furnace
#

you rly boosted an app?

earnest phoenix
#

yes

restive furnace
#

on glitch

earnest phoenix
#

yes

restive furnace
#

oh ok

earnest phoenix
#

i want my money back >:(

#

Lol

restive furnace
#

make a ticket

earnest phoenix
#

wdym?

#

wdym by ticket?

restive furnace
#

make a support ticket on glitch

earnest phoenix
#

uh how

restive furnace
#

lemme take look

#

brb

wheat jolt
#

what would be a smart way to fetch 50 users at once

earnest phoenix
#

ok

restive furnace
wheat jolt
#

happy bday @pale vessel @modest maple

tulip ledge
#

Any idea why .splice(-1, 0, "string") adds to the second to last?
For example:
["item", "item2", "item3"].splice(-1, 0, "item4")
Result: ["item", "item2", "item4", "item3"]

wheat jolt
earnest phoenix
#

thanks

#

@restive furnace ok, where can i create a ticket?

tulip ledge
#

@wheat jolt doesn't really help have been over it like 3 times already

restive furnace
#

@earnest phoenix just create new thread

round garden
#

What's the ratelimit for bots/votes?

earnest phoenix
#

can i host anywheres for free?

pale vessel
#

free, yes, good uptime, no

tulip ledge
#

yes at glitch or heroku but I paid is always better

earnest phoenix
restive furnace
#

or if you want private repls, you have to pay, so easier to get vps.

nimble escarp
#

Anyone here with AWS experience who could help out?

#

Need to make EFS accessible "publicly"

earnest phoenix
#

can someone help me setup on heroku?

#
            let user = message.author.createDM();
            const collector = user.createMessageCollector(filter, { time: 30000 });
            collector.on('collect', m => {
                console.log(m.content);
            });
            collector.on('end', collected => {
                message.author.send("Canceled");
            });
pale vessel
#

ghost ping lul

earnest phoenix
#

pls help me

#

:))

pale vessel
#

createDM returns a promise so you have to await it

earnest phoenix
#

oh

#

@restive furnace whats vps

solemn latch
#

vps is a virtual private server

earnest phoenix
#
        async function applyQuestion() {
            if(i > apply[message.guild.id].questions.length) return message.author.send("Your application will be submit ! Thanks you for using me ;)");
            let embed = new RichEmbed()
                .setColor(red_light)
                .setTitle(apply[message.guild.id].questions[i])
                .setFooter(message.guild.name + " | This will be end after 30sec")
            message.author.send(embed);
            let user = await message.author.createDM();
            const collector = user.createMessageCollector(filter, { time: 30000 });
            collector.on('collect', m => {
                questions[i] = m.content;
                i++;
                applyQuestion();
            });
            collector.on('end', collected => {
                message.author.send("Canceled");
            });
        }

Not working sad

#

ok then how do i get a "vps"

nimble escarp
#

you buy it from a provider

hoary lily
#

Uhm I'm kinda confused. But how can I stop client.on from listening?

#

return will do?

nimble escarp
#

client.on is not a traditional listener, it's an event listener.

earnest phoenix
#
                collector.on('collect', m => {
                    answers[i] = m.content;
                    console.log(answers[i]);
                    i++;
                    applyQuestion();
                })

It is not console.logging

hoary lily
#

Yeah I just want to stop it from listening

#

An on/off I mean the "off"

hoary lily
#

Thanks

earnest phoenix
#

pls help me

wheat jolt
#

ghost ping lul
@pale vessel not a ghost ping, was a happy bday from me :)

pale vessel
#

NguyenXD ghostpinged me

wheat jolt
#

ah

earnest phoenix
#

nope

#

xD

wheat jolt
#

How can I send messages to the gateway on discord.js v11?

digital ibex
#

is there a way to disable intents on eris?

earnest phoenix
#

Hi guys im using command handler and i have 1 small problem

#

const logChannel = client.channels.cache.find(channel => channel.name === 'mbot-log')

#

when i put that in ban.js

#

it says client dont exist

#

and idk hwo to add client there

#

Learn js

hollow saddle
#

Specifically how to use node.js

earnest phoenix
#

yeah

#

:3

#

nvm i realised

#
if (urlValid) {
      try {
        songInfo = await ytdl.getInfo(url);
        song = {
          title: songInfo.videoDetails.title,
          url: songInfo.videoDetails.video_url,
          duration: songInfo.videoDetails.lengthSeconds
        };
      }```

```TypeError: Cannot read property 'title' of undefined

help ?

grizzled isle
#

Looks like song is undefined

prime cliff
#

Wong

earnest phoenix
#

wdym with undefined ?

prime cliff
#

Either songInfo or videoDetails

#

Your videoDetails is invalid are you using the correct functions

earnest phoenix
#

i think so

wicked pivot
#

how do we change an array?

#

at least something in an array

amber fractal
#

array[index] = item ..?

wicked pivot
#

thx

#

remove on array ? @amber fractal

amber fractal
#

You're probably looking for splice

#

array.splice(index, 1) deletes 1 item at index from array

#

in place

#

it can also be used to insert items over other items

wicked pivot
#

but its not removing it?

amber fractal
#

it does remove it

wicked pivot
#

ok i look

amber fractal
#

splice also returns the removed values as an array

wicked pivot
#

problem is that in my array there is text and it's quite random

earnest phoenix
#

Can anyone help mw?

#

i regenerated the token but not worked

wicked pivot
#

"error request 429" in google

earnest phoenix
wicked pivot
#

You will receive the error message 429 Too many requests because the user sent too many requests in a given period of time (this can be a plugin, a DDoS, or another chosen). It is a server which asks you to stop sending requests.

earnest phoenix
#

You can't see?

stable grail
#

how do i use the <style> thing on the website?

earnest phoenix
#

@wicked pivot I'm not sending requests

wicked pivot
#

well error 429 says that now i don't know

amber fractal
#

you're gonna have to show some code

#

we know what the error means, but not why you're getting it

earnest phoenix
#

@earnest phoenix why u pinged #development he is in development

#

?

#

šŸ¤”

#

Idk,why its happening..

#

So idk which code

#

xD

solemn latch
#

Im not sure what you expect us to do if you dont provide info

amber fractal
#

well when did you start getting it

#

what code changes did you make

#

it wouldnt just come out of nowhere

earnest phoenix
#

Oof

#

But why

#

I did welcome and leave commands

#

So its happened

#

Right

wicked pivot
#
msg[reponse.selectedText] = input``` (msg = array)
it does not work
sick gazelle
#

Hi everyone !
I'm trying to create a first bot and I love the embed message class, I find the design very good but this class is too restrictive for me (image always on the bottom for example). So my idea is to create a canva that looks exactly like the embed message. My probleme over here is that the canvas is not display at full size. Does anyone have an idea to help me ?

prime cliff
#

Discord will always auto size images depending on width/height theres nothing you can do aside from using a specific width/height that works best and is clear

sick gazelle
#

There is no way to force the default display size ? At least for my canvas ?

quartz kindle
#

nope

sick gazelle
#

So... I can't use the embed message, I can't use canvas... There is no other way to do this message design ? šŸ˜…

quartz kindle
#

nope

#

you can only use what discord allows you to use

#

everyone plays by the same rules

prime cliff
#

You can send them as attachments not embed images

quartz kindle
#

but they'll still show at the bottom of the embed

sick gazelle
#

const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'contrast.png');

prime cliff
#

No Tim no embeds

sick gazelle
#

That's what I'm doing but the size auto reduce

prime cliff
#

As attachments

quartz kindle
#

yeah, he asked about using images as a replacement for embed

#

but the image will be resized to be smaller than an embed

prime cliff
#

Yup

sick gazelle
#

The top is the canvas and the bottom is an embed message. Hope there is a way to make the canvas the same size as embed but as you say, it seems impossible ^^'

quartz kindle
#

yup, impossible

prime cliff
#

Why not put the embed image in the 2nd one?

sick gazelle
#

It's just the idea I just had ^^

#

I'm gonna try

plush escarp
sacred wraith
#

You're trying to read property 'map' of undefined. Without the code, I don't think we can help you further.

plush escarp
#

ok

#

ima give u de code

#

1 sec

#

@sacred wraith

sacred wraith
#

If you look at the stack trace, this error actually originated from help.js

willow river
#

Can anyone solve this problem for me, and will I give it money when it is finished?

plush escarp
#

@sacred wraith So I need to give u the help cmd?

solemn latch
#

@willow river are you on windows?

plush escarp
#

hi woo

#

can u dm me

willow river
#

Yeah @solemn latch

plush escarp
#

i need help for something

quartz kindle
#

i believe i already told you that canvas has some requirements on windows

solemn latch
quartz kindle
#

even sent you the link with instructions before (this link ^)

solemn latch
#

yeah you did

willow river
#

Would you solve it for me? I will give you a Windows server to enter and resolve it for me @solemn latch

sick gazelle
#

@prime cliff Not working either... šŸ˜…

solemn latch
#

its a 3 step process @willow river

willow river
#

And I will give you money @solemn latch

solemn latch
#

install node gyp
install gtk 2
install node canvas

#

its 3 steps

shy turret
#

Someone's broken.

#

So, I have let random = Math.floor(Math.random() * maxdamage) + mindamage; in my code

#

the maxdamage and mindamage are the correct number variables

#
mindamage = 10
maxdamage = 100
#

but the random thing became

solemn latch
#

sometimes it goes over 100?

shy turret
#

yah that happened

#

how

solemn latch
#

let random = Math.floor(Math.random() * (maxdamage - mindamage)) + mindamage;

shy turret
#

I tried it in the console too

Math.floor(Math.random() * 100) + 10;
103
sacred wraith
#

lol you're way faster @solemn latch xD

solemn latch
#

i was already typing it

#

before he finished

shy turret
#
let random = Math.floor(Math.random() * (maxdamage - mindamage)) + mindamage;

change it to this?

#

OH

#

I GET IT

#

because 10 + 100

#

@solemn latch would i need to add a + 1 so the number doesn't become 0?

#

well like

#

i mean

#

nvm im gonna add + 1

round garden
#

What's the ratelimit for bots/votes?

solemn latch
#

60 per minute

amber fractal
#

all are 60r/60s globally

round garden
#

yikes

solemn latch
#

im not sure why youd need more than once a minute tho

amber fractal
#

just use webhooks and a database

rancid tartan
#

@copper cradle back to you, no that did not work

#

remove it from your package.json and then re add it@rancid tartan

misty sigil
#

i wanna use a database

#

for discord bot prefixes

#

any pointers?

solemn latch
#

šŸ¤”

#

use the database you choose like the docs say to

quartz kindle
#

use whatever you feel more comfortable with

honest perch
#

I find mongo pretty nice and easy to manage if that helps

copper cradle
#

@rancid tartan that should've worked lol

misty sigil
#

the search for a free db provider continues

quartz kindle
#

all dbs are free lol

#

or have a free version

#

unless you want to use a remote database service

misty sigil
#

or i could just abandon this idea

#

and just have 1 prefix

wicked pivot
#

I can't change something in an array how do we do it? js array [name of the value to be changed] = the new name

quartz kindle
#

wat

#

like this? [a,b,c,d] => [z,b,c,d]?

wicked pivot
#

I’m not sure it’s very clear I’m going through google translate

#

I make an example

#
var array = ['a', 'b', 'c']

array["a"] = "d"```
#

that's good ?

quartz kindle
#

you have to find the index

#

array[0] = "d"

#

you can use array.findIndex()

#
let index = array.findIndex(item => item === "a");
array[index] = "d";
wicked pivot
#

ahhhhhhhhhhh thank you

quaint pendant
#

Issues with .setPresence.
My command "example" is below. The error I get and more is below as well.

    client.user.setStatus('available')
    client.user.setPresence({
        game: {
            name: '!chhelp',
            type: "WATCHING",
            url: "example url"
        }
    });```
Errors include.
.setPresence not being defined. 
Not displaying any text on the bot as it should, meaning no changes. 

All code I've found is either outdated or does not function.
Simply looking for a fix or updated code.
pale vessel
#
online
idle
invisible
dnd``` these are the only statuses you can set
#

available is not one of them

#

you can get rid of setStatus since you can just set it in setPresence

#

game has been renamed to activity

quaint pendant
#

Seems to still not show anything.

#

I'll keep poking around then come back.

pale vessel
#

then you have something wrong with your code

earnest phoenix
#

How would I get my bot to show emojis from other servers?

I know how to make it show normal emojis but I don’t know how I’d make it show ones from other servers

pale vessel
#

you can find the emoji from your client or if you already know the emoji name and id, you can just use <:name:id>

#

<a:name:id> for animated emojis

earnest phoenix
#

Oh okay thanks

misty sigil
#

need ideas

#

for commands

summer torrent
#

moderation?

misty sigil
#

fun

#

or moderation idgaf

small prairie
#

Whats happened to glitch

misty sigil
#

idk

small prairie
#

no space left error

misty sigil
#

you ran out of disk space

small prairie
#

All my test bots are down

#

Yea im sure i didnt

misty sigil
#

just you pal

small prairie
#

It just happened out of nowhere

#

wasnt like that before

candid granite
sacred oyster
#

im trying to use a new command handler

#

and i ahev an error

#

if anyone can help please do

quaint pendant
#

Still having issues with setPrefrence

Updated code.

        status: 'online',
    activity: {
        name: '!chhelp',
        type: 'WATCHING'
    }
});```

Error.
Cannot read property 'setPrefrence' of null
solemn latch
#

šŸ¤”

#

is client defined

quaint pendant
#

Yes.

empty owl
#
    let team1 = await teamPrompt(bot, message, "1")
    let team2 = await teamPrompt(bot, message, "2")
    if (numberOFTeams > 2) {
        let team3 = await teamPrompt(bot, message, "3")
    }  
    if (numberOfTeams > 3) {
        let team4 = await teamPrompt(bot, message, "4")
    }
    let obj = bot.games.observe(message.guild.id)
    for (let i = 0;i < numberOfTeams;i++){

        obj.teams[`team${i}`] = 
    }``` 
discord.js v12, is there any way I can set the value to team1/2/3/4 based off of i
solemn latch
#

is this being ran in the client on ready event @quaint pendant

quaint pendant
#

It's being ran after the bot logs in as that could cause the issue, I can try the ready event, but may get the same thing.

hardy vector
#
const BaseCommand = require('../../utils/structures/BaseCommand')
const {MessageEmbed} = require('discord.js')
module.exports = class HelpCommand extends BaseCommand {
    constructor() {
        super('help', 'utility', []);
      }
    
      async run(client, message, args) {
        const categories = [...new Set(client.commands.map(cmd => cmd.category))];
        const embed = new MessageEmbed()

        for (const id of categories) {
             const category = client.commands.filter(cmd => cmd.category === id);

            embed.addField(`${id} (${category.size})`, category.map(cmd => `\`${cmd.name}\``).join(", "));
        }

        return message.channel.send(embed);
      }
}```(node:5684) UnhandledPromiseRejectionWarning: TypeError: client.commands.map is not a function
    at HelpCommand.run (C:\Users\kenra\Desktop\Galaxy\src\commands\info\help.js:9:56)
sacred oyster
#

const Discord = require("discord.js"),
fs = require("fs");

module.exports = client => {
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.helps = new Discord.Collection();

fs.readdir("./commands/", (err, categories) => {
if (err) console.log(err)
console.log(Found total ${categories.length} categories.);

categories.forEach(category => {
  let moduleConf = require(`../commands/${category}/module.json`);
  moduleConf.path = `./commands/${category}`;
  moduleConf.cmds = [];
  if (!moduleConf) return; 
  client.helps.set(category, moduleConf);
  
  fs.readdir(`./commands/${category}`, (err, files) => {
    console.log(`Found total ${files.length - 1} command(s) from ${category}.`);
    if (err) console.log(err);
    let commands = new Array();
    
    files.forEach(file => {
      if (!file.endsWith(".js")) return;
      let prop = require(`../commands/${category}/${file}`);
      let cmdName = file.split(".")[0];
      
      client.commands.set(prop.help.name, prop)
      
      prop.conf.aliases.forEach(alias => {
        client.aliases.set(alias, prop.help.name);
      })
      
      client.helps.get(category).cmds.push(prop.help.name);
    })
  })
})

})
}

hardy vector
#

thats easy

#

incorrect path

empty owl
#
 let team1 = await teamPrompt(bot, message, "1")
    let team2 = await teamPrompt(bot, message, "2")
    if (numberOFTeams > 2) {
        let team3 = await teamPrompt(bot, message, "3")
    }  
    if (numberOfTeams > 3) {
        let team4 = await teamPrompt(bot, message, "4")
    }
    let obj = bot.games.observe(message.guild.id)
    for (let i = 0;i < numberOfTeams;i++){

        obj.teams[`team${i}`] = 
    }```
Is there anyway I can set team1 in the object to team1 variable and etc.
quaint pendant
#

Okay I figured it out, it has to run in the "ready" event else it does not function.

solemn latch
#

it can run anywhere client is defined and logged in

#

client.login(token)
then just below it
client.user.setPresence()
wont work

quaint pendant
#

I have run it many times above client.login.
It will return the same errors I have had,
I had my code wrong.

solemn latch
#

above wont work either.
my point was more, it just should be in an event, or you should be checking if the client is available before doing it.

#

@hardy vector how are you defining client.commands?

#

the way listed on discordjs.guide?

hardy vector
#

client.commands = new Map();

#

like that @solemn latch

#

but thats in my main file

solemn latch
#

and your setting them with
client.commands.set(command.name, command);
or something similar correct?

hardy vector
#
const BaseCommand = require('../../utils/structures/BaseCommand')
const fetch = require('node-fetch')
module.exports = class Command extends BaseCommand {
    constructor() {
        super('cmd', 'utility', []);
      }
    
      async run(client, message, args) {
      }
}```
#

?

#

my cmd handler format?

#
const { Client } = require('discord.js');
const { registerCommands, registerEvents } = require('./utils/registry');
const client = new Client();
(async () => {
  client.commands = new Map();
  client.events = new Map();
  client.prefix = "g!";
  await registerCommands(client, '../commands');
  await registerEvents(client, '../events');
  await client.login("token");
})();


#

this is my main file

solemn latch
#

šŸ¤”

#

I dont see where you are adding your commands to client.commands

#

or is that what registerCommands does

hardy vector
#

registercommands does this

#

const path = require('path');
const fs = require('fs').promises;
const BaseCommand = require('./structures/BaseCommand');
const BaseEvent = require('./structures/BaseEvent');

async function registerCommands(client, dir = '') {
  const filePath = path.join(__dirname, dir);
  const files = await fs.readdir(filePath);
  for (const file of files) {
    const stat = await fs.lstat(path.join(filePath, file));
    if (stat.isDirectory()) registerCommands(client, path.join(dir, file));
    if (file.endsWith('.js')) {
      const Command = require(path.join(filePath, file));
      if (Command.prototype instanceof BaseCommand) {
        const cmd = new Command();
        client.commands.set(cmd.name, cmd);
        cmd.aliases.forEach((alias) => {
          client.commands.set(alias, cmd);
        });
      }
    }
  }
}

async function registerEvents(client, dir = '') {
  const filePath = path.join(__dirname, dir);
  const files = await fs.readdir(filePath);
  for (const file of files) {
    const stat = await fs.lstat(path.join(filePath, file));
    if (stat.isDirectory()) registerEvents(client, path.join(dir, file));
    if (file.endsWith('.js')) {
      const Event = require(path.join(filePath, file));
      if (Event.prototype instanceof BaseEvent) {
        const event = new Event();
        client.events.set(event.name, event);
        client.on(event.name, event.run.bind(event, client));
      }
    }
  }
}

module.exports = { 
  registerCommands, 
  registerEvents,
};```
#

it already does client.commands.set

young nymph
#

I'm trying to make my bot say hello back when you say "hello bot!"
i'm using javascript

hardy vector
#

bruh

#

thats basic js

young nymph
#

i'm just learning it

hardy vector
#

no one is going to spoonfeed

#

learn basic js

young nymph
#

ok

solemn latch
#

sorry @hardy vector i am not sure
SadCat

hardy vector
#

:((

#

i cri

mild swan
#

I don’t even know how to code in js and I could still do that lol.

hardy vector
#

lol

mild swan
#

It’s called looking it up btw lol.

hardy vector
#

lol me
?

solemn latch
#

one thing i do notice, your adding each command repeatedly for each alias.
wouldnt it be better to load each one once, and find the alias's of the command
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));

hardy vector
#

hm

#

yes

empty owl
#

say If i tell my code to throw an error, will it stop all of its code including the bot or jsut that command

hardy vector
#

well

#

if you use a try catch block

#

you can console.log the error instead of having it crash ur bot

small prairie
#

if u dont use catch i guess the code stops

empty owl
#

so i have this in a function in a loop

if (name.length > 20) return simpleEmbed(message.channel, "Setup", "Please use a name thats less than 20 characters.")``` and basically it just ends the function early and not the actual command
#

is there a way I can make stop

solemn latch
#

make it stop if the if statement runs?

empty owl
#

ye

#

pls ping me i gtg

solemn latch
#

pretty sure you already do that?

empty owl
#

it’s in a function

solemn latch
#

return breaks loops

empty owl
#

in a loop

#

it just continues

#

tho

solemn latch
#

so you have a function in a loop?

empty owl
#

ye

#

The function is team prompt

solemn latch
#

if(response === "breakLoop") return
then in the team prompt, on the condition you want to break,
return "breakLoop"

#

or true false, or whatever you need

hardy vector
#
async function registerCommands(client, dir = '') {
  const filePath = path.join(__dirname, dir);
  const files = await fs.readdir(filePath);
  for (const file of files) {
    const stat = await fs.lstat(path.join(filePath, file));
    if (stat.isDirectory()) registerCommands(client, path.join(dir, file));
    if (file.endsWith('.js')) {
      const Command = require(path.join(filePath, file));
      if (Command.prototype instanceof BaseCommand) {
        const cmd = new Command();
        client.commands.set(cmd.name, cmd);
        cmd.aliases.forEach((alias) => {
          client.commands.set(alias, cmd);
        });
      }
    }
  }
}``` can i add something so that it sets the category as well
solemn latch
#

shouldnt the category be set in each commands file

hardy vector
#
const BaseCommand = require('../../utils/structures/BaseCommand')
const fetch = require('node-fetch')
module.exports = class DiscordJSCommand extends BaseCommand {
    constructor() {
        super('djs', 'utility', []);
      }
    
      async run(client, message, args) {
     
}``` this is my cmd handler format
#

idk if it is

#

bc when i make a different help cmd which has categories

#

and also im not actually mapping the categories anywhere

timber linden
#

im usign visual studio code

#

but i forgot how to run it...

#

any help?

hardy vector
#

bruh

solemn latch
#

for my help command, i get the categories when the command is run.
const categories = [...new Set(client.commands.map(command => command.category))]; // get all the unique categories commands use
@hardy vector
then i set each category in each command

timber linden
#

yes ik im funny

hardy vector
#

ur trolling

timber linden
#

but how do i run visual studio code

#

IM NOT

solemn latch
#

press windows key

hardy vector
#

@solemn latch if possible can you show me ur cmd handler

solemn latch
#

type visual studio code
press enter

timber linden
#

o kk

#

.

#

enter does uh

#

nothing

#

im a dumbo

#

IM not joking

hardy vector
#

you want to run ur bot?

#

open a terminal window

#

cd into the directory

#

node .

timber linden
#

yes

#

in visual studio i did node.js

hardy vector
solemn latch
#

visual studio code is a program.
like any other program on windows, you just double click the exe

timber linden
#

oh

#

makes the number go higher

#

made chat quiet ez

solemn latch
#

me and nerd went to dms

timber linden
#

from my dumbness

#

WHY

solemn latch
#

he wanted to see my command handler shrek

#

and im embarrassed of it

timber linden
#

big oof

solemn latch
#

its so bad, its the worst part of my bot

#

but the most important

#

nerds stuff is soooooo much cleaner

strong tundra
#

im trying to learn c# guys is it easy can i make game with it

vernal basin
#

(ping with response please)

scenic kelp
#

@strong tundra how do you define easy?

#

if you have experience with C-like languages then you've got a good head start

blissful carbon
#

is reason for my bot's high ping is discord api latency?

strong tundra
#

i know rust

blissful carbon
#

I have no other reasons for it

strong tundra
#

i guess it's c-like

#

i went through the tutorial at on ms earlier and it seems decent

scenic kelp
#

Give it a try and see I guess

strong tundra
#

yea

vernal basin
#

also btw this was the error it was throwing

strong tundra
#

i'm planning on using xna

#

but i've never done any kind of gui/game/graphics ever

vernal basin
#

wait so I slightly fixed it

#

but now it's just saying it can't find this dependency

#

and I'm so confused

#

since the link provided seems to match exactly with my string?

vale garden
#

hello

#

i made a command to calculate the weather of a place

#

but while calculating the temp in C°

#

it comes to about 23.888888889 from 74°F

#

is there a way to round it off

sudden geyser
#

IF 23.888... is a number, use .toFixed

vale garden
#

ok

#

thx

weary ridge
lusty spade
lusty quest
#

@lusty spade where did you define message?

#

nvm found it

#

not sure but its possible that you need to run it async (i guess its a promise)

lusty spade
#

ok i'll try

lusty quest
#

@weary ridge its an API. you need to make a Get Call or HTTP call to it and it will answer with a Json that contains data, like URL to the picture, captions, timestamps and other stuff.

lusty spade
#

thanks it worked!

weary ridge
#

Oh k

dapper lynx
#

Would ytdl-core be suitable for 100 or less servers if i am to implement music to my bot?

#

Also for that amount of servers what would be a good reccomendation for hosting the bot as currently i am just self hosting which isn't practical at all

sacred oyster
#

error

#

for my command handler

#

heres the code

pale vessel
#

have you tried reading the error

#

try debugging

#

log prop

lusty quest
#

did you have set a name in your command?

#

its possible that there is a duplicate or a missing name

sacred wraith
#

@sacred oyster Tangential, but const var1 = something, var2 = something does not make var2 const.

grizzled isle
#

So, I made a timer command that sends a message in the channel that the command is issued in. I made the minimum interval 5 minutes due to rate limits and potential abuse. Is that too short or just right?

sacred oyster
#

prop is defined

pale vessel
#

@dapper lynx

dapper lynx
#

Yeah

pale vessel
#

discordjs/opus is enough

#

opus and opusscript won't help you since discordjs prioritizes discordjs/opus

dapper lynx
#

Fair enough

pale vessel
#

yeet

dapper lynx
#

Wait so remove @types/node too

pale vessel
#

yeah

dapper lynx
#

Okay so now just repeat the whole github process and deploy on Heroku

pale vessel
#

it should deploy automatically as you commit and push to origin

dapper lynx
#

Damn seriously push failed again

#

Wait, do i add the node modules via Heroku or do i put the node_modules folder into GitHub repo

#

I put folder into repo

pale vessel
#

no you don't

#

heroku installs the modules for you

dapper lynx
#

Okay i'll remove it then that should probably fix it

pale vessel
#

oh lol you had it

dapper lynx
#

I did say after i asked that i put the folder in the repo lol

#

I was told to put "all files from bot" into repo

#

I've removed it now just need to commit and stuff

#

Yup it's deployed

#

App was successfully deployed, what do i do now because the bot is still offline

pale vessel
#

then you didn't set the config vars correctly

earnest phoenix
#

d!help music

pale vessel
dapper lynx
#

First bot "token" second box the actual token

pale vessel
#

and in code, it should be process.env.token

dapper lynx
#

Oh so the bot's token should be replaced with process.env.token

#

In code

pale vessel
#

in code, yes

#

don't put quotes

dapper lynx
#

Bruh, i was told to just leave the token blank by the other person..

pale vessel
#

bruh

dapper lynx
#

Like that???

pale vessel
#

mhmm

dapper lynx
#

I need an env file right???

#

Or no

pale vessel
#

nah, heroku handles it for you

dapper lynx
#

So i don't need to add to const either just literally put that and it should work fine?

pale vessel
#

should work just fine

#

if you were on a vps, you'd have to install dotenv module and actually have to add a file named .env

#

but this time heroku handles everything, just set vars in settings

dapper lynx
#

Yeah i did originally have it setup like that so the token wouldn't have to be in index.js so i didn't have to blur it

#

Glad i don't anymore it'd be more effort probably

#

Deployed but still offline

pale vessel
#

check logs

#

actually, go to resources tab first

#

send a screenshot

dapper lynx