#development
1 messages · Page 1056 of 1
Omega
you can leave the rest
Okay
and then when i ask for a line of code people say s poon feedinjg isnt allowed here
)_)
Asking is bad
@quartz kindle same problem
Ah
well, technically thats not spoon feeding because its not end code, its for debugging purposes
Send the play function
logs?
Play function pls
case 'play':
function play(connection, message){
var server = servers[message.guild.id];
console.log(server)
server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));
server.queue.shift();
let stream = ytdl("https://www.youtube.com/watch?v=-tJYN-eG1zk", {filter:"audioonly"})
stream.on("info",console.log)
stream.on("progress",console.log)
connection.playStream(stream)
server.dispatcher.on("end", function(){
if(server.queue[0]){
play(connection, message);
}else {
connection.disconnect();
}
})
}
if(!args[1]){
message.channel.send("You need to porvide a link!");
return;
}
if(!message.member.voiceChannel){
message.channel.send("You must be in a Voice Channel to play music!");
return;
}
if(!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
server.queue.push(args[1]);
if(!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection){
play(connection, message);
})
break;
api thing?
@fringe axle put the stream code before the dispatcher, and replace your connection.playStream line with the stream one
okay
.playStream?
hes on v11
Oh ok
i have my own music bot script @fringe axle
Same problem @quartz kindle
i have my own music bot script @fringe axle
@earnest phoenix and now?
¯_(ツ)_/¯
Are u providing args?
huh
I go to eat now. This is the code atm:
case 'play':
function play(connection, message){
var server = servers[message.guild.id];
console.log(server)
stream.on("info",console.log)
stream.on("progress",console.log)
connection.playStream(stream)
server.dispatcher = connection.stream.on("info",console.log)(ytdl(server.queue[0], {filter: "audioonly"}));
server.queue.shift();
let stream = ytdl("https://www.youtube.com/watch?v=-tJYN-eG1zk", {filter:"audioonly"})
server.dispatcher.on("end", function(){
if(server.queue[0]){
play(connection, message);
}else {
connection.disconnect();
}
})
}
if(!args[1]){
message.channel.send("You need to porvide a link!");
return;
}
if(!message.member.voiceChannel){
message.channel.send("You must be in a Voice Channel to play music!");
return;
}
if(!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
server.queue.push(args[1]);
if(!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection){
play(connection, message);
})
break;
Wot
oh.
to see what the problem is in the first place
xD
Does the bot joins channel?
yes
it joins and leaves immediately
right
because the end event fires instantly
But i have to go now xD
i just tested it on runkit and it seems to work
i mean, i get the video info output correctly
from the stream.on("info") event
YOO
hmmm
why doing stream.on
hoyl shit
Tim when i am compiling typescript it gives an error saying message.author.fetchFlags is not a function
i think i deleted it from their typings
¯_(ツ)_/¯
how lol
¯_(ツ)_/¯
idk how that shit works
2020-07-14T10:00:12.960696+00:00 app[Worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-14T10:00:12.960697+00:00 app[Worker.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-14T10:00:12.960697+00:00 app[Worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-14T10:00:12.960697+00:00 app[Worker.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
2020-07-14T10:00:12.960698+00:00 app[Worker.1]: code: 'MODULE_NOT_FOUND',
2020-07-14T10:00:12.960698+00:00 app[Worker.1]: requireStack: [ '/app/index.js' ]
2020-07-14T10:00:12.960699+00:00 app[Worker.1]: }
2020-07-14T10:00:13.007867+00:00 heroku[Worker.1]: Process exited with status 1
2020-07-14T10:00:13.049564+00:00 heroku[Worker.1]: State changed from up to crashed``` how to cry
Hmm
Bro, it literally says there, wasn't able to find main file index.js @earnest phoenix
@rigid maple in v11 avatarURL is not a function
It's a property
voltrex teach mongoose kek
edit:joke

If so
v12 => client.user.avatarURL()``` @rigid maple
whatever you said i didn't get @restive pebble
boing boing
k
been 7 minutes and my bot logs are still showing Initializing node_modules, hold on...
should i go tothe terminal and type refresh?
Wot, where do you host
@rigid maple i can show you how to do embeds
glitch.com is the fastest free worst hosting service
^^what i use
i did @earnest phoenix
I prefer heroku over glitch but using a vps is the best @earnest phoenix
luca is rude
Bruh
I prefer heroku over glitch but using a vps is the best @earnest phoenix
@earnest phoenix when you're poor
Hi I am making a ban command and I want to test for IDs. Does anyone know how to use a regex for that or have a regex I can use?
xD
@golden condor for detecting only a single id or
a single id
/(\d{17}|\d{18})/
Usefull for what?
Is that for ids or mentions?
702905673524051988
IDs
is 18 long
IDs can be 17 long too @restive pebble
ok now tell some nice apis
@restive pebble
Usefull for what?
hmmmm
if (!user) {
if (banRegex.test(args[0])) user = args[0]
else return message.channel.createMessage("Please give me a valid user")
}``` So this would work?
like nice api to wrap
yes
What libary?
kinda
@golden condor what's banRegex.test
The regex u gave
Oh
const banRegex = /(\d{17}|\d{18})/
I assume u use discord.js?
Okay
pplication Logs
2020-07-14T10:11:02.048135+00:00 app[Worker.1]: at MessageCreateAction.handle (/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
2020-07-14T10:11:02.048136+00:00 app[Worker.1]: at Object.module.exports [as MESSAGE_CREATE] (/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
2020-07-14T10:11:02.048137+00:00 app[Worker.1]: at WebSocketManager.handlePacket (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
2020-07-14T10:11:02.048138+00:00 app[Worker.1]: at WebSocketShard.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
2020-07-14T10:11:02.048138+00:00 app[Worker.1]: at WebSocketShard.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
2020-07-14T10:11:02.048139+00:00 app[Worker.1]: at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:125:16)
2020-07-14T10:11:02.048140+00:00 app[Worker.1]: at WebSocket.emit (events.js:315:20)
2020-07-14T10:11:02.048141+00:00 app[Worker.1]: at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:797:20)
2020-07-14T10:11:02.048200+00:00 app[Worker.1]: (node:4) 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)
2020-07-14T10:11:02.048235+00:00 app[Worker.1]: (node:4) [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.
like informative
Hmmm
omega
2020-07-14T10:11:02.048135+00:00 app[Worker.1]: at MessageCreateAction.handle (/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
2020-07-14T10:11:02.048136+00:00 app[Worker.1]: at Object.module.exports [as MESSAGE_CREATE] (/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
2020-07-14T10:11:02.048137+00:00 app[Worker.1]: at WebSocketManager.handlePacket (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
2020-07-14T10:11:02.048138+00:00 app[Worker.1]: at WebSocketShard.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
2020-07-14T10:11:02.048138+00:00 app[Worker.1]: at WebSocketShard.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
2020-07-14T10:11:02.048139+00:00 app[Worker.1]: at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:125:16)
2020-07-14T10:11:02.048140+00:00 app[Worker.1]: at WebSocket.emit (events.js:315:20)
2020-07-14T10:11:02.048141+00:00 app[Worker.1]: at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:797:20)
2020-07-14T10:11:02.048200+00:00 app[Worker.1]: (node:4) 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)
2020-07-14T10:11:02.048235+00:00 app[Worker.1]: (node:4) [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.```
or should I do args[0].match(banRegex)
@golden condor if you on js then use match
heroku moment
Yea
xD
Brb
k
if(args[0].match(<my regex>))
I'll test it like this
if (!user) {
if (args[0].match(/(\d{ 17 }|\d{ 18 })/)) user = { id: args[0] }
else return message.channel.createMessage("Please give me a valid user")
}```
are u sending an empty msg?
oop vsc added spaces
@earnest phoenix
@restive pebble its a music thing
ok
ok
so guys i need help with my work cmd it oonkly works for me
code:
const Discord = require("discord.js")
module.exports = {
name: "work",
aliases: ["w"],
category: "Currency",
run: async (bot, message, args, err) => {
let random = Math.floor(Math.random() * 100);
let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})
console.log(JSON.stringify(prevmoney))
console.log("Random money: " + random)
await bot.db.collection("Money").updateOne({"User_ID": message.author.id}, {$set:{Money: prevmoney ? prevmoney.Money + random : random}}, {upsert: true})
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(`You worked!`)
.setDescription(`You worked and got ${random} money!💰`)
.setFooter("This command is in beta so it wont save your money we are sorry :(")
message.channel.send(embed);
}
}
more infos?
?
what did you expect to do?
is 2gb of ram enough for 2 bots
what did you expect to do?
@lusty quest i want to make it so like when you run it it gives you coins but it only works for me not anyone else like it doesnt even show the embed 😦
depends on many factors, but 2gb is more than enough to start with
@quartz kindle could you help?
with what
my work cmd its not working scroll up
@earnest phoenix do you create a DB entry for the other users?
@misty sigil depends on how large your bot is. With 110 Guilds i currently use 80-90MB with one bot
@earnest phoenix then you know why it wont work
ok so how do i make a DB entry?
how did you made yours?
lul
@misty sigil depends on how large your bot is. With 110 Guilds i currently use 80-90MB with one bot
@lusty quest what lib?
d.js-light
how did you made yours?
@lusty quest ?
@earnest phoenix there has to be atleast one Document with your Infos. How did you made this one?
i suggest that you learn how to use mongoose. otherwise you will have a hard time understanding what is going on
uhh mongoose?
or Mongodb depends what you use as lib
hi what do u guys recommend for hosting
vps
lmao
thats easy. fix your knowledge on the lib you use for connecting to mongodb
im usinf discord.js
discord.js doesnt offer you a way to connect to mongodb
how did you save your money in mongodb?
const Discord = require("discord.js")
module.exports = {
name: "work",
aliases: ["w"],
category: "Currency",
run: async (bot, message, args, err) => {
let random = Math.floor(Math.random() * 100);
let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})
console.log(JSON.stringify(prevmoney))
console.log("Random money: " + random)
await bot.db.collection("Money").updateOne({"User_ID": message.author.id}, {$set:{Money: prevmoney ? prevmoney.Money + random : random}}, {upsert: true})
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(`You worked!`)
.setDescription(`You worked and got ${random} money!💰`)
.setFooter("This command is in beta so it wont save your money we are sorry :(")
message.channel.send(embed);
}
}
``` code
that command assumes there is already a saved profile for the user in mongodb
he has no idea how he got the profile
if there is no profile saved for that user, it wont work
thats why im asking, how did you save yours
previous attemps
how did you create a user with 0 money
?
or how do you define an initial money
like if a user never used your bot before
how do you give him a starting amount of money
i dont know?
how did you give yourself a starting amount of money?
i think the updateOne or a other method created it on a older attempt
how did you give yourself a starting amount of money?
@quartz kindle dont know how thoe tbh
lol
Derku do not just copy codes
mmk
what did you use for connecting to your MongoDB?
this one? https://www.npmjs.com/package/mongodb
yes
i dont use mongo, but something like this should work ```js
if(!prevmoney) {
await bot.db.collection("Money").updateOne({...},{$set:{Money:0}},{upsert:true})
prevmoney = 0;
}
or something along those lines
uhh ok
if there is no previous money
create a new profile and give it 0 money
with the author id of course
so where would i put?
upsert:true means create a new if an existing is not found
so where would i put?
read your code
i am making a discord invite tarcker
so
i need to give it perms
what are the necessary perms for this
create instant invite for creating invites
and manage server for reading them
i believe
ok
wait how do i make a start.bat?
@quartz kindle still doesnt work
well figure it out, sorry but i cant baby-sit you through everything
i need java nerds who are familiar with microoptimization and java's GC
so im doing a paperspigot plugin which is already trash in performance as is and im playing around with potion effects
the spigot api requires me to make a new potioneffect object to apply it to an entity
Hi Tim! 👋
should i make the potion effect a final field in a class or just create a new instance everytime i want to apply it
i'm unsure how the GC behaves with that
(the properties of the potion effect don't ever change)
im doing my best to leave a low memory footprint
if(!prevmoney) {
await bot.db.collection("Money").updateOne({"User_ID": message.author.id}, {$set:{Money: 0 }},{upsert:true})
prevmoney = 0;
} else {
await bot.db.collection("Money").updateOne({"User_ID": message.author.id}, {$set:{Money: prevmoney ? prevmoney.Money + random : random}}, {upsert: true})
}
```doesnt work
what doesn't work
the code
what doesn't work
@earnest phoenix
i know it's the code
what about it doesn't work
you can't just tell me "doesn't work" and expect me to understand what doesn't work
where's the context in that?
Just giving us code and saying doesn't work we can't do much
that's like going to the doctors and telling them "cure me" without telling them anything else
Provide us with more context please
he still got probably the issue that the code only works for him and dont create a new Document for non existing users
doesnt work dang it
What piece
what in the code doesn't work
What is not working
which part of it
thw whole
they want to know what you expect the code to do
to make it have the user 0 coins and then like im not sure tbh ;;-;;
it's almost been 8 minutes and we still do not know what doesn't work
correction
it's been 8 minutes
We're not wizards or something
If you don't provide us with context we can't do much 🤷♂️
i donated my crystal ball to BLM so unfortunately i can't know what they want to say
lets say i have a role named
verified
so i need i to assing it to a newly joined and verydied memeber to tat role
so
i need to have it
so it takes
the name
filter for it
i mean
@quartz kindle
when i run:
(everyone else nothing)
rn i have to use the role id
stop
writing
your messages
like this
and instead write it in one cohesive message
that's why i said filter for it
kk
and when somebody else runs the command? @earnest phoenix
the logs should still show
then put another log: console.log("bla") before the let random line
ok
then put another log:
console.log("bla")before the let random line
@quartz kindle logs nothing..
it logs bla to the console
unless your console is broken or you dont have access to read it or something
how can i make special theme look like this
and how can i active Shards
edit css
thats not how it works
smh
console.log is a global thing on javascript
it works on browsers, nodejs bots and any thing that has javascript in it
you cant just not have it
How do I get to CSS
smh I TRIED ITS NOT IT IT JUST DOESNYT WORK OK
How do I get to CSS
@celest basin lmao
?
you put it in the detailed description @celest basin
@quartz kindle it logs nothing
I do not have any options to access the CSS file
bruh
<style> tags
if it still logs nothing even if its the first line of the run function, then the problem is not even there
?
if the code doesnt get executed, the problem is not the code
is whatever comes before
the command handler
@celest basin something like this would probably work although i dont use it so idk https://cdn.vurighosting.com/u/f3WgFi.png
is whatever comes before
@quartz kindle but how
yup
@celest basin i got it to work https://cdn.vurighosting.com/u/pcVOaJ.png
<p style="text-align:center;">[TEXT]</p>```
@obtuse jolt I think you didn't understand what I mean
probably not
i want to color the buttons look like thit
damn i want that
BRUH HELP IT JUST DOESNT WORK
@earnest phoenix "not working" doesnt help solving the issue
you need to communicate properly
explain, show code examples, test, debug, put console.logs everywhere, see until where your code works and where it stops working....
i said its possible that your problem is in the command handler, so you need to at least show the code for the command handler, if you dont understand anything else
@celest basin overwrite the css classes with the html style tag in your description
you can get the classes with inspect element
and you can access the existing stylesheet rules with whatever stylesheet viewer your browser has
if any
.titleandvote
css gradients
how do u catch missing permissions error in discord.py
commands extension or on_message?
yea
on_command_error
is this ProBot Birthday Event#3905 a scam?
isinstance(error, ??)
commands.MissingPermissions
how do i define args in command handler?
time to read the docs
@lost chasm probably
do i have to define everything?
ask here discord.gg/probot
lemme read again ig
Where are you looking?
i wasnt looking just came here to ask
@summer torrent doesn't seem smart to ask potential scammers if their product is a scam - I don't believe they will ever say "YES" 😄
>>> commands.MissingPermissions
<class 'discord.ext.commands.errors.MissingPermissions'>
>>> commands.BotMissingPermissions
<class 'discord.ext.commands.errors.BotMissingPermissions'>
If you are trying to do something within the command itself, a try-except is fine
I have this problem
basically, I have many socketio listeners on my webserver
but when I open one page on my webserver, I only want it to trigger the event listener for that route
but it's triggering all of them
is there a node support server that I can ask in? or do you or do you know anyone who knows node express?
show code
can someone help with my work and bal cmd? basicly my whole coin system
Well then how can we help?
Just saying "I get an error" doesn't give us enough information on your problem.
say what happens
any kind of error
show code
we've already been through this
he wants some kind of magical fix that we magically come up with
?
stfu
@earnest phoenix "not working" doesnt help solving the issue
you need to communicate properly
explain, show code examples, test, debug, put console.logs everywhere, see until where your code works and where it stops working....
i said its possible that your problem is in the command handler, so you need to at least show the code for the command handler, if you dont understand anything else
read this
i didnt even say not working lmfao
well im using Discord.js and mongoDb
and my work cmd just doesnt work
and my work cmd just doesnt work
hmm
its literally the same thing?
are u just going to argue or post details about the problem
same, non useful information
because if its the first stop
code: ```
const Discord = require("discord.js")
module.exports = {
name: "work",
aliases: ["w"],
category: "Currency",
run: async (bot, message, args, err) => {
let random = Math.floor(Math.random() * 100);
console.log("blah")
let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})
console.log(JSON.stringify(prevmoney))
console.log(Random money: ${random})
if(!prevmoney) {
prevmoney = 0;
await bot.db.collection("Money").updateOne({"User_ID": message.author.id}, {$set:{Money: 0 + prevmoney.Money + random}},{upsert:true})
}
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(`You worked!`)
.setDescription(`You worked and got ${random} money!💰`)
.setFooter("This command is in beta so it wont save your money we are sorry :(")
message.channel.send(embed);
}
}
Have you tried console.log lines to figure out where it breaks?
and you said the blah doesnt show in the console, correct?
so the problem is not there
not in this code
show other code
command handler
message event
etc
That’s a command handler or message event thing
const Discord = require("discord.js");
module.exports = {
name: "vote",
category: "Bot Information",
aliases: ["rate", "upvote"],
run: async (bot, message, args) => {
let voteEmbed = new Discord.MessageEmbed()
.setThumbnail("https://cdn.discordapp.com/avatars/701741237966995456/9f3bbf6be522c76191608334234be96f.png?size=128")
.setColor("#2f3136")
.setTitle(`Hay! ${message.author.username} want to vote me?`)
.addFields(
{
name: "Did you know?",
value: `\`\`If you vote you may get some special perks!\`\``,
},
{
name: "Invite Link",
value: "[Click Here](https://top.gg/bot/701741237966995456/vote)"
}
);
message.channel.send(voteEmbed);
}
};
``` another cmd
Anybody knows what this mean?
null OkPacket {
fieldCount: 0,
affectedRows: 1,
insertId: 0,
serverStatus: 34,
warningCount: 0,
message: '(Rows matched: 1 Changed: 1 Warnings: 0',
protocol41: true,
changedRows: 1
} undefined
null OkPacket {
fieldCount: 0,
affectedRows: 1,
insertId: 0,
serverStatus: 34,
warningCount: 0,
message: '(Rows matched: 1 Changed: 1 Warnings: 0',
protocol41: true,
changedRows: 1
} undefined
I did a nsql query and did console.log after seeing it didn't change the data
and this one works?
and this one works?
@knotty steeple i tihnk so
try it dek-vote
wait bot offline
See this
It always works at second time
Not first
Any sol
And it takes username
Not nickname
yeah it works @knotty steeple
?
for the handler
You saying me ?
no
Ok
@tulip ledge null is a class which is OkPacket
show code pcgamer
@earnest phoenix as i said before, the problem is not in the commands. the problem happens BEFORE the command
PC gamer 
null is a class which is OkPacket ok yeah well I can read why is it happening tho?

this?
so you need to show the code for your message event, or command handler, or main file, or whatever how your bot works
not there either
that’s not a problem
so what is
show us where the message stuff is done
the message event. commonly under /events/message.js
show us the message event
No need to be like that, I'm just tryna point that out as I can't read your mind to see whether or not you can read it @tulip ledge
I just need to know why it's happening
it shows the rows were changed tho
if(command === "embarrass"){
let channel = msg.channel
let member = msg.mentions.members.first() || msg.member,
user = member.user; channel.createWebhook(`${user.username}`, {
avatar: `${user.displayAvatarURL()}`,
}).then(webhook => console.log(`Created webhook ${webhook}`)).catch(console.error);
const embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setDescription(`test`)
.setFooter("ok")
try {
const webhooks = await channel.fetchWebhooks();
const webhook = webhooks.first();
var emb = ['I genuinely like the nutshack.' ,
'Trollface is my favorite meme. PROBLEM?',
'I get legitimetly scared when I play five nights at freddys',
'delet this.',
'I once deep fried a vibrator.',
'Sometimes.. I think why am I alive',
'I could not teach my son how to ride a bike cause I can not ride one myself.',
'I am a gamer, therefore, I am better than you.',
'my favorite emote is :joy:',
'I vomit over my girlfriend while she’s sleeping and clean it all up before she wakes up.',
'My grandma runs faster than me, and she is 95 with arthritis.',
'Thanks for the gold kind stranger!',
'I have a crush on the map from dora the explorer.',
'I got my parents to buy me a Macbook for gaming',
]
await webhook.send(emb[Math.floor(Math.random() * emb.length)], {
username: `${user.username}`,
avatarURL: `${user.displayAvatarURL()}`,
// embeds: [embed],
});
} catch (error) {
msg.reply("Err ahhh! Do I have the perms to manage weebhooks?")
console.error('Error trying to send: ', error);
}
}``` @quartz kindle
USE A BIN PLEASE
@quartz kindle @misty sigil this?
@delicate shore you have two mistakes there
i get this whenever i do a command. te command works fine though
ok?
firs, dont create a new webhook on every single command, the channel will become filled with tons of webhooks in the server configuration
Can these people read I wonder
edit it?
second, youre not waiting for the webhook creation to finish
you're immediatelly sending a message regardless if the webhook exists or not
@quartz kindle @misty sigil this?
@earnest phoenix EUREKA! your line 102 if/else if returns if you aren’t the owner
try removing the line 102 if/else, and that should work
so basically you made all your commands owner only lol
yes Tim
oh lol
that’s basically it
tim can u help me plz (the comand works fine but i get this)
it’s
Can you read pls
R E A D
cannot send empty message
hey @quartz kindle then hwo can i make it edit
post code
but first create
Please people read
also
one
read
i dont have any empty strings
YES
do u send variable contents

do u send variable contents
@hazy sparrow
whats that
like send(variable) a
umm
umm?
message.channel.send(message.channel.send( "**:game_die:" + "|" + message.author.username + "** rolls a dice!" + `\n` + ":blank:" + "|" + "It's a " + "**" + Math.floor(Math.random() * (6- 1 + 1) + 1) + "**"))
Wtf
why is there 2 functions
i found the mistake
Sending a message inside a send message function
ur send is in a send

mate
tim help
tim u should be paid for this
What do you need help with
lmao true
(Plus saying "help" without any details is useless, refrain from doing that)
message.channel.send(message.channel.send(
tim help
pls*
Noice
(Plus saying "help" without any details is useless, refrain from doing that)
@misty sigil he knows my ques
could’ve just said that
ok
@quartz kindle how can i add a timeout so it deltes the weebhook after 2 sec
because delteing weebhook don't delete msg
setTimeout
Deleting a webhook doesn't affect a message
but what is usage
@delicate shore when a webhook is created, it is added to the guilds webhooks list. you probably dont want to edit existing webhooks to avoid interfering with them, but you also dont want to spam new webhooks for no reason.
- await guild.fetchWebhooks
- webhook = webhooks.find(webhook => webhook.name === "my webhook here")
- if(!webhook) { webhook = await channel.createWebhook() }
- if(webhook.channelID !== message.channel) { await webhook.edit() }
- webhook.send()
o
so basically you want to maintain a single webhook for your bot for that guild
ok
if it doesnt exist, create it
then every time you use the command, get this webhook, and check if its in the right channel, if not, change the channel
then send
If discord doesn't pay tim we should raid discord HQ 
Lol
NEW STREAM: raiding discord HQ
unless your bot has manage messages
you cant delete webhooks
@quartz kindle i cannot delete the webhook?
messages sent via webhook have no author, they dont belong to your bot
they can only be deleted by users with delete message permission
the webhook itself yes
it can be deleted from the guild
so it cant be used anymore
o
Yea creating webhooks again and again and again fastly would be an api abuse
o
dek-w
however, using the webhook edit method introduces a race condition
but better like that than spamming webhook creates
however, using the webhook edit method introduces a race condition
@quartz kindle and eleting one?
deleting*
(node:6140) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'remove' of undefined
let tounmute = message.mentions.members.first() || bot.users.cache.get(args[0]);
const config = await MuteRole.findOne({ GuildID: message.guild.id });
let muterole = config.RoleID;
tounmute.roles.remove(muterole);```
help ?
Second one is a user
Users don't have roles
it’d be message.guild.cache.get(args[0]) right?
message.guild.members.cache.get(args[0])
i mean, if its easier to understand, just use the create delete method
oh right
but it makes much more api requests than the edit method
if(command === "embarrass"){
let channel = msg.channel
let member = msg.mentions.members.first() || msg.member,
user = member.user;
. webhook = webhooks.find(webhook => webhook.name === "Black Sheep")
await guild.fetchWebhooks
if(!webhook) { webhook = await channel.createWebhook(`${user.username}`, {
avatar: `${user.displayAvatarURL()}`,
})
if(webhook.channelID !== message.channel) { await webhook.edit() }
.then(webhook => console.log(`Created webhook ${webhook}`)).catch(console.error);
try {
const webhooks = await channel.fetchWebhooks();
const webhook = webhooks.first();
var emb = [responses]
await webhook.edit(emb[Math.floor(Math.random() * emb.length)], {
username: `${user.username}`,
avatarURL: `${user.displayAvatarURL()}`,
// embeds: [embed],
});
} catch (error) {
msg.reply("Err ahhh! Do I have the perms to manage weebhooks?")
console.error('Error trying to send: ', error);
}
}
something like this?
please use a bin for big code blocks
weebhook
Try and see
// create delete method
1. create
2. send
3. delete
1. create
2. send
3. delete
1. create
2. send
3. delete
// edit method without caching
1. fetch
2. create
3. send
1. fetch
2. send
1. fetch
2. send
1. fetch
2. edit (if changed channels)
3. send
// edit method with caching
1. fetch
2. create
3. send
1. send
1. send
1. edit (if changed channels)
2. send
each section would be a user command
so 4 commands with the create method, do 12 api requests
4 commands with the edit method, would do 10 requests if you change channels once
o
4 commands using the edit method with caching and changing channels once, would do 7 requests
ok
its a matter of efficiency basically
does anyone here has nitro? i need a help from them
if(command === "embarrass"){
let channel = msg.channel
let member = msg.mentions.members.first() || msg.member,
user = member.user;
let webhook = webhooks.find(webhook => webhook.name === "Black Sheep")
await guild.fetchWebhooks
if(!webhook) { webhook = await channel.createWebhook(`${user.username}`, {
avatar: `${user.displayAvatarURL()}`,
})
if(webhook.channelID !== message.channel) { await webhook.edit() }
.then(webhook => console.log(`Created webhook ${webhook}`)).catch(console.error);
try {
const webhooks = await channel.fetchWebhooks();
const webhook = webhooks.first();
var emb = [responses]
await webhook.edit(emb[Math.floor(Math.random() * emb.length)], {
username: `${user.username}`,
avatarURL: `${user.displayAvatarURL()}`
});
} catch (error) {
msg.reply("Err ahhh! Do I have the perms to manage webhooks?")
console.error('Error trying to send: ', error);
}
}```
i know it's incorrect
the problem you had before was that you were not awaiting the create
and also not deleting it properly
thats why it only worked on the second command
tim a general question, do you know how to get a animated emoji id without nitro?
what do u want
use \
you'd need someone to use it i guess
nvm
:wobble:
and i dont have nitro
:runmeow:
and get the id
if(command === "embarrass"){
let channel = msg.channel
let member = msg.mentions.members.first() || msg.member,
user = member.user; channel.createWebhook(`${user.username}`, {
avatar: `${user.displayAvatarURL()}`,
}).then(webhook => console.log(`Created webhook ${webhook}`)).catch(console.error);
const embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setDescription(`test`)
.setFooter("ok")
try {
const webhooks = await channel.fetchWebhooks();
const webhook = webhooks.first();
var emb = ['I genuinely like the nutshack.' ,
'Trollface is my favorite meme. PROBLEM?',
'I get legitimetly scared when I play five nights at freddys',
'delet this.',
'I once deep fried a vibrator.',
'Sometimes.. I think why am I alive',
'I could not teach my son how to ride a bike cause I can not ride one myself.',
'I am a gamer, therefore, I am better than you.',
'my favorite emote is :joy:',
'I vomit over my girlfriend while she’s sleeping and clean it all up before she wakes up.',
'My grandma runs faster than me, and she is 95 with arthritis.',
'Thanks for the gold kind stranger!',
'I have a crush on the map from dora the explorer.',
'I got my parents to buy me a Macbook for gaming',
]
await webhook.send(emb[Math.floor(Math.random() * emb.length)], {
username: `${user.username}`,
avatarURL: `${user.displayAvatarURL()}`,
// embeds: [embed],
});
} catch (error) {
msg.reply("Err ahhh! Do I have the perms to manage weebhooks?")
console.error('Error trying to send: ', error);
}
}
ok let me try that
you're not
await webhook.send
let webhook = await channel.createWebhook()
await webhook.send()
await webhook.delete()
@hazy sparrow there is a bot
called Animated Emoji
it can use any animated emoji
i have that in my server
use that
can you send the link in dm
just do \:emoji:.
i want the id of this
436677458339823636
ok ty
message.delete()
"ticket me"
Deleting the message of the bot ? @earnest phoenix
<Message>.delete() will delete the message
@quartz kindle well uhh the command (work command) it works but when the user runs again it doesnt store the number like the cmd works but the number doesnt get stored into the database
@delicate shore what does this do (im asking for help fro you)
yup
do i have to define RANDOM?
No.
ok great
this red color is random
The library generates the random color for you.
it can be anything
this is something i never knew i wanted
@quartz kindle well uhh the command (work command) it works but when the user runs again it doesnt store the number like the cmd works but the number doesnt get stored into the database
bow pro there are more pre-defined colors Discord.js allows you to pass: https://discord.js.org/#/docs/main/stable/typedef/ColorResolvable
help me if you can
did not delete my messages @earnest phoenix
How do I delete my answer when I ask a bot question ?
<Message>.delete
@delicate shore can i set the thumbnail to "RANDOM" for it to give random colours?
You must be kidding.
@delicate shore can i set the thumbnail to "RANDOM" for it to give random colours?
@hazy sparrow no
oof ok
is there a way to do so?
owo bot does it though
what
@misty sigil
well uhh the command (work command) it works but when the user runs again it doesnt store the number like the cmd works but the number doesnt get stored into the database
oh that
that
is an api
ohh
or it could be canvas
ok thanks
with what
idk
@summer torrent I'm using v11 doesn't it have to be like this message.delete()
😦
i've never worked with hooks
@rigid maple it is
it's not working tho
you are not awaiting the creation
?
you have to await the createWebhook
how tho
well uhh the command (work command) it works but when the user runs again it doesnt store the number like the cmd works but the number doesnt get stored into the database
i am awating
like i said before
<Message>.delete() ?
let webhook = await channel.createWebhook()
you dont need to fetch
furthermore that fetching is wrong
it will fetch the first webhook, whatever it is, even if its other people's webhooks
let webhook = await channel.createWebhook()
@quartz kindle do i need to entter name and avatar here as well?
there is no name during creation
earlier
only when sending
well uhh the command (work command) it works but when the user runs again it doesnt store the number like the cmd works but the number doesnt get stored into the database
@quartz kindle could you help?
@quartz kindle what about the name?
i meant username
webhook name is one thing, webhook username is another thing
should have clarified
@quartz kindle https://hastebin.com/qumosujewu.js not working
it makes webhooks but now don't even send
msg
and keeps saying error
and logs nothing
dude
yes?
what
thats where you are creating the webhook
thats what you need to await
not add another empty createWebhook
oootgoogogogogg
message.edit()
@quartz kindle it says cannot read property of send https://hastebin.com/uhuvupukig.js
ok

.>
remove .then() on .then(woefhowuehouwhg) means remove .then(wouehouwehouwhge) not remove .then and leave (owuehowuhetuwe)
tim did you have a stroke?
fpheiheoghpeihpi
yes, but thats how promise chaining works
if you do let bla = await a(a).then(b).then(c)
bla gets the result of c, not a
how would i remove these comma's in between Array elements?
let ShipTable = [];
console.log(Array.length)
for(var j=0; j < Array.length; j ++) {
ShipTable.push(`<tr><td>${Array[j][3]}}]</td><td>[${Array[j][2]}]</td><td>${Array[j][1]}</td><td>${Array[j][0]}</td><td>${(Array[j][4] / Array[j][1]).toFixed(0)}</td></tr>`)
}```
Array.length makes no sense
nvm. found it
Array is the base array object, you should not be using it as a variable
Quite easier to keep track of that stuff unlike in programming languages where casing doesn't matter
reworked the ShipTable.toString() and then replaced using regex
array.toString() does the same as array.join(",")
anyone no y i get this error?
you need array.join("") if you want to join with no delimiter
anyone no y i get this error?
its in my play command
more code?
?
that error means you're trying to use .get on something that doesnt exist
const queue = client.musicQueue.get(message.guild.id)
that doesn't contain get
Hello, does someone know how to open an image as an array ?
oh now id does
then if you get that error, it means client.musicQueue doesnt exist
@barren basin open an image as an array?
what kind of array?
array of pixel data?
yes
you need to use an image parser or something. which language are you using?
javascript
@still badge did you copy paste that code?
@barren basin the canvas library can do that
and probably other image manipulation libraries can as well
such as jimp and sharp
ok thank you i'll see that
well if you created it yourself...
What’s a good file based database for nodejs
Lots of reads and writes
client.musicQueue is not a standard property
it doesnt exist in discord.js
unless you create it yourself
the code you are using, assumes there is a client.musicQueue created somewhere, by you
@obtuse jolt use sqlite if you want to have it local
hold on
otherwise something like Postgres, mysql or mongodb
how do i define args in a command handler? do i have to define discord, then client, then message, then args?
mongodb and others can also be local, sqlite is just the easiest to setup
doesnt matter what you define
i got it
@hazy sparrow ```
cmd.run(client, message, args, settings);
you only need that in your main file
ah ok
the file where you do client.login()
@quartz kindle ty lol i was missing a collection
👍
what about this
what about it
this splits your arguments off your prefix
do i have to put it in the command handler also?
yes
if you want it to be accessible by your commands, yes
okay to do so i have to define message
for which i have to defiine Discord.Client()
no...
for which i have to define discord.js"
on Message event?
^
this gives you the message object
and for client you can just pass your client to the command handler
or attach it to your events if you have a event handler
or just get it from any other discord class
so wll this work
module.exports = {
name: 'roll',
description: "this is a dice command. it generates random numbers from 1-x or by default, 6. .",
execute(message){
const roll = Math.floor(Math.random() * (6- 1 + 1) + 1)
const args = message.content.slice(prefix.length).split(/ +/);
if(roll === 1) {
message.channel.send( "**:game_die:" + "|" + message.author.username + "** rolls a dice!\n" + ":blank:" + "|" + " Booo... It's a " + "**1**")
} if(roll === 2) {
message.channel.send( "**:game_die:" + "|" + message.author.username + "** rolls a dice!\n" + ":blank:" + "|" + " Booo... It's a " + "**2**")
} if(roll === 3) {
message.channel.send( "**:game_die:" + "|" + message.author.username + "** rolls a dice!\n" + ":blank:" + "|" + " Nice! It's a " + "**3**")
} if(roll === 4) {
message.channel.send( "**:game_die:" + "|" + message.author.username + "** rolls a dice!\n" + ":blank:" + "|" + " Yikes It's a " + "**4**")
} if(roll === 5) {
message.channel.send( "**:game_die:" + "|" + message.author.username + "** rolls a dice!\n" + ":blank:" + "|" + " What a lucky day it is! It's a " + "**5**")
} if(roll === 6/>6) {
message.channel.send( "**:game_die:" + "|" + message.author.username + "** rolls a dice!\n" + ":blank:" + "|" + " WHOA! It's a " + "**6**")
}
}
}
@quartz kindle @lusty quest
Anyone know how to fix this?
UnhandledPromiseRejectionWarning: Error: Something took too long to do.
It happened after try to kick all ALT spamming bot
dont care about the number in the string
otherwise something like Postgres, mysql or mongodb
@lusty quest those aren't file based
aka 1 single file for all data
@knotty steeple i know but a single file database is anyways a bad idea
@hazy sparrow that looks horrendous
they are slow af
no not really
wait until it aproaches 1GB
sqlite can handle 1tb what is u saying
there is a difference between a json db and sqlite
why would u use json as a db
a dice command...
yea but why 6 different messages?
make it 1 message




