#development
1 messages ยท Page 1430 of 1
so the following code only produces the following "role" @everyone
print( (get(message.author.roles)) )
Am i missing something? Where is this in the embed?
nvm
anyone know anything about shebang lines
if anyone has experience with discord.js-light, i need some help with some errors i am getting while trying to use the voiceStateUpdate event
what i am trying to achieve is for my bot to leave the vc and clear the music queue when there are no other users in it, or clear the queue when manually disconnected it. i was able to achieve this with normal discord.js using this code
// If a user leaves or changes channels
if (oldState != null && oldState.channelID != newState.channelID) {
const serverQueue = client.queue.get(oldState.guild.id);
const channelInfo = oldState.guild.channels.fetch(oldState.channelID);
const botChannelID = oldState.guild.members.fetch(client.user.id).voice.channelID;
const usersInVC = channelInfo.members.filter(member => !member.user.bot).size;
// If the bot is the only user in the VC clear the queue and leave
if (channelInfo.members.has(client.user.id) && usersInVC < 1) {
if (serverQueue) {
if (serverQueue.twentyFourSeven) return;
let leaveEmbed = new Discord.MessageEmbed()
.setColor(0xff4a4a)
.setTitle(`๐ Left due to no other users being present in the VC.`);
serverQueue.textChannel.send(leaveEmbed);
if (serverQueue.connection.dispatcher) serverQueue.connection.dispatcher.destroy();
if (client.queue) client.queue.delete(oldState.guild.id);
}
channelInfo.leave();
// If the bot is not in a VC and there is a queue, clear the queue
} else if (botChannelID == null && serverQueue) {
let leaveEmbed = new Discord.MessageEmbed()
.setColor(0xff4a4a)
.setTitle(`๐ Left due to being manually disconnected.`);
serverQueue.textChannel.send(leaveEmbed);
if (client.queue) client.queue.delete(oldState.guild.id);
}
}
problem is, discord.js light sends a null response when someone disconnects, causing the code to error out, and i cant seem to find a way to make it detect the specifics i need it to with that
any help is appreciated
any way i can get the lyrics of asong?
scrape genius
if you google around you can also probably find alternative apis
ok
if(!oldState && newState) // user joined
if(oldState && !newState) // user left
if(oldState && newState) // user changed channel or changed something else
ok, thanks!
commandHandler(path) {
this.fs.readdirSync(this.path.normalize(path)).map((f) => {
const File = require(this.path.join(__dirname, '..', path, f));
this.commands.set(File.name, File);
});
};
getCommand(cmd) {
return this.command.has(cmd) ? this.command.get(cmd) : false;
}
start(token, path) {
this.commandHandler(path);
this.login(token);
this.mongoose.connect('//this is the link but i deleted it cuz its important to keep safe i think', {
useNewUrlParser: true,
useUnifiedTopology: true
});
this.mongoose.connection.on('connected', () => console.log('DB connected'));
this.on('ready', () => console.log(`${this.user.tag} is now online!`));
this.on('message', async(message) => {
if(message.author.bot || !message.guild || !message.content.toLowerCase().startsWith(this.config.prefix)) return;
const args = message.content.slice(this.config.prefix.lenght).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();
const command = this.getCommand(cmd);
if(!command) return;
if(command.timeout) {
if(this.timeouts.has(`${command.name}${message.author.id}`)) return message.channel.send(this.embed({ description: `Please wait ${this.ms(Date.now() - this.timeouts.get(`${command.name}${message.author.id}`), { long: true })}`}));
} else return command.run(this, message, args).catch(console.error);
})
}
embed(data, message) {
return new this.discord.MessageEmbed({ ...data, color: 'RANDOM' }).setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, format: 'png' }));
}
};
module.exports = EconomyClient
so i was following a tutorial for the beginning of an economy bot and I ran into a problem as it says there are some problems with the code and I need to fix them to move one. can anyone help?
show the code before
ok
const { Client, Collection, MessageEmbed } = require('discord.js');
class EconomyClient extends Client {
constructor() {
super();
this.discord = require('discord.js');
this.fs = require('fs');
this.path = require('path');
this.ms = require('ms');
this.mongoose = require('mongoose');
this.commands = new Collection();
this.timeout = new Collection();
this.config = {
prefix: '?',
};
this.schemas = this.mongoose.model('economy', new this.mongoose.Schema({
user: String,
Coins: Number
}))
}
}
and this is a reason im not a good coder, way too many spelling mistakes
also, you have one bracket too many
you're ending the class before the other methods
which bracket is it?
just copy and paste your code into an online js beautifier or whatever and you'll see
anyone know how to show how many severs its in like a live feed of how many seves its in
pusher + html
ez
can you show me picture
Tf is a pusher?
no
pusher
and html
You use the API and send the bot guilds every x hours.
Webhook or whatever it's called.
what do you mean
is it possible to give your discord bot a custom emoji on its status
im not making a website its for my bot's long description on top.gg
yes
?
so html or markdown (https://www.markdownguide.org/getting-started/)
what is a partial user?
okayy so this is my bots long description ok?
Do u see the images where it says Help Panel @hollow sedge ?
or how can you check if a user is a webhook
sigh ik this is markdown
good question
thanks?
can you show me the markdown for the image @dim wadi
idk what a partial is
alr
is it possible to give your discord bot a custom emoji on its status
i dont think bots can have emoji statuses anyway
#development message this then msg.author.bot doesn't seem to work
dude
oops
if you had showed me that i couldve helped you lol
sowwy ๐ฆ
lol as long as you fixed it, it's good
UwU ๐
The library usuall drops events if the required data isn't cached already. For example, if a message was deleted and that particular message wasn't found in cache then the messageDelete event isn't fired. However, if you enable partials, you will start receiving the ID related to the event. For example, if a message was deleted but wasn't found in cache, the event will still be fired but, the caveat being that the message object passed to the event will only have the ID, in this case, the message ID. Head over to the docs to find an example with the messageReactionAdd event as well.
uh i have a question
is it possible to like list a persons warns AND the person who warned them the reason and time?
yes
if you keep track of it
a usual pattern for this would be to have a punishment object which has the following
type property that defines the punishment type (i.e. warn/ban/kick etc)
target property that defines the target of the punishment (user id)
issuer property that defines the person responsible for the punishment (user id)
timestamp property that defines the unix timestamp of the occurance
you can obviously throw in a reason and other shit in there
No, bots do not have access to the user endpoint and cannot use custom status. So, you can neither have custom statuses nor emojis in your bot's status.
you're wrong on some of that
you can definitely give custom statuses to bots
it's been around longer than users even had the option @lunar sequoia
Umm no, when I say custom status, it is referring to the Custom status that users can set on their profiles. Bots have never had access to set this custom status however, you can set a status with the default PLAYING, WATCHING, LISTENING, etc.
const { Message } = require("discord.js");
const Client = require("../structures/Client");
module.exports = {
name: `ping`,
/**
* @param {Client} client
* @param {Message} message
* @param {string[]} args
*/
run: async (client, message, args) => {
const msg = await message.channel.send("Pinging..");
await msg.edit(
client.embed(
{
description: `Pong!\nMessage edit: ${
msg.createdAt - message.createdAt
}\nWS: ${client.ws.ping}`,
},
message
)
);
await msg.edit(`Pong!`);
},
};
So, I created the ping command and I did the node . thing and it said the bot was online yay but when I typed the command in my discord, it didn't work and an error popped up. Ill send the ss of the error below. If anyone can help me figure out where I went wrong, I'd like that.
it appears to be an issue in your client.js, could you send the code for that
const config = require('../../config.json');
module.exports = {
name: 'help',
aliases: ['commands'],
cooldown: 3,
description: 'List all of my commands or info about a specific command',
usage: '<command>',
type: 'info',
execute: (message, args) => {
//...
message.channel.send(config.color)
//Cannot access 'config' before initialization
ok
const { Client, Collection, MessageEmbed } = require("discord.js");
const { set } = require("mongoose");
class EconomyClient extends Client {
constructor() {
super();
this.discord = require("discord.js");
this.fs = require("fs");
this.path = require("path");
this.ms = require("ms");
this.mongoose = require("mongoose");
this.commands = new Collection();
this.timeout = new Collection();
this.config = {
prefix: "?",
};
this.schemas = this.mongoose.model(
"economy",
new this.mongoose.Schema({
user: String,
Coins: Number,
})
);
}
commandHandler(path) {
this.fs.readdirSync(this.path.normalize(path)).map((f) => {
const File = require(this.path.join(__dirname, "..", path, f));
this.commands.set(File.name, File);
});
}
getCommand(cmd) {
return this.command.has(cmd) ? this.command.get(cmd) : false;
}
start(token, path) {
this.commandHandler(path);
this.login(token);
this.mongoose.connect(
"//this is a link i should keep safe or smth",
{
useNewUrlParser: true,
useUnifiedTopology: true,
}
);
this.mongoose.connection.on("connected", () => console.log("DB connected"));
this.on("ready", () => console.log(`${this.user.tag} is now online!`));
this.on("message", async (message) => {
if (
message.author.bot ||
!message.guild ||
!message.content.toLowerCase().startsWith(this.config.prefix)
)
return;
const args = message.content
.slice(this.config.prefix.lenght)
.trim()
.split(/ +/g);
const cmd = args.shift().toLowerCase();
const command = this.getCommand(cmd);
if (!command) return;
if (command.timeout) {
if (this.timeouts.has(`${command.name}${message.author.id}`))
return message.channel.send(
this.embed({
description: `Please wait ${this.ms(
Date.now() -
this.timeouts.get(`${command.name}${message.author.id}`),
{ long: true }
)}`,
})
);
command.run(this, message, args).catch(console.error);
this.timeouts.set(
`${command.name}${message.author.id}`,
Date.now() + command.timeout
);
setTimeout(() => {
this.timeouts.delete(`${command.name}${message.author.id}`);
});
} else return command.run(this, message, args).catch(console.error);
});
}
embed(data, message) {
return new this.discord.MessageEmbed({
...data,
color: "RANDOM",
}).setFooter(
message.author.tag,
message.author.displayAvatarURL({
dynamic: true,
format: "png",
})
);
}
}
module.exports = EconomyClient;
thats the whole thing
looks like its an issue with this block
if (command.timeout) {
if (this.timeouts.has(`${command.name}${message.author.id}`))
return message.channel.send(
this.embed({
description: `Please wait ${this.ms(
Date.now() -
this.timeouts.get(`${command.name}${message.author.id}`),
{ long: true }
)}`,
})
);
on the client?
so what should i do, make one?
no, you just made a typo :)
this.timeout = new Collection();
should be
this.timeouts = new Collection();
yeah the reason im not a great coder is a) im not 100% familiar with the language and b) im not the best typer
yeah i feel that lol
hey, @south sinew, sorry for ping but it is still giving an error
whats the error?
ok, so timeouts is still undefined
i thought i changed it tho
wait.....
let me try smth
nvm i thought it was because i didnt save it
but still gave the error
different or same?
same
hmmm
just check over your code again and make sure that timeouts is still defined throughout
js is wack sometimes
no
alr then they are all changed
hmm, I'm not too sure but try replacing the if condition to this.timeouts && this.timeouts.has()
Yup, give it a try now
What's the error now?
ok
In your getCommand function, it's supposed to be this.commands.has
where?
Show me where line 31 is
Yeah, you missed an "s"
so should i undo what you had me do earlier?
So, it should be this.commands.has()?this.commands.get():false
No, not necessary. It shouldn't be an issue anyway.
ok
so, it didnt work nor did it give me an error
when i did ?ping on my server, it didnt respond
but i havent received an error yet
What is line 31 now?
Am I unable to verify my bot if I'm under 18? Discord requires a government-issued ID.
Nah, as long as you're over the minimum age (which is 13 and 16 in some countries), you can verify your bot
Yeah, passports work and if you have a driver's liscence that works
you can get an id while you're underage though, no?
I'm under 15 so I had a bit of a struggle lol
i got my id when i was 13
Yes, but Discord declined mine.
"We are unable to verify your identity because one or more of the documents you provided are not supported. Please try again."
It's government issued kids ID, I'm not sure why it's not accepted.
they don't accept certain documents from certain countries
Guess I'll try it again with a student ID
Guess I'm fucked ๐ @earnest phoenix
Do you live inside a cave
could anyone help me find out what is wrong with my code? when i node it, it says that its online and connected but when i go into my server and run the command, there isnt a response. before, everytime there wasnt a response the terminal said there was an error but there is no appeared error in the terminal.
don't ask to ask
just ask about your problem right away
provide your code and the errors you get
and obviously state your lib and language
lib?
library
lang is js
Too bad that we aren't lucky enough to live in a first world country.
const { Client, Collection, MessageEmbed } = require("discord.js");
const { set } = require("mongoose");
class EconomyClient extends Client {
constructor() {
super();
this.discord = require("discord.js");
this.fs = require("fs");
this.path = require("path");
this.ms = require("ms");
this.mongoose = require("mongoose");
this.commands = new Collection();
this.timeouts = new Collection();
this.config = {
prefix: "?",
};
this.schemas = this.mongoose.model(
"economy",
new this.mongoose.Schema({
user: String,
Coins: Number,
})
);
}
commandHandler(path) {
this.fs.readdirSync(this.path.normalize(path)).map((f) => {
const File = require(this.path.join(__dirname, "..", path, f));
this.commands.set(File.name, File);
});
}
getCommand(cmd) {
return this.commands.has(cmd) ? this.commands.get(cmd) : false;
}
start(token, path) {
this.commandHandler(path);
this.login(token);
this.mongoose.connect(
"//this was the important link that i might have leaked",
{
useNewUrlParser: true,
useUnifiedTopology: true,
}
);
this.mongoose.connection.on("connected", () => console.log("DB connected"));
this.on("ready", () => console.log(`${this.user.tag} is now online!`));
this.on("message", async (message) => {
if (
message.author.bot ||
!message.guild ||
!message.content.toLowerCase().startsWith(this.config.prefix)
)
return;
const args = message.content
.slice(this.config.prefix.lenght)
.trim()
.split(/ +/g);
const cmd = args.shift().toLowerCase();
const command = this.getCommand(cmd);
if (!command) return;
if (command.timeouts) {
if (this.timeouts.has(`${command.name}${message.author.id}`))
return message.channel.send(
this.embed({
description: `Please wait ${this.ms(
Date.now() -
this.timeouts.get(`${command.name}${message.author.id}`),
{ long: true }
)}`,
})
);
command.run(this, message, args).catch(console.error);
this.timeouts.set(
`${command.name}${message.author.id}`,
Date.now() + command.timeouts
);
setTimeout(() => {
this.timeouts.delete(`${command.name}${message.author.id}`);
});
} else return command.run(this, message, args).catch(console.error);
});
}
embed(data, message) {
return new this.discord.MessageEmbed({
...data,
color: "RANDOM",
}).setFooter(
message.author.tag,
message.author.displayAvatarURL({
dynamic: true,
format: "png",
})
);
}
}
module.exports = EconomyClient;
thats the client.js
const { Message } = require("discord.js");
const Client = require("../structures/Client");
module.exports = {
name: `ping`,
/**
* @param {Client} client
* @param {Message} message
* @param {string[]} args
*/
run: async (client, message, args) => {
const msg = await message.channel.send("Pinging..");
await msg.edit(
client.embed(
{
description: `Pong!\nMessage edit: ${
msg.createdAt - message.createdAt
}\nWS: ${client.ws.ping}`,
},
message
)
);
await msg.edit(`Pong!`);
},
};
thats the ping.js
Jeez
bruh imagine js
i dont have to
You leaked your mongo URI
DELET THIS
Change your password
will do
Log your variables
Make sure that the command was at least executed
If not then the problem is from somewhere else
its not letting me type in the debug thing
Just use console.log()
Add a console.log("test") to the first line of your ping command and try running it
If test appears in your console then the command has issues
no, it didnt
Change it to console.log(client, message, args);
Where did you put that
in the top of the ping.js file, should i have put it in the client.js file?
You put the test on there too?
try it again inside the first line of that function
Yes
wdym
idk
Then.... Try it?
You didn't remove that console.log() on the top of the file...
i did
Show your command
delete the other one or keep it
Keep it
So the command wasn't found
Try moving that console.log() one line above
Above the return
Run the command
Then your message event is broken
how do i fix it?
Hi
I doubt this would change anything since if the command wasn't found, it would return false which in this case it didn't
So it's somewhere else
I have posted a bot https://top.gg/bot/784608351119736832 but it is not showing in search of top.gg
in where?
Never mind, can you add console.log(message) on the first line of this function?
Before if
after this.on("message",
Above if
oh
what code for first bot in visual studiio code?
im first time use the visual studio code
Start by learning javascript.
Useful links for learning JavaScript and Node:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie's Accelerated JS: https://js.evie.dev/
hmm yeah thx
Hello, this question is targeted to people who have music bots.
Basically I have bot, and I started working on a music cog with lavalink. I am wanting to put these changes on my host but I have no clue where to start. My host is pebblehost and i have their 5 dollar a month bot plan. For lavalink do I need a dedicated server?
Step 1) learn programming
Step 2) choose a library
Step 3) code the bot
If you're not going to learn programming, you're not making a music bot, you're just shovelling code, and you might as well just use Groovy.
Making a bot while copying code is like thinking you're an artist because you can do a puzzle.
you could use a GUI tool to write a bot. but writing is not really the right therm for it
you can run lavalink on the same server.
https://top.gg/bot/728115804826239017 how we feelin about the look of this
did you get an error?
it's displayAvatarURL()
can I host the bot with firebase
its not really designed for it. better use a compute engine machine
@green kestrel idk if this gives you an idea for future scaling but its an attempt i guess https://gist.github.com/DasWolke/c9d7dfe6a78445011162a12abd32091d
SF
how can i get users in voice channel, so im making when u type !users to show all users in voice channel.
but in embed
DiscordAPIError: Cannot send an empty message . Im trying to ping the user in a channel after they join so i do
const channel = client.channels.cache.get('mychannelid')
channel.send(member);
})```
.send(`<@${member.id}>`)
if(message.content.startsWith(prefix + "avatar") || message.content.startsWith(prefix + "av")){
let embed = new Discord.MessageEmbed()
.setImage(message.mentions.users.size.first().avatarURL())
.setColor("RANDOM")
.setFooter("text
")
message.channel.send(embed)
}```
can someone check?
let embed = new Discord.MessageEmbed()
.setImage(message.mentions.users.size.first().avatarURL())
.setColor("RANDOM")
.setFooter("text")
message.channel.send(embed)
}```
uhh
^^^^
i thought you were not supposed to spoonfeed
but you look like a nice guy
thnx btw
you arent supposed to spoonfeed smh
Hi ppl,
I want to do a command that plays the Snowgiving Radio in JS.
Problem is it is a m3u stream. Is there any way to play it anyways?
I tried ```js
channel.join()
.then(connection => {
const dispatcher = connection.play('http://ice55.securenetsystems.net/DASH45.m3u');
message.reply("Should Play")
dispatcher.on("end", end => {channel.leave()});
})
.catch(console.error);
But it doesnt play any Audio
help
@earnest phoenix dont use heroku, problem solved
hey happy
refer to pins
the code you gave me shows an error
are there any errors thrown?
Nope just doesnt play somehow
I guess it only supports mp3 and not m3u. Okay imma try that rq
@reef mantle size is a number, the size of the discord collection
Do it without .size i guess
Doesnt help too. I guess it only supports MP3
yeah id assume that
if you want higher quality you can always check if theres a higher bitrate
But how do i play m3u ? Or convert it to mp3
seems like
huh
I think i got it
lemme try
It seems like it works now
I just removed the .m3u
And the Quality is wow
gg
ty ^^
Gonna Continue the Command
But one question tho
Should i do a Broadcast where ppl subscribe or for every guild a own Player?
what
dont put it behind a paywall 
No i mean discord.js Broadcast
what is that?
https://discordjs.guide/voice/voice-broadcasts.html#broadcastdispatcher this thingy i guess
Imma just stay with that
ah
hey guys
sorry if i am asking again but
how to make our bot say something everyday at the same time
i know i have to use timeout
but how i do not know
as i am still an average
hey guys how do i set the color of an embed in discord.py to random?
because i know in javascript you can just use "RANDOM".
how can that be done in py?
you should probably use node-cron
pretty sure you have to make a random color generator on your own. afaik i dont think there's a "RANDOM" in python discord
Interesting this is what I'm doing right now just with multiple "cache workers"
ok
So I can restart subsets of the shards rather than having to cold boot them all for an upgrade I can rolling restart them
does the broadcasting of the shardids could be managed over it? like you add a new one without having to reboot all of them
Bro Log Set Kyu nahi ho raha DLS Vote ka?
english please
Why Log is being not setuped With DLS Vote Bot??
Why am I getting this ?
(node:3879) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
at Object.embedDes (/app/res/reference.js:57:22)
My code is
embedDes : (message,Title,Description,Footer) => {
let emb;
if(Footer == false || Footer == undefined){
emb = new Discord.MessageEmbed()
.setColor("#ff6f61")
.setTitle(Title)
.setDescription(Description)
}else{
emb = new Discord.MessageEmbed()
.setColor("#ff6f61")
.setTitle(Title)
.setDescription(Description)
.setFooter(Footer)
}
message.channel.send(emb);
}
I'm getting error here
message.channel.send(emb);
Don't mind the ||shitty|| code
Update your Node.js Version
oh it works fine on my pc but this error shows on vps
I'll try
let reason = args.slice(1).join(" ");
if(!reason) reason = 'Belirtilmemiล.';
let warnings = db.get(`warnings_${message.guild.id}_${user.id}`);
if(warnings === 3) return message.channel.send(`${user} adlฤฑ kullanฤฑcฤฑ zaten **3 uyarฤฑsฤฑ** var. Daha fazla veremezsin.`);
i want to make reason compulsory how do i do that? I mean like that: !warn <@user> (no reason)
and message channel send ('You should give a reason')
how do i that
if(!reason) return message.channel.send("you must provide a reason")
thanks
How can I check if args[0] is a mention of a channel?
Use regex to check if it's a channel mention
channel = message.mentions.channels.first();
@molten yarrow no
Or you could just check if the message contains a channel mention ^
if I use it like that, any args will count as the first channel mentioned
Thats why you check it
I will try to use regex just like the voltrex said
but that is args[0] ?
that way, any agrs would count. If I mentioned the channel in args [1] it would pick up in the same way, but I just want to take args [0]
How the arg system works is if I do "!channel #channel then say text" it will only detect args[0] which is the channel
With args[1] being the text it won't respond to it
Unless you code it to
๐ ๐
Hi,
I have a issue with Playing audio with my Bot on NodeJS v14.15.0. Somehow it says i dont have a Opus Module even tho i have @discordjs/opus installed and if i try opusscript it gives me a Chunk full of Error
how would i store it
Can anyone help me with this Opus issue?
would love to but i make a big circle around music bots bcs they are a pain in the ass
there are so many ways, like Databases, maps (only if it doesnt need to be persistant)
why?
what database should i do though
what did you want to store?
i would just use MoonSQL but some of the functions im storing in it would contradict what i want to store
im making a warn command that stores the reason points the person who warned them and the person who got warned
any database will work
quick.db to?
yea
I mean it literally works on my PC that uses Debian 10 as a Base without even root. But my Server with Debian 10 it is dying
same version of node installed on both?
Server: 14 | PC: 15
i would use a unique id as key and then add the Warn reason, Warned user id, and Moderator User ID to it
for the unique id i would just use guild.id+user.id
Now its both 15
did you tryed to make the db call async?
no?
also your syntax is wrong
look at the example Superbrain posted above and your way of storing

db.set(`warned_${message.guild.id}`,{user:userid,points:points,reason:reason,issuer:issuer})
then you can also call it by db.get(`warned_YOURGUILDID.user`)as example
does it work now?
Nope
did you updated all packages on the server?
It doesnt complain now but it doesnt play any audio
remove the node_modules folder and run npm install
Everything is up to date. Gonna try
Doesnt help
It just doesnt play any audio
But the URL works
cuz my PC works with it
And no errors at all
The URL even works with wget
strange
@lusty quest is there a way to like
make a number then each time they get warned it goes from 1 - 2
Hotpatched with Replacing Opus with Lavalink
opus is a codec?
const canva = require('canvacord');
const Discord = require('discord.js')
module.exports = {
name: "trigger",
description: "Trigger yourself",
async run (client, message, args) {
let avatar = message.author.displayAvatarURL({dynamic: false, format: "png"});
let image = await canva.trigger(avatar);
let triggered = new Discord.MessageAttachment(image, "triggered.gif")
message.channel.send(triggered);
}
}```
```node:14016) UnhandledPromiseRejectionWarning: TypeError: canva.trigger is not a function
Why if i use this code it says that error?
canva.trigger doesnt exist
use a function that exist
or you have somewhere a mistake in your syntax
??
sorry im new
what do you mean
did you know basic js?
yeah
@timber fractal they where probably using a older version of Canvacord
yea is the next guess
oof how to fix that
use a up2date tutorial
@timber fractal step 1. Find a better tutorial
-_-
5sec of googling xD
im gonna try
or read the docs
LOL
That too
how do i install canvacord on windows
the dollar sign is not an command
'$' is not recognized as an internal or external command,
operable program or batch file.
dont use the $ xD
why in ytdl-core songInfo.videoDetails.author.name is unfefined?
if you going to answer "idk" please dont respond
Damn+
Code?
songInfo = await ytdl.getInfo(results[0].url);
song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
duration: songInfo.videoDetails.lengthSeconds,
id: songInfo.videoDetails.videoId,
author: songInfo.videoDetails.author.name
};```
It wasn't on purpose
Debug
i know xD
Log songInfo
unfefined
holy fk thats a lot of debug
ok
Log songInfo.videoDetails
the debug shows it as it is
That's what you'll be using
allowRatings: true,
viewCount: '12089',
author: 'Testing',
isLowLatencyLiveStream: false,
isPrivate: false,
isUnpluggedCorpus: false,
author isnt undefined in the debug
guess so
@jovial nexus Now?
wait
What did you put
what do you want to get?
Yes, because you want to get everything
Can you show what you did
just changued songInfo.videoDetails.author.name to songInfo.videoDetails.author
console.log(songInfo)?
the code is like js songInfo = await ytdl.getInfo(results[0].url); song = { title: songInfo.videoDetails.title, url: songInfo.videoDetails.video_url, duration: songInfo.videoDetails.lengthSeconds, id: songInfo.videoDetails.videoId, author: songInfo.videoDetails.author }; console.log(songInfo) message.channel.send(song.author)
mistake there
Change the console.log content to songInfo.videoDetails.author
i guess
I'm still not sure what the content of songInfo.videoDetails is
Can you post it in hastebin?
When I try to get info.videoDetails.author.name, it returns undefined. This is some basic code that I use to try to get it. const ytdl = require('ytdl-core'); ytdl.getBasicInfo(&...
guess what
ok i have a TypeError: Cannot read property 'name' of undefined
function walk(dir, callback) {
fs.readdir(dir, function(err, files) {
if (err) throw err;
files.forEach(function(file) {
console.log(`Loading a total of ${files.length} commands.`);
var filepath = path.join(dir, file);
fs.stat(filepath, function(err,stats) {
if (stats.isDirectory()) {
walk(filepath, callback);
} else if (stats.isFile() && file.endsWith('.js')) {
let props = require(`./${filepath}`);
console.log(`Loading Command: ${props.help.name} โ`);
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
}
});
});
});
}
walk(`./commands/`)```
@analog kettle would be nice if you actually threw the whole error, but anyway
one of the commands you have doesnt have name in it
c:\Users\joshu\Desktop\Coding\TC Bot\Base.js:21
console.log(Loading Command: ${props.help.name} โ);
^
TypeError: Cannot read property 'name' of undefined
at c:\Users\joshu\Desktop\Coding\TC Bot\Base.js:21:62
at FSReqCallback.oncomplete (fs.js:168:5)
thats the error
Looks like the help export doesn't even exist in one of them
git : The term 'git' 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
+ git init
+ ~~~
+ CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
i have a problem with git, and i don't know how to fix it
I already did
clearly not
im fairly certain windows doesnt need to be restarted for git
worst case scenario you could just open a git terminal
on mine the commands load but then instantly the code stops :/. eh ill fix it eventually
I had that issue
git bash, boom
had to manually insert it into windows env
you just need to restart terminal if you installed it after you open the terminal
yo whats the ETA for verification again?:
What's in procfile?
worker: node .
Did you refresh the page?
yes
Are you deploying all changes to a github repo?
no
Then you're using heroku's cli?
That's strange
I am trying to send a message to a channel when i get a event for it (py)
here is my code
@bot.event
async def on_guild_channel_create(channel):
await channel.send(random.choice(messages))
and my messages is a list
messages = ["Ooh, a new channel!", "First!"]
wont send
idk y
IK
Can someone help me set up a event to see when someone has voted for my bot in python
node (main start file).js
I am trying to send a message to a channel when i get a event for it (py)
here is my code
async def on_guild_channel_create(channel):
await channel.send(random.choice(messages))```
and my messages is a list
```messages = ["Ooh, a new channel!", "First!"]```
wont send
idk y
no errors
just wont send
i tried a try except
no error
random.choice()
import random
How would I test this?
dk what I did but my message event is giving this?
(node:11284) UnhandledPromiseRejectionWarning: DiscordAPIError: 401: Unauthorized
worked for one command, then stopped working all together with this.
go to the link of webhooks here
on the pic
webhooks: dont ruslte yor feather for no reason, if youre lost you can read more aobut out _webhooks here_
oh
So something strange is happening, whenever I run !ping, bot works fine, I run it again, all fine. I run !eval and the bot throws a 401 error from djs, then every single action djs makes, message events etc, throws 401 error?? Makes 0 sense but something here is breaking djs
https://hasteb.in/gopudoci.coffeescript
Umm, why are you doing client.token = "HIDDEN"?
I don't see a reason to be changing the token for the bot?
You can't change client's token to that @snow urchin
It actually tries to use the one you set, which is not a valid token
That's how the lib works
oh wait ye, I had that set for a different bot that used a differnt lib where that worked lol
I feel dumb
i use this to remove all critical stuff from eval prints ```js
text.replace(//g, "" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
I'm not sure if your eval is safe from token leak
there's no point in trying to hide the token
evaling client[atob('dG9rZW4=')] will prob still leak it
this
when would i EVER need to eval that lol
why bother with trying to hide it then?
atob?
A simple way to hide the token is to Iterate through the output and replace all instances of the token
there's still a ton of ways to access it
@earnest phoenix except it's a string and strings can be transformed
ah true, you could always Buffer.from('blabla', 'base64').toString()
print the letters in each line
What?
I don't use node too much haha, just front end stuff
there's no point in trying to hide the token, just don't make a dumb bitch move to give eval access to someone you don't trust
hot take: just don't have an eval command ๐ณ
i can transform the token into inserting a space after every character, a zero, or anything really
attackers are way more creative than that though
I hide my token like this, there's literally no possible way to reveal the token
i mean just do what cry said
your regex won't catch it

Heck, you could even just message.channel.send(...) the token
Don't bother trying to hide your token
It's a waste of time.
I did that, doesn't send the token
transform the token in any reversible way and the regex won't see it
and the attacker can transform it back
Voltrex there are still a number of ways to send it. It's not worth the time to try disguising it, because your #1 protection should be good enough to limit who can use the command anyway
Whats wrong wt my code it dosnt work...
from discord.ext import commands
import dbl
class TopGG(commands.Cog):
"""
This example uses dblpy's webhook system.
In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
"""
def __init__(self, bot):
self.bot = bot
self.token = 'I think I hide this...' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
@commands.Cog.listener()
async def on_dbl_test(self, data):
"""An event that is called whenever someone tests the webhook system for your bot on top.gg."""
print("Received a test upvote:", "\n", data, sep="")
def setup(bot):
bot.add_cog(TopGG(bot))```'
If there is an actual way, show me, go, ahead
The hell does that even mean
eval convert token to hex
token.split(" ").join("0")
and boom
your regex doesn't detect it
well
you'd split by ""
and not " "
Array.from(token).reverse()
Yo guys
How i can optimize it?
//console.log('ะะฐะฟัััะธะปัั!');
bot.user.setStatus('available'); // available idle dnd invisible
bot.user.setPresence({
activity: {
name: `*help โจ `,
type: 2
}
});
});```
what is there to optimize?
How to make a command that lists all my boyโs servers?
dw Iโm privating it to myself only
I have memory leaks in my code, I think they are here
they are definitely not there
if you're using discord.js, iterate over client.guilds.cache
I decided this way, because after a long bot work, the status simply disappears
Oh you meant that way?
client.guilds.cache.forEach(g => message.channel.send(g.join(โ\nโ))
Like this?
c/supreme Rules
Yea that way is impossible to hide the token from
no, that will send 500 messages if you have 500 guilds
I got 36 for now so itโs ok for me ๐
status may disappear when your bot disconnects and reconnects
sending 36 messages at once is definitely not ok
you can only send 5 messages per 5 seconds
oh
yes, I understood it wrong
And how i can fix it?
so how to do it properly if not like that?
if you dont have a dynamic status, you can set the status in the client options, that way it will never reset because its automatically set again on every reconnect
Hmmm, how i can do animate status?
wdym animate status
Rotating status?
Yep
Yessss
Mkay
setInterval
In ms?
Just don't change it too quickly
yes
setInterval is in ms in every implementation of js i think
How i can do it in code like this:
you can use .map instead of .forEach
oh do I
make an list of possilbe statuses and the set interval. each time the nterval stops generate a random number to pick an string from the list
yes but not in the same way
which part ๐ณ
Idk how to realize it
do you know how to make an array?
Ye
ok what about setInterval
._.
setInterval(function, time)
function can be defined in place or as a reference to an existing function
time is in ms
make a list js const status_list= ["status1","status2"]
create a setIntervall and use a random number generator to get the index for the list
setInterval(()=>{
const index = Math.floor(Math.random()*(status_list.length-1)+1)
}, 50000)
this is an example
then also set the activity inside your interval
inside the set activity just pass the list with the random generated index
Tip: you don't need to -1)+1
lmao that -1 +1
Math.floor(Math.random() * array.length)
LOL
which they obviously will
lmao
yeah true
๐ฟ The bait, it always works
next time i write them in COW
examples in rust from now on
in wasm bytecode 
i write them in g-code. you then need either a software to simulate it to see the result or you have a Milling machine that could run the program
dafuq is g code
programing language for CNC controlled milling machines
also lathes
and EDM machines
lmao
ah, this reminds me of those lathe days lol
Yo how do you get your lavalink server onto your host?
i have a music bot and I have no clue how to do it.
My host doesn't give me access to a command prompt
where tf did you host that this stuff happens?
the host doesn't provide it
they don't give you full access
which host are you using
pebble
did you use a webspace?
no
did you pay for the host?
uhm yes
gtfo there
?
get the frick out there
lol did you seriously buy their bot hosting plan
you got ripped off
and
it did what I wanted
for like 5 months
do you guys know of a better host that provides everything for cheap?
they're pinned
digitalocean, vulture, OVH as example
i use heroku ๐
AWS and Google Cloud Services
you should never ever get shit like that advertising "EASY DISCORD BOT HOST!!"
because they're ripping you off
if its easy its dumb, you pay way to much for next to no functions
they're profiting off people who don't have experience with getting a cheap vps or linux
also for 5$/month you can get a Digitalocean VPS that will have probably more compute power and full access
does the galaxy gate 3 dollar a month plan give u access to the command prompt?
sweet
for $7/mon you can get a hobby heroku dyna that you'll spend more time making docker files for than actually programming your service
LOL
i use it cause it's automated
i could make my bot also automated.
Do I talk here to if something with my Discord bot is not working?
my bot is hosted on a vps with dokku so it's basically the same thing
if you need help yeah
did you get errors?
@lusty quest what host do u use for your bot?
i use digitalocean
I have the Terminal on cmd I type (node .) and it changes cmd to node then it changes it back to cmd.
?
so you ran node . and nothing happened
It changed cmd to node then changed it back.
the window title yes
did you get errors?
because it ran node
@lusty quest what plane do you specifically use?
airbus a380
currently a Debian 10 Droplet
so no errors
run node -v
what does your package.json look like
also did you initialized your node project?
Save your file
Your js file is not saved.
CTRL+S to save. If there's a white dot next to the file name in the tab at the top, it's not saved.
if it is this i guess someone is facepalming rn pretty hard
This happens multiple times a week actually, on various servers I'm in.
there's no error cause the entrypoint exists but there's no output cause there's no code
nice
hey so like how do i make my bot send a message that is o a json file
we did it
There you go. Now we're moving forward.
Which module didn't it find, if you scroll up?
did you initialize this project yourself or is it from somewhere else
uhm
Can we get, like, a bigger screenshot? make the window bigger, run it again, and look at the error
like i made a json made a require server = json file and then if i got to the msg.channel.send("${server}")
did you know how to read json files?
You probably forgot to install discord.js
yes
then you can just refer to it to send it
does it not send like that?
no
is it trying to send an embed?
ye
run npm i discord.js
run npm install discord.js
lol
You should be following a tutorial, not blindly moving forward
of npm i discord.js
Better yet, you should be learning javascript first.
^
have you checked the docs for your discord api lib to sending raw json?
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- proper syntax
- debuging code
- basic features (vars, arrays, objects, functions)
- read and understand docs
- nodejs module system
As much as we'd like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.
Here are good resources to learn both Javascript and NodeJS:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie's Accelerated JS: https://js.evie.dev/
Please take a couple of weeks/months to get acquainted with the language before trying to make bots!
or maybe someone else can chime in since on JDA it just sends it
that means it worked
It changes to node then back to cmd.
Can you please learn javascript first
And then once you're done, follow a tutorial for discord.js bots
because... we're not going to handhold you through the entire process, here.
The bot is offline still.
yeah because it's not running
yo @earnest phoenix what's the problem now?
What should I search?
you wanna apply that to your question too? lol
like i have the require then in the embed but like if i type anything in the json file in ""it only sends me a erorrr
How to make it upload random memes
go to a website
use the reddit api
what's the error
ye
as example
or that
ok, so what error, and what's in your json file?
let me see
Can you send me link
Reddit gives you the best of the internet in one place. Get a constantly updating feed of breaking news, fun stories, pics, memes, and videos just for you. Passionate about something niche? Reddit has thousands of vibrant communities with people that share your interests. Alternatively, find out whatโs trending across all of Reddit on r/popular....
thx
i'd look up a lib for your language of choice
DUDE
so there's an error in your JSON.
your json is not formatted
syntax error in your json -> unable to be used.
I do have my token their.
Please don't ignore the fact that if you do not know javascript, you will not be able to make a bot.
but if i put the colon
I just replaced it because I am smart.]
it doesnt work
?
it makes even more erors that are unfixeble
learn Javascript and how to use a discord lib please. we wont babysit you here for the entire process
???
bc it only makes more and more erorrs
Just to paste this link where it is .setImage ?
OMFG!
json is an object notation spec that should be parsed the same way by everything that claims to support it
Anyone knows how to set up a reverse proxy using cloudflare workers?
put your bot token in there
no
are you only using http traffic?
you can use xpath to get the path inside the json to get the image out of it
here. let's be very thorough in this answer.
Why shouldnโt I use a JSON file as a database?
A JSON file is not suitable for use as a database for several reasons.
Firstly, you will incur a major performance hit as you need to read from and write to the file on each query and modification. This brings a major performance impact especially when the amount of data increases.
Second, you cannot concurrently write to a JSON file - only one write can be performed at a time. This is part of what causes the performance impact, but perhaps more importantly may introduce unexpected results and even file corruption.
JSON files are also human readable and easily accessible by end users. This means that your database and application will be vulnerable to attacks, especially as database reads are rarely checked for malicious code (Which usually happens on write).
What should I use instead?
An actual database, to put it bluntly. SQL, NoSQL, whatever takes your fancy. Some SQL databases are SQLite, PostgreSQL and MariaDB, while NoSQL databases include things like MongoDB, RethinkDB, ArangoDB and many more. If you want the easy way out, check out Enmap.
What can I use a JSON file for?
JSON files are best used to store static data, in other words data that doesnโt need to change often or programmatically. In practice, this means configuration and other application data that needs to be defined by a human - which is what JSON excels at. If you want something easy, use enmap.
OMG its simple coding
Https
right
why do you need a reverse proxy?
@earnest phoenix Thank you for telling me to remove the colon.
lol that wasn't even the problem ๐
