#development
1 messages Ā· Page 982 of 1
le big brain
im working on 2 bots at the same time haha
unexpected EOF while parsing (<fstring>, line 1)
so its normal to get confused or forget something
idk why im getting an error
import asyncio
that is throwing an error
idk why
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!")
}
})```
how to get bots icon url in py
client.user.avatar_url < https://discordpy.readthedocs.io/en/latest/api.html#discord.ClientUser.avatar_url
can someone uhh tell me 24/7 script?
Can anyone tell me why I get this error: https://hastebin.com/obemojusoy.sql
24/7 script
you can't use a script to let a bot stay online 24/7
You'll want a VPS if you wanna run it 24/7 @viral lynx
What's happening in here , lol
looks like map is undefined @plush escarp
make sure it is defined before reading it
hm.. will this work in DBM? I only have it.
dbm is bad
we dont support bot makers
if you have questions or issues related to them, go complain to the developer
oh ok :I
https://paste.tortoisecommunity.ml/6elRZ5dIu8
unexpected EOF while parsing (<fstring>, line 1)
whats causing the error?
or imma just give up, im an Animator, not a Scripter
some syntax error
its legit just import asyncio
lul
Can anyone tell me why I get this error: https://hastebin.com/obemojusoy.sql here is the code: https://pastebin.com/jk4n9pBS
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
Send the rest
why do you have an fstring on your first line if you're importing a module 
(If only the page actually loaded for me)
Can anyone tell me why I get this error: https://hastebin.com/obemojusoy.sql here is the code: https://pastebin.com/jk4n9pBS ping me when you answer
In the code there isn't that import asyncio
@plush escarp
is client.categories actually set?
Pro Gamer I think that somebody would help you if they knew how
Why are field values in a set
...
looks like it should be set to the categories of commands of your bot
hi, i have this code:; ```ts
public getMember(search: string, { members }: Guild): Member | undefined {
any ideas?
how do i fix the error?
in typescript
have client.categories set
to whatever it should be, according to what you want it to be.
client.categories = what you are setting it to
what do it set it??
it depends on the structure of your bot, but i set mine like this
i cant tell you what your bot does 
Ok, tysm
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?
oh ok thank you!
š
@solemn latch the help command is working but all of the commands are not showing up
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?
you can use ||
|| means or
if (message.content.toLowerCase() === 'test' || message.content.toLowerCase() === 'test2')
you can also use array.includes if you want to have more than 2 or 3 options
if([a,b,c,d,e,f].includes(message.content.toLowerCase()))
I am new on these stuff...
@earnest phoenix learn basic js, it helps a lot
@quartz kindle it does not work
show code
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
you removed the block lol
{}
if() {
// code here
}``` not ```js
if()
// code here
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
what error?
hi, how can i fix SyntaxError: Cannot use import statement outside a module in ts w/o changing it to require?
wym is require really a problem?
#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
@heavy pollen any error
wym is require really a problem?
Just use require lol
@heavy pollen any error
@summer torrent after waiting sometime, I'm getting this error: https://hasteb.in/adeteyux.sql
what error?
@quartz kindle you know the error, I'm trying with 0 project too. Not works, my bot have 4k servers.
@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
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
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
ill put my face into that hopefully it works
Trying, 1 miunte..
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
doesnt python have a way to check mentions from a message?
probably but ehh
like discord.js has message.mentions
yeah but im inputting a string that doesn't come from a message
if(message.content.startsWith("&ping")) {
message.channel.send('Pong! Your ping is `' + `${Date.now() - message.createdTimestamp}` + ' ms`!');
}
})```
like for outputs my func detects if it can or not send embeds, if it can great otherwise make sure no pinging the role
My bot doesn't reponding
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') {
}
})
ah if its not coming from a mention then i guess regex is your best bet
there are many websites that can help you generate a regex for finding text in between two patterns
@surreal notch @long yew learn js & discord.js please
@surreal notch i know a ping command that is embeded and shows the ping in ms for the bot
dm me

i'll help
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
are you on windows?
@surreal notch i sent u a friend request so i can dm u
Yes Tim
if so, you need to install node.js from the node.js website, then restart the computer
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
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?
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
use regexp
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]
Use <Array>.indexOf and <Array>.splice(index, 1)
@chrome olive Use splice
thx
@quartz kindle Are you there? Can you look here?
I mean the install "technically" worked?
why i have this problem ?
Is message even defined
hm i tink yes?
You're not sure?
i just copyed it
Well it's not
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
@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]
}```
@heavy pollen https://discordjs.guide/additional-info/changes-in-v12.html
You can read this.
(Discord.js v12 sürümünde yapılan deÄiÅiklikler)
Are you v11????
yeah
I think it works thanks @quartz kindle
You think so?
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
shards:"auto" = internal sharding
Who can help me,too?
if it works with internal sharding, but not with the sharding manager, then something is wrong with your shard files
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!
@earnest phoenix delete your node_modules folder and try again
Not works sharding with your code
also, then you do uninstall, you need to use --save
I try lots of shard file
npm uninstall <module> --save
so, it will work, right?
@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
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 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?
Can you inspect my server.js file?
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
https://hasteb.in/odegosoj.js here is my server.js
I'm Turkish so writing Turkish messages.
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
Okay, I will catch everyting.
@quartz kindle can u help me with this pls
no errors?
i have 1 error
show
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.```
theres your answer
It says Unknow Role but role is there :3
Manager destroyed error
I need to spawn more shards? (It is currently auto)
1 minute
I think fixed
congrats!
@earnest phoenix console.log(typrole) before adding
k
@hardy vector console.log(query)
@earnest phoenix why do you speak unnecessarily? I'm only trying to get help because I don't know how to solve error.
What?
better?
ok
now shut.
Don't mouth off.
Only English please.
@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 }
@quartz kindle it didnt log anything
How to you make a bot dm the person who kicked the bot from the guild
then you dont have a query
and if !query return
so nothing happens
@deft condor you cant
if your code says there is no query then there is no query
but
now you have to find out what happened with it, why is your query disappearing
ok
the answer is probably your querystring module
which seems very unnecessary in the first place
you could just remove it entirely
but they told me i needed it to encode the spaces
you can encode with encodeURI or encodeURIComponent
what do I need to do for this because when i type in 'emitter' nothing shows up ;-;
those are built in javascript functions
@spark breach console.log(client._events)
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)
}
}
}```
Why do you have 11 message listener events in the first place anyway 
Why do you have 11 message listener events in the first place anyway :Thonkeng:
idk
use cmd handler
Havent thought about that actually
Well if you don't know then how is anyone gonna help you debug it
@quartz kindle U can see log what came idk what to do :/
@earnest phoenix do ...roles.add(...).catch(console.log)
it should catch a better error
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
@spark breach what do you need 11 message listeners for
did you actually make an event listener for each command?
@earnest phoenix thats the @ everyone role
are you getting the role object from it?
You know pinging roles is a bad idea for a command..
yes you know
@quartz kindle What should i do ?
===
bc you don't know what an if statement is, or what a switch statement is, or what a module is
ok ill try with ===
@earnest phoenix check if the channel the message was sent in matches said channel
that's why you used a message event for each command
@quartz kindle I tryed with === and now says "Invalid Role!" but role does exist
console.log(rRole)
ok @quartz kindle i did with that and it just type @!713079087761195129> Test in console
there you go
thats hthe name of the role its trying to find
does anyone know a command manager i can use?
i an still learning js but was told i need to use a command manager.
so you have to fix your args
@silent berry a command manager is something you make
@copper cradle ik that but does anyone have any templates?
if you're using discord.js their guide has one
@quartz kindle thank you, can you link it please
@quartz kindle Im little confused idk waht to do :/
yes
so args.join(" ").slice(1) is converting your command to that
which is wrong
so you need to change the args
ok
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
so i need just args.join(" ")
ok
osi just need Test
ah yes
then yeah
remove the first element
and then join the rest
what tim said
k
ty
I did it
waht i did is
let rRole = args.slice(1).join(" ");
and it shows just
" Test "
alright, so now it should work
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(" ");
that should work for spaces too
oh what i realised is
that it need to be exact name Like Good Member it cant add if i type Good member
how do you use puppeteer on a vps?
@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
npm install dblapi.js
What?
Hm
If the bots are accepted, then it will be necessary to connect the top.gg API?
no
its optional
it's not required
their api is used for you to post your servercount
if you want to
and get votes
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)
Discord. Js?
Can someonr help me with my bot
@halcyon ember
Someone*
console.log(state-exchange)
@bitter harness yes
U can
Š ŃŃŃŠŗŠøŠ¹ или ŠŠ½Š³Š»ŠøŠ¹Ńкий знаеŃŃ?
...
blyat cyka jobany urod #memes-and-media
š³ š
lmao
i watch russian videos

i know a few more
@bitter harness what do you mean the bot wont let you add commands?
I only know Я Узбек
@earnest phoenix ye
I need help with my bot, I proofread it, but nothing seems wrong, although Glitch says there is something wrong.
Glitch says there is something wrong.
If you don't explain what the issue is noone can help you
@quartz kindle it creates the channel without any problems
Error: Cannot find module 'discord.js'
ŠŃоŃŃ Š¾ŃŃŠ°Š²Š°ŃŃŃŃ Š² #memes-and-media ŠµŃŠ»Šø не ŃŠ¾Š±ŠøŃаеŃŃŃŃ ŠæŠ¾Š¼Š¾Š³Š°ŃŃ ŠøŠ»Šø ŠæŃŠ¾ŃŠøŃŃ ŠæŠ¾Š¼Š¾ŃŠø Ń ŠæŃŠ¾Š³ŃŠ°Š¼Š¼ŠøŃŠ¾Š²Š°Š½ŠøŠµŠ¼
guild.channels.create(`exchange-${state.exchange}`, { type: 'text', parent: '713550063145844766',}
that works
I installed the package, and inserted a const
@halcyon ember ah so thats a channel you just created? then you need to await its creation
remove it from your package.json and then re add it@rancid tartan
await guild.channels.create?
yes
oh
otherwise it will try to find it before it finishes creating
its fine if i put it in a async function?
you'll need to
since await can only be used inside async functions
yes but you have to put everything inside the same function
you can also do that in chrome dev tools
yeah
@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)}```
looks like a loop
what
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
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
How i can create a messageCollector in DM
user#dmChannel
ok
@pale vessel didnt you have that bot taking screenshots of websites?
perhaps
puppeteer?
yeah
how did you get it to work on vps?
by doing npm i puppeteer
did you get any error?
no
can you show me the code you used?
probably isn't the cause since it works on your local machine
the code is fine, but on my vps it just gets stuck at trying to take the screenshot
did you use catch?
yeah
if it doesn't you can disable it
it's weird since it should throw an error if something is wrong
worth a shot, how would i do that
@halcyon ember you didnt close the channels.create function?
you have channels.create({}
nope, disable gpu didnt help
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
where's the await now?
await message.guild.channels.cache.find(channel => channel.name === exchange-${state.exchange}).send('<@&713541593121947699>, <@'+message.author.id+'> wants an exchange with note: '+details)
on the channels.create
oh both need em huh ok
does someone know wtf happens/is happening to glitch.com
yes its dying
thats so annoying
you might be out of luck then
My code:
const reactions = await m.awaitReactions((reaction) => {
reaction.emoji.name === emoji
}, { time: 5000 });
console.log(reactions)```
Why output is `Collection [Map] {}` (empty collection)
just get pi@earnest phoenix
still bandwidth
pi?
oh, didnt remember that everyone doesnt have unlimited bandwith like me sad
raspberry pi
b r u h
now i wasted my money on boosting a server on glitch ;-;
nice
bruh i worked so hard for my bot
you rly boosted an app?
yes
on glitch
yes
oh ok
make a ticket
make a support ticket on glitch
uh how
what would be a smart way to fetch 50 users at once
ok
https://support.glitch.com/ @earnest phoenix
happy bday @pale vessel @modest maple
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 doesn't really help have been over it like 3 times already
@earnest phoenix just create new thread
What's the ratelimit for bots/votes?
can i host anywheres for free?
free, yes, good uptime, no
yes at glitch or heroku but I paid is always better
repl.it can be backdoored easily
or if you want private repls, you have to pay, so easier to get vps.
Anyone here with AWS experience who could help out?
Need to make EFS accessible "publicly"
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");
});
ghost ping lul
createDM returns a promise so you have to await it
vps is a virtual private server
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"
you buy it from a provider
client.on is not a traditional listener, it's an event listener.
collector.on('collect', m => {
answers[i] = m.content;
console.log(answers[i]);
i++;
applyQuestion();
})
It is not console.logging
Thanks
ghost ping lul
@pale vessel not a ghost ping, was a happy bday from me :)
NguyenXD ghostpinged me
ah
How can I send messages to the gateway on discord.js v11?
is there a way to disable intents on eris?
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
Specifically how to use node.js
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 ?
Looks like song is undefined
Wong
wdym with undefined ?
Either songInfo or videoDetails
Your videoDetails is invalid are you using the correct functions
i think so
array[index] = item ..?
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
but its not removing it?
ok i look
splice also returns the removed values as an array
problem is that in my array there is text and it's quite random
sxcu.net free ShareX uploader
Can anyone help mw?
i regenerated the token but not worked
"error request 429" in google
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.
You can't see?
how do i use the <style> thing on the website?
@wicked pivot I'm not sending requests
well error 429 says that now i don't know
you're gonna have to show some code
we know what the error means, but not why you're getting it
@earnest phoenix why u pinged #development he is in development
?
š¤
Idk,why its happening..
So idk which code
xD
Im not sure what you expect us to do if you dont provide info
well when did you start getting it
what code changes did you make
it wouldnt just come out of nowhere
msg[reponse.selectedText] = input``` (msg = array)
it does not work
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 ?
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
There is no way to force the default display size ? At least for my canvas ?
nope
So... I can't use the embed message, I can't use canvas... There is no other way to do this message design ? š
nope
you can only use what discord allows you to use
everyone plays by the same rules
You can send them as attachments not embed images
but they'll still show at the bottom of the embed
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'contrast.png');
No Tim no embeds
That's what I'm doing but the size auto reduce
As attachments
yeah, he asked about using images as a replacement for embed
but the image will be resized to be smaller than an embed
Yup
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 ^^'
yup, impossible
Why not put the embed image in the 2nd one?
Hi, can someone help me solve this error pls? https://hastebin.com/dequgaweso.sql
You're trying to read property 'map' of undefined. Without the code, I don't think we can help you further.
ok
ima give u de code
1 sec
Here u go: https://hastebin.com/natocawube.js
@sacred wraith
If you look at the stack trace, this error actually originated from help.js
Can anyone solve this problem for me, and will I give it money when it is finished?
@sacred wraith So I need to give u the help cmd?
@willow river are you on windows?
Yeah @solemn latch
i need help for something
i believe i already told you that canvas has some requirements on windows
even sent you the link with instructions before (this link ^)
yeah you did
Would you solve it for me? I will give you a Windows server to enter and resolve it for me @solemn latch
@prime cliff Not working either... š
its a 3 step process @willow river
And I will give you money @solemn latch
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
sometimes it goes over 100?
let random = Math.floor(Math.random() * (maxdamage - mindamage)) + mindamage;
I tried it in the console too
Math.floor(Math.random() * 100) + 10;
103
lol you're way faster @solemn latch xD
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
What's the ratelimit for bots/votes?
60 per minute
all are 60r/60s globally
yikes
just use webhooks and a database
@copper cradle back to you, no that did not work
remove it from your package.json and then re add it@rancid tartan
use whatever you feel more comfortable with
I find mongo pretty nice and easy to manage if that helps
@rancid tartan that should've worked lol
the search for a free db provider continues
all dbs are free lol
or have a free version
unless you want to use a remote database service
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
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 ?
you have to find the index
array[0] = "d"
you can use array.findIndex()
let index = array.findIndex(item => item === "a");
array[index] = "d";
ahhhhhhhhhhh thank you
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.
online
idle
invisible
dnd``` these are the only statuses you can set
available is not one of them
for setPresence, refer https://discord.js.org/#/docs/main/stable/typedef/PresenceData
you can get rid of setStatus since you can just set it in setPresence
game has been renamed to activity
then you have something wrong with your code
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
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
Oh okay thanks
moderation?
Whats happened to glitch
idk
no space left error
you ran out of disk space
just you pal
anyone know how to use this?
im trying to use a new command handler
and i ahev an error
if anyone can help please do
Still having issues with setPrefrence
Updated code.
status: 'online',
activity: {
name: '!chhelp',
type: 'WATCHING'
}
});```
Error.
Cannot read property 'setPrefrence' of null
Yes.
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
is this being ran in the client on ready event @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.
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)
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);
})
})
})
})
}
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.
Okay I figured it out, it has to run in the "ready" event else it does not function.
it can run anywhere client is defined and logged in
client.login(token)
then just below it
client.user.setPresence()
wont work
I have run it many times above client.login.
It will return the same errors I have had,
I had my code wrong.
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?
and your setting them with
client.commands.set(command.name, command);
or something similar correct?
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
š¤
I dont see where you are adding your commands to client.commands
or is that what registerCommands does
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
I'm trying to make my bot say hello back when you say "hello bot!"
i'm using javascript
i'm just learning it
ok
sorry @hardy vector i am not sure

I donāt even know how to code in js and I could still do that lol.
lol
Itās called looking it up btw lol.
lol me
?
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));
say If i tell my code to throw an error, will it stop all of its code including the bot or jsut that command
well
if you use a try catch block
you can console.log the error instead of having it crash ur bot
if u dont use catch i guess the code stops
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
make it stop if the if statement runs?
pretty sure you already do that?
itās in a function
return breaks loops
so you have a function in a loop?
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
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
shouldnt the category be set in each commands file
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
bruh
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
yes ik im funny
ur trolling
press windows key
@solemn latch if possible can you show me ur cmd handler
type visual studio code
press enter


visual studio code is a program.
like any other program on windows, you just double click the exe
me and nerd went to dms
big oof
its so bad, its the worst part of my bot
but the most important
nerds stuff is soooooo much cleaner
im trying to learn c# guys is it easy can i make game with it
is there anything I'm missing here? (just moved to java & gradle)
(ping with response please)
@strong tundra how do you define easy?
if you have experience with C-like languages then you've got a good head start
is reason for my bot's high ping is discord api latency?
i know rust
I have no other reasons for it
i guess it's c-like
i went through the tutorial at on ms earlier and it seems decent
Give it a try and see I guess
yea
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?
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
IF 23.888... is a number, use .toFixed
https://www.reddit.com/r/memes.json?sort=hot so this is for and how setup
I need help on a serverinfo command, i keep getting errors
code: https://pastebin.com/EzPYWc6i
error: http://pastebin.com/Ug8dfU95
@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)
ok i'll try
@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.
thanks it worked!
Oh k
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
did you have set a name in your command?
its possible that there is a duplicate or a missing name
@sacred oyster Tangential, but const var1 = something, var2 = something does not make var2 const.
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?
prop is defined
@dapper lynx
Yeah
discordjs/opus is enough
opus and opusscript won't help you since discordjs prioritizes discordjs/opus
Fair enough
yeet
Wait so remove @types/node too
yeah
Okay so now just repeat the whole github process and deploy on Heroku
it should deploy automatically as you commit and push to origin
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
Okay i'll remove it then that should probably fix it
oh lol you had it
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
then you didn't set the config vars correctly
d!help music
can you click this and see
First bot "token" second box the actual token
and in code, it should be process.env.token
Bruh, i was told to just leave the token blank by the other person..
bruh
mhmm
nah, heroku handles it for you
So i don't need to add to const either just literally put that and it should work fine?
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
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




