fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.events.set(eventName, { name: eventName, run: eventFunc.run })
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});```
#development
1 messages · Page 942 of 1
And in reload.js
else if (args[0].toLowerCase() === "event") {
console.log(client.events)
if (!client.events.has(args[1])) {
return message.reply("That event does not exist");
}
const event = client.events.get(args[1])
delete require.cache[require.resolve('../../events/' + event.name + '.js')];
let pull = require('../../events/' + event.name + '.js');
client.events.delete(args[1]);
client.events.set(args[1], { name: event.name, run: pull.run });
message.reply(`The event \`${event.name}\` was reloaded`)
}```
So
Idk what I did wrong
Who is your host
Why?
that is simialr code that i use for commands
its the same principle but just for events.
Hey bro I'm new here and i want to know about bot development
its the same principle but just for events.
@neat ingot Doesn't seem to be the same principle really
except it is, thats the thing. the only difference would be that you call your command files from within the message event, and the other events .run command from their respective event handlers
Could anyone tell me which software does i use to make bot without coding and with coding please
like, i would have
bot.on('someevent', function(){
if (eventhandler.has('someevent') {
// call event handler code from custom js file
}
});
Yeah but if the event is already been called with client.on, then you can't change it no?
no you cannot
well, you probably can if you remove the existing handlers
thats why you wrap the event handler in a functiona s shown above
So it won't work with this handler
fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.events.set(eventName, { name: eventName, run: eventFunc.run })
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});```
lmao, deleting all the wrong letters there 😄
ahhh yea no, that client.on event would be set still even after the event file had been reloaded
client.on(eventName, (...args) => {
if(client.events.has(eventName)){
const event = client.events.get(eventName)
event.run(client, ...args)
}
}); ```
Like this?
yea, with eventName being a valid event name string ofc
np, lemme know if it goes well 🙂
Ok
0|index | (node:26790) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 voiceStateUpdate listeners added to [Client]. Use emitter.setMaxListeners() to increase limit```
I am not?
fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.events.set(eventName, { name: eventName, run: eventFunc.run })
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});```
you remove the on handler from there?
Why?
But I need that
like, your event handlers should be outsidew of your code to load the events
like umm
if(client.events.has(eventName)){
const event = client.events.get(eventName)
event.run(client, ...args)
}
});
// now load event files into client.events
Uhhhh now it is sending messages like a million times
your client,.events.has and get should be returning the code that is to be ran whenever that event is emitted
Ok it is because I did an ooopsy
so there is no need to define the on handler for that event within the event loading part of code
Yeah I screwed the hell up so on an event I made it like this
client.on("message", message =>{
client.on("message", message =>{
})
})
so oof
Fixed it
Nope didn't work
fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.events.set(eventName, { name: eventName, run: eventFunc.run })
client.on(eventName, (...args) => {
if (client.events.has(eventName)) {
const event = client.events.get(eventName)
event.run(client, ...args)
}
});
});
});``` would this not work?
it should if you dont need to reload the events
if you do, you would have to have the client.on predefined for each event outwith that codeblock
yea but when you reload it will give the error for too many event listeners on the same events
cause those listeners arent being removed
o0
It doesn't add another listener
[py] so when using a dict in python, I can easily do something like this
ALBUM_DICT = {
"The Piper At The Gates Of Dawn" : 0,
"A Saucerful of Secrets" : 1,
"More" : 2,
}
print(ALBUM_DICT["More"]
which will print 2, but can i somehow print "More" by typing 2?
rr.removeListener("theevent", thefunction);
seems to be valid for removing an event listener
not something ive ever tried myself within node
Would I have to do that?
or do list comprehension where you compare a value
What like this?
client.removeListener(event.name)
hm ok
also hey :> didnt see you both in a long time
Is it like what I showed above?
i mean:
keys, values = dict.items()
value = keys[values.index('something')]```
would work
i think so yea, again though, not something ive tried myself 🙂
oki ty
yea 🙂
client.on(event.name, (...args) => { event.run(client, ...args) })
``` Like this?
no no, dont give an anonomouse function
name it, cause you need the name to reference for future removal
you would need to name and hold reference to it
but tbh i still dont understand why the first way didnt work for you
why does it need to be a function
but tbh i still dont understand why the first way didnt work for you
@neat ingot same
so i have this
bot.on("message", (message) => {
if(message.channel.type === "dm") console.log(`[${message.author.username}#${message.author.discriminator}] ${message.content}`), message.author.send("Thank you for the suggestion! Troll suggestions will be ignored, and you could get blacklisted by the bot!")
});```
and whenever someone dms the bot
which shouldnt give an error because the code is fine
it says
(node:17228) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user at RequestHandler.execute (C:\Users\littl\Downloads\joop bot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:17228) 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:17228) [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.
but it still works
DMs are off for that user?
its me
i was testing it
and i have them on
@golden condor it still works like it just gives that message but nothing happens
and i wanrt it to go away-
want*
You sure someone else isn't dming your bot
whats an event i can easily test other than regular message event?
uhhh, voiceStateUpdate?
sure
dekita
do you know how to fix this
everything works it just gives an error message for no reason when the console logs the bot's messages
is there a way to only make the console log a user's messages?
the current code is
bot.on("message", (message) => {
if(message.channel.type === "dm") console.log(`[${message.author.username}#${message.author.discriminator}] ${message.content}`), message.author.send("Thank you for the suggestion! Troll suggestions will be ignored, and you could get blacklisted by the bot!")
});```
yes easily
bot.on("message", console.log)
ok ty
now its an error
why
It's cos the bot is responding to its own messages
https://cdn.discordapp.com/attachments/479198300881289229/714161822529224734/unknown.png
MessageEmbed fields may not be empty on line 17
no
Anyone know where I can find a list of ratelimits and their times?
its not
Tryna send a message to itself
wait what
Well it is
how do you make it not
Because you don't have anything stopping that
You probably want it to stop responding to bots at all
yea
if(message.author.bot) return;
^
ok
in your message event
so this
bot.on("message", (message) => {
if(message.channel.type === "dm") console.log(`[${message.author.username}#${message.author.discriminator}] ${message.content}`), message.author.send("Thank you for the suggestion! Troll suggestions will be ignored, and you could get blacklisted by the bot!")
if(message.author.bot) return;
});```
o k
@neat ingot for some reason the reloading won't work
@neat ingot do u use lavalink?
@golden condor it still logs the bots messages even if i put the if function
if so make sure to run the jar file before the bot
that returns
I guess the event reloading isn't too important but it's nice to have so I don't have to keep restarting
pls help-
Show the code
bot.on("message", (message) => {
if(message.channel.type === "dm") console.log(`[${message.author.username}#${message.author.discriminator}] ${message.content}`), message.author.send("Thank you for the suggestion! Troll suggestions will be ignored, and you could get blacklisted by the bot!")
if(message.author.bot) return;
});```
Do it before that code
ok
right under the first line
YES
IT WORKS AND NO MESSAGE
woot woot
no more lengthy error message that takes up my suggestions
i know
i wanna do both
but how
wait no
because it logs every dm so it would send non suggestions as well
meaning that
you could spam the channel
and that would get annoying
which is exactly why i put it in logs so the server doesnt get spammed just the console-
sorry for delay, had to make a command to reload shit 😛
that was my test event handler file
and as mentioned previously, i just reworded my command loading/reloading code for events
and setup a predefined event handler that checks if there is any handler loaded for that event, then calls it
Well this won't work for me
why on earth wouldnt it?
you just have to provide the client to your command handler/ command
I mean what I've done
literally just copied and changed my existing command reloading code
fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.events.set(eventName, { name: eventName, run: eventFunc.run })
client.on(eventName, (...args) => {
if (client.events.has(eventName)) {
const event = client.events.get(eventName)
event.run(client, ...args)
}
});
});
});``` Can I improve this to work?
yes, improve it by doing something similar to what i outline above 😄
im literally doing the same thing
click image and open orig 😄
eef
one thing to be aware of ~ my 'args' that my commands process is always forced to lower case
in which case i would never find a camel case event name
I am tryna do what you did but I am not sure how I can implement it into my code
I need help
lol
Is there a method for collectors to stop them without calling the end event?
@neat ingot I'm not saying that
😛
I just kinda need some help
wtf
https://tenor.com/view/acid-spoon-ihave-no-more-spoon-gif-14007313
@neat ingot what is this
it is a spoon being melted by acid?
please help
Code?
wait
your trying to call 'end' on something that is undefined.
const Discord = require('discord.js');
const { RichEmbed } = require('discord.js');
const YouTube = require('simple-youtube-api');
const ytdl = require('ytdl-core');
const moment = require('moment');
exports.run = async (client, message, args) => {
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] Geç - komutu Çalıştırıldı.`)
const queue = client.queue;
var searchString = args.slice(0).join(' ');
var url = args[0] ? args[0].replace(/<(.+)>/g, '$1') : '';
var serverQueue = queue.get(message.guild.id);
var voiceChannel = message.member.voiceChannel;
const err0 = new RichEmbed()
.setColor("RANDOM")
.setDescription(`**Bir sesli kanalda değilsin.**`)
if (!voiceChannel) return message.channel.send(err0);
const err05 = new RichEmbed()
.setColor("RANDOM")
.setDescription(`**Şuanda herhangi bir şarkı çalmıyor.**`)
if (!serverQueue) return message.channel.send(err05);
const songSkip = new RichEmbed()
.setColor("RANDOM")
.setDescription(`**Şarkı başarıyla geçildi!**`)
serverQueue.connection.dispatcher.end('');
message.channel.send(songSkip)
};
exports.conf = {
enabled: true,
aliases: ['skip', 's', 'Skip', 'Geç', 'gec', 'S', 'Geç', 'gec', 'GEC', 'Gec'],
permLevel: 0
};
exports.help = {
name: 'geç',
description: 'Sıradaki şarkıya geçer. Sırada şarkı yoksa şarkıyı kapatır.',
usage: 'geç'
};
at line 26
here
serverQueue.connection.dispatcher.end('');
that one
you're trying to get the message id again var serverQueue = queue.get(message.guild.id);
lemme check smth
okay
@toxic jolt can you try removing the '' in serverQueue.connection.dispatcher.end('')
[py] how do i replace the last ", " with ".", I tried this:
songs = songs[::-1].replace(", ", ".", 1)
return songs[::-1]
but it does not seem to work
why dont u just return songs and not songs[::-1]
lmao
how do i create a mute role via bot? discord.js btw. current code is
if (!muterole) return msg.guild.roles.create()
idk what the names of the perms are
btw nvm, found out how
Is there a way I can use apache2 and have a.xyz.com/server1 routed to port A and a.xyz.com/server2 routed to port B?
<VirtualHost *:80>
serverName ac.vinniehat.com/server1
ProxyPass / "http://127.0.0.1:8772/"
ProxyPassReverse / "http://127.0.0.1:8772/"
</VirtualHost>
<VirtualHost *:80>
serverName ac.vinniehat.com/server2
ProxyPass / "http://127.0.0.1:8773/"
ProxyPassReverse / "http://127.0.0.1"8773/"
</VirtualHost>
``` Like I have this, but it doesn't work
The only solution I have is to make it ac1.vinniehat.com and ac2.vinniehat.com rather than ac.vinniehat.com/server1 or /server2
ProxyPass /server2/ "http://127.0.0.1:8773"
same with reverse
serverName stays as domain only
my invite manager is offline and the commands don't work
Gotcha. So @quartz kindle do I just make one big VirtualHost?
not sure if you can make it in one vitualhost
actually not even sure if it will work
i dont use apache
Gotcha. I'll try it
@dense jetty this is not the support server for invite manager
lol, so many people come here for support on other bots 😄
no speak englesh
Lol
im portuguese
gj!
Unfortunately it didn't work tim
voce está no servidor errado
ahahah
este servidor não é do invite manager
@quartz kindle br?
ofc tim knows portuguese too 😄
-wrongserver
e ele ta off no meu dc
n tem chat livre la
-wrongserver @dense jetty
@dense jetty
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(
tim knows every language, from C++ to zulu warrior tribe speak 😄
not our problem
best hop over to the right server asap then bruh 😗
melhor pular para o servidor certo o mais rápido possível, então bruh
no idea how good google translate is, but w.e 😄
Is there anyway to have a bot unban everyone from a server?
My server was raided and 13k people were banned.
@dense jetty didnt i sent an invite into support for the actual InviteManager support?
@nocturne dagger Yes, I've seen bots being denied for having a unban command that unbans too quickly, Just have maybe a 15 second cooldown of unbanning each member (or whatever the number is to make it not api abuse)
why would you want to bulk unban people tho?
oh lol
I don't want to submit it its just going to be used for my server.
can someone help me with adding roles code
sure, what isn't working?
what library are you using?
can you show how far you've gotten?
@abstract crow
<VirtualHost *:80>
serverName ac.vinniehat.com
<Location "/server1">
ProxyPass "http://127.0.0.1:8772/"
ProxyPassReverse "http://127.0.0.1:8772/"
</Location>
<Location "/server2">
ProxyPass "http://127.0.0.1:8773/"
ProxyPassReverse "http://127.0.0.18773/"
</Location>
</VirtualHost>
use location tags whilst keeping the virt host but then defining locations based on proxypass
Awesome! Thank you so much. I'll try that rn
no problem
The other thing is that everything redirects to ac.vinniehat.com/races, etc. Not the /server1/races. Do you know how to fix that?
change the hyperlinks in your server
because you you're redirecting to /
/ is the roof of the domain
like in linux how / is the root of the server
idk if ./ works in express/node for web services
but the way I do it is just redirecting to the absolute web path
So I'd have to go into the code of each redirect and fix that right?
This is a plugin so I'm trying to look into it
Oof ok. The file has no extension so I have no clue what to do with it
No
I got 2 files with the manager. A config file, and the file to run for the server manager
you can do
<VirtualHost *:80>
serverName ac.vinniehat.com
Redirect /races "https://ac.vinniehat.com/server1/races"
<Location "/server1">
ProxyPass "http://127.0.0.1:8772/"
ProxyPassReverse "http://127.0.0.1:8772/"
</Location>
<Location "/server2">
ProxyPass "http://127.0.0.1:8773/"
ProxyPassReverse "http://127.0.0.18773/"
</Location>
</VirtualHost>
hacky but works
const Discord = require("discord.js");
const db = require("quick.db");
const colours = require("../../colours.json")
module.exports = async (client, message, oldMessage) => {
const logs = db.fetch(`logs_${message.guild.id}`);
let logChannel = client.channels.cache.get(logs);
if (!logs) return;
if (!logChannel) return;
const editedLogEmbed = new Discord.MessageEmbed()
.setColor(colours.purple_light)
.setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL())
.setDescription(`**Edited Message** in ${message.channel}`)
.addField(`Old Message:`, `${message.content}`)
.addField(`New Message:`, `${oldMessage}`)
.addField(`Edited By:`, `${message.author.tag}`)
.addField(`Message Link:`, `[Jump to Message](https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id})`)
.setTimestamp();
if (logChannel) logChannel.send(editedLogEmbed);
}```
also i know that Old Message and New Message are swapped but it works for me, the main issue is the MessageEmbed field values may not be empty, everything still sends but the error still shows. ```(node:68364) UnhandledPromiseRejectionWarning: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.```
mk
same error @delicate zephyr
nothing helped from here because my name and values aren't empty
clientStatus is an object.
Check out what you need in the docs: https://discord.js.org/#/docs/main/stable/class/Presence?scrollTo=clientStatus
alr
How can I get the Activity from a User? When you want to answer me, please ping me 😄
?
Tank you
@earnest phoenix u do know its easier to use the message edited event instead of the module.exports
I thinked about this too
@earnest phoenix u do know its easier to use the message edited event instead of the module.exports
@zenith terrace im using an event handler
also that still won't fix my issue
its probably embeds
embeds are sent as message edits
@earnest phoenix
so the oldMessage will be empty
it does send the embed with the old message and new message
it just says that it's empty for some reason although the message shows that it's not
tbh idk
as seen here
idk
does anybody know of a bot/how to make a bot that basically lets people dm it and then the message gets relayed into another channel, and mods can send messages to respond to people through the bot?
well just get the message and send it to a channel
i think there is some helpful stuff in the documentation too when it comes to dms
same thing, fetch the message sent by the mods and send it via dm
so for creating a storable token i was thinking of doing something like this.
createToken () {
return Crypto.createHash('sha256')
.update(Crypto.randomBytes(8).toString('hex'))
.update(`${Date.now()}`)
.update(`${this.config.oauth.mysecret}`)
.digest('hex')
}```
but like idk if i there's any other things i should add or if things like date.now are even necesarry etc
isnt that kinda unnecessary?
mine is just crypto.createHash('sha3-224').update(Date.now().toString(36)+Math.random().toString(36)).digest("hex");
but well, im not that into crypto to know whats better
seems like pretty much the same thing
except i add a mysecret which im sure would be more secure
and crypto.randomBytes
which is just a securer way of doing the random part lol
probably
<Array.<Object>>.map(x => {
return { n: x.name, i: x.id, a: x.icon }
})```
i feel like there out to be a better way of doing this right?
I mean, n, i and a are quite vague key names.
for the sake of as little memory used as possible
its just for cached things
but i want to make it able to map into those but theres gotta be a better way of goin abt it right?
I don't know how you could make it better (unless someone points some way) as you're still going to iterate the array of objects at the end of the day.
i mean just for the sake of good looking code
probably a one line way of doing it without the absurd returning and stuff
@slim heart you can do x => ({n: x.name, ...})
try catch the fetch method from UserManager
oo alr thats a bit better
hmm maybe
ye
hi so
i'm really confusrd
i have ```js
const array = ['test', 'array'];
array.find((e) => 'test' === e)
but i have something like
const array = ['a very conmplicated array', 'which is', 'confusing'];
array.find((e) => 'a very compli' === e)
``` ik i can do .includes but i need to find a specific array, but i can't check for the exact match as i only know part of it
wait so if i fetch it how do i make my bot know the correct user to dm a reply to
Is there a discord.py command to see how many servers your bot is in? Like !servers and it tells you the number?
Don't spoonfeed
oh okay, well i found out how to do in by googling, so @static trench just look it up, not that hard to find
Ok
@glacial thicket what is the command? I have
from discord.ext import commands
client = commands.Bot(command_prefix='^')
@client.command(pass_context=True)
async def botservers(ctx):
await client.say("I'm in " + str(len(client.servers)) + " servers")
client.run("token")
Is that right?
It looks right
yeah thats right!
Ok
Ty
@glacial thicket i replaced:
from discord.ext import commands
client = commands.Bot(command_prefix='^')
@client.command(pass_context=True)
async def botservers(ctx):
await client.say("I'm in " + str(len(client.servers)) + " servers")
client.run("token")
With @bot.command
Asyncio def count(Ctx):
I’m pretty sure it works
I have this error
TypeError: Cannot read property 'send' of undefined
var logs = new db.crearDB("logs-mensajes");
const canal = client.channels.get(logs);
canal.send(embed)```
In set-logs cmd, i have this:
logs.establecer(message.guild.id, canal.id)```
Whats the discord re-write for server count?
I have @bot.command()
async def ping(ctx):
await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))
Oops
Wrong command
That’s ping
const { MessageEmbed } = require("discord.js")
module.exports = {
name: 'kick',
description: 'kick a specific user',
execute(client,message, args) {
const user = message.mentions.members.first();
const reason = args.slice(1).join(" ")
if (!user) message.reply("Who you kicking bruh")
if (!reason) message.reply("I need a reason")
if (user && reason) {
let embed = new MessageEmbed()
.setColor("RANDOM")
.setTitle(`Kicked ${user}`)
.addField("User Kicked", `${user.username}`)
.addField("Reason", `${reason}`)
.setThumbnail(user.avatarURL())
message.channel.send(embed)
user.kick(reason)
}
},
};```
nothing gets sent and the person being mentioned isnt being kicked
Ok???
@hardy vector u getting any errors?
TypeError: user.avatarURL is not a function
@hardy vector u got an answer
TypeError: user.displayAvatarURL is not a function
const { MessageEmbed } = require("discord.js")
module.exports = {
name: 'kick',
description: 'kick a specific user',
execute(client,message, args) {
const user = message.mentions.members.first();
const reason = args.slice(1).join(" ")
if (!user) message.reply("Who you kicking bruh")
if (!reason) message.reply("I need a reason")
if (user && reason) {
let embed = new MessageEmbed()
.setColor("RANDOM")
.setTitle(`Kicked ${user}`)
.addField("User Kicked", `${user.username}`)
.addField("Reason", `${reason}`)
.setThumbnail(user.displayAvatarURL())
message.channel.send(embed)
user.kick(reason)
}
},
};```
How do I make reaction buttons using Eris?
@hardy vector displayAvatarURL is only available on the User class. You're calling it on a GuildMember instance.
get the user object from the member
that would be user.user because the first user is actually a member
you named it wrong
can i fade something
I want to make the recording myself and I couldn't find the code in it.
(Example; registration Atakan | 17)
please help me
How i delete all messages of my bot?
That's not possible
In any way
Unless all the messages were sent under 2 weeks ago
Mmm
Even then you would have to go through every single channel and fetch tons and tons of messages and delete tjem
please give more details
i got a digital ocean droplet and i did ssh root@ip and now im inside of the vps i think
what do i do now
please help
read guides on how to install nodejs and stuff, if that's what you want to do
module.export= {
name: "help",
category: "info",
usage: "help",
description: "List All Commands",
run: (client, message, args) => {
var channel = message.channel;
let embed = new discord.MessageEmbed()
.setTitle(`*Here are my commands!*`)
.setColor("#03002b")
.setTitle("HELP")
.setDescription("**Default Prefix**:-`d!`\n\n**Info Commands**\n「`level`」,「`ping`」,「`weather`」\n**Moderation Commands**\n「`kick`」,「`ban`」,「`prefix`」,「`setwelcome`」,「mute」,「unmute」")
.setFooter(`Requested by: ${message.author.tag} | Created by DEMON`);
let embed1 = new discord.MessageEmbed()
.setTitle("**ADDITIONAL INFO**")
.setColor("RANDOM")
.setDescription("**If you have any problem in using these commands use\n`d!help <command>` For More Info of that command**")
.setFooter(`Requested by: ${message.author.tag} | Created by DEMON`);
message.channel.send(embed)
.then(msg => {
channel.send(embed1)
})
return;
}
}
i am getting error
help.js | :x: -> missing a help.name, or help.name is not a string.
you can add js module.exports.help = { name: "foo" } and move the help information there
sorry i forgot to do exports 😂 but now again
look in your file, it's missing an s
i added it now but same error
module.exports.help = {
name: "help",
category: "info",
usage: "help",
description: "List All Commands",
run: (client, message, args) => {
var channel = message.channel;
let embed = new discord.MessageEmbed()
.setTitle(`*Here are my commands!*`)
.setColor("#03002b")
.setTitle("HELP")
.setDescription("**Default Prefix**:-`d!`\n\n**Info Commands**\n「`level`」,「`ping`」,「`weather`」\n**Moderation Commands**\n「`kick`」,「`ban`」,「`prefix`」,「`setwelcome`」,「mute」,「unmute」")
.setFooter(`Requested by: ${message.author.tag} | Created by DEMON`);
let embed1 = new discord.MessageEmbed()
.setTitle("**ADDITIONAL INFO**")
.setColor("RANDOM")
.setDescription("**If you have any problem in using these commands use\n`d!help <command>` For More Info of that command**")
.setFooter(`Requested by: ${message.author.tag} | Created by DEMON`);
message.channel.send(embed)
.then(msg => {
channel.send(embed1)
})
return;
}
}
embed?
oh i corrected it
This should work just fine, I think the only problem was that module.export should have been module.exports. Though I could be wrong.
const discord = require('discord.js')
module.exports = {
name: "help",
category: "info",
usage: "help",
description: "List All Commands",
run: (client, message, args) => {
var channel = message.channel;
let embed = new discord.MessageEmbed()
.setTitle(`*Here are my commands!*`)
.setColor("#03002b")
.setTitle("HELP")
.setDescription("**Default Prefix**:-`d!`\n\n**Info Commands**\n「`level`」,「`ping`」,「`weather`」\n**Moderation Commands**\n「`kick`」,「`ban`」,「`prefix`」,「`setwelcome`」,「mute」,「unmute」")
.setFooter(`Requested by: ${message.author.tag} | Created by DEMON`);
let embed1 = new discord.MessageEmbed()
.setTitle("**ADDITIONAL INFO**")
.setColor("RANDOM")
.setDescription("**If you have any problem in using these commands use\n`d!help <command>` For More Info of that command**")
.setFooter(`Requested by: ${message.author.tag} | Created by DEMON`);
message.channel.send(embed)
.then(msg => {
channel.send(embed1)
})
return;
}
}
module.export should be module.exports, yes.
though I do question, why do you save channel to a variable if you're using the same thing above (message.channel.send == channel.send)?
Yeah that's true, message.channel doesn't need to be assigned to a variable.
you also should have a dynamic help command, it helps
Also, .then(msg => { channel.send(embed1)}) doesn't need to be there while you can just add another line message.channel.send(embed1);.
i uploaded my files to the vps through filezilla but when i run node . this happens
internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module '/root'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
If I were to use Config Vars, could it be const Prefijo = require(process.env.Prefijo); or const Prefijo = process.env.Prefijo;?
I don't use JS, but probably the second
Hmm, ok.
Isn't require for importing external scripts
the second yeah
@hardy vector check the directory where the node command was run.
oh im dum im tired sorry lol
i pushed all my files to a vps and when i start it i get this error
Error: SQLITE_CORRUPT: database disk image is malformed
i tried deleting it
but it still said that
const SA = require ('fs');
const Discord = require('discord.js');
const Cliente = new Discord.Client();
const Prefijo = process.env.Prefijo;
Cliente.commands = new.Discord.Collection();
I'm getting an unknown identifier error at Cliente.commands.
new.Discord.Collection is not a thing.
lmfao
I'm such a bad coder dude
I'm getting a SyntaxError on line 47 but my code only has 45 lines
ok
you are prob not saving the file when editing, or you are launching the wrong file
yesh
a snowflake is a unique id
^
hello! i’m currently using quick.db, but i’m looking for a better and more complete solution. do you have any suggestion?
maybe mongodb or sql
e.e
the bot are in beta version
now u know
yes
can changing an embed on reaction (pagination) cause API ratelimiting? would putting a cooldown on it fix it and if so how long should the cooldown be?
editing messages cooldown is very short, so I guess it cant be considered as api abuse
I mean quite a few bots use embed reacts
Editing messages are the same as sending
Bots can get ratelimited if you dont have some sort of safeguard to stop someone just mashing and emoji and flying through pages
I just make them remove the emoji and re apply it for a skip page and seems to cut time down alot
client.voiceConnections does not exist
I mean, if you play music & use a queue to store songs, you can look at queue size
you can also look, for each guild, if your bot is connected to a vc
message.guild.me.voice.channel
-null if not connected
-object if connected
can u give me example for snowflake
545490362568015873
714393258616422453
@earnest phoenix https://discord.com/developers/docs/reference#snowflakes
Discord Developer Portal
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
yes i am reading it
?
is there a macro for nsfw channels in serenity
or do i have to get is_nsfw on the channel
pretty sure you just check is_nsfw
youd probably have better luck asking in the serenity discord server tho
not that i know of
dont ask to ask
Don't ask to ask a question
how can a person change my bot's name?
is that possible
it just happened
and i have 2fa
Bot awaiting approval - Please be patient, us humans take time to verify bots!
who can verify my bot
"Please be patient"
yes I know but I just wanted how long that will take @earnest phoenix
1 week or more
o thnx
How do you make a message like this?
I know I can use ``` but what do I put next to that?
it just happened
@earnest phoenix then immediately change your token
in the dev portal
oh wait was it the real name or just the nickname on a server?
real name
How do you make a message like this?
I know I can use ``` but what do I put next to that?
I mean, which languages do I have to use, tried markdown but doesn't work, is it like html or smt?
real name
@earnest phoenix ok do what I said immediately
I mean, which languages do I have to use, tried markdown but doesn't work, is it like html or smt?
@opaque seal idk what Groovy (guess that's Groovy tho) uses for its markdown there, but you can always log that message.content and find it out
uhh, im having an absolute blank moment.
anyone know how to invert this math formula?
function xyToIndex(x, y) {
return 32 + (x+1) + (13 * (y-1));
}```
Im trying to make a function `indexToXY(index)` but my brain is just pooping out lol
@opaque seal there are many valid markdown syntax highlighting that discord allows. for example:
ruby: 1
"js": 2
Ml: 3
see: https://highlightjs.org/static/demo/ for more info
yea idk if it can be reversed either lol
everything i try is just wildly off lol
lmao
nah im not gonna join a server to ask a question then leave :D
thats savage af 😄
idk if ill be able to make my minesweeper minigame without sorting the formula though 💔
lol
need it to calculate the adjacent squares :/
hi
im trying to write json but i get this problem
why cant i access guild id in configWrite ?
Your JSON syntax is broken
^
oh it works now, tnx
np
i'd recommend reading into javascript objects and how to manipulate/control them 😗
side note: I just nullified having to make a valid math formula <3
I just did a simple for loop and pre-calculated all of the available index's xy positions from the xyToIndex() function and stored the data in an array referenced by index 🙂
not performant at all, but w.e idc lol
i mean, its maxxing out at 9 each way, so its not that bad. but certainly not ideal 😛
minesweeper here i come 😄
your saving to a file yea? using json stringify?
why null, 2 in your filesync? thats not valid according to the doc
your third arg should be an object, no 4th arg
i was reading this tutorial
Stack Abuse
One of the best ways to exchange information between applications written in
different languages is to use the JSON [https://en.wikipedia.org/wiki/JSON]
(JavaScript Object Notation) format. Thanks to its uniformity and simplicity,
JSON has almost completely replaced XML as th...
likely not the issue, just thought i'd mention
lol, the null, 2 is for json stringify options 😛
lemme explain
i want to add new values into json
{
guildid: {
somevalue: "asdasd"
}
otherguildid: {
value: "asdasdasd"
}
}
yea i got that already 😄
One message removed from a suspended account.
that is a slice of code from a data storage module i wrote that i use in my bot.. However, i do not use this to save any critical data or settings.
its highly recommended to not use json for storing large amounts of data
unless you know how to optimize things fully
as if there is an issue when saving, the file is corrupted and rekt
i need to save 2 variables
and if that file has all your guilds settings, you just fucked over all those guilds.
however, assuming you are doing as i have above, the file should save fine.
i'd reommend fixing the writeFileSync and JSON.stringify functions to use their correct arguments and see how it goes from there 🙂
ill try this above, sec
(dont copy my code word for word, it wont work if you do)
One message removed from a suspended account.
One message removed from a suspended account.
any guild or player config is handled by an actual databasing system: mongodb.
what your bots do jimboo?
One message removed from a suspended account.
One message removed from a suspended account.
there are so many really good ones already
hard to make one thats able to compete enough imo
One message removed from a suspended account.
One message removed from a suspended account.
im in the process of rewriting my first bot to use node 12 and d.js v12 (from node 10 and d.js11)
and i got bored last week and made another bot
One message removed from a suspended account.
well, i made a few commands, then decided it'd be best in its own bot
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
idk why, the syntax isnt even that bad, but it's always really annoyed me lol
what are you using atm?
like, in current botz
One message removed from a suspended account.
yea which language
One message removed from a suspended account.
One message removed from a suspended account.
why u wanna switch?
One message removed from a suspended account.
One message removed from a suspended account.
like, if i was gonna change
@earnest phoenix thats just your code being shit lmao
lullllz ~ shots fired
not even shots, its just the truth
tbh tho, why are you able to even try execute a command that doesnt exist?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
@opaque seal there are many valid markdown syntax highlighting that discord allows. for example:
ruby: 1"js": 2Ml: 3see: https://highlightjs.org/static/demo/ for more info
@neat ingot thx
np 🙂
const dbl = new DBL(api_token, { webhookPort: 5000, webhookAuth: 'password' });
what i have put at the webhookPort when i use heroku ??
oops wrong channel
i think heroku gives you a specific port in the ENV
idk if it allows you to have access to other ports
yes it's that
Hi
Heyy
@bronze fossil can you help me huh
Sure
2020-05-25T11:26:18.284078+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
??
problem at process.env.PORT
do you have a web dyno enabled?
i highly doubt you have the url webhook.herokuapp.com
you should be going to myappname.herokuapp.com/webhookpath
but that dashboards quite different from the last i used heroku, and ive never setup a webhook with them, only hosted regular node js sites
oh
like, i would just setup a regular node js app with them, and then contact my app via the given url /mychosenpath
but it seems like they have added some kinda support for webhooks specifically
so idk 😄
but no
thats to wetup a webhook so that you will be notified when your heroku app changes
not a webhook your app listens for
setup*
If you want a proper machine, you do
bro vps cost money
:((
wait
does dyno work 24/7
or it will shutdown until there is request
i think herokus free web dyno do yeah
if its a hobby? dyno it will
or you can pay to have it running 24/7
tbh tho i'd just get a vps from contabo. its cheaper, by a long way.
You can bypass it by making your app request itself in a given interval
oh
but be carefull with this hacky way, add a random offset to the interval (so make it a setTimeout) because Heroku now checks for this hack
lmao
lmao
😉
you can have an affordable VPS for 5 / 8€
contabo has cheap plans
@earnest phoenix In which country do you want the server to be ?
germany
i want when i ping my bot
to respond
ex @echo holly help
and respond
etc
i put the prefix
"<@idbot>"
and how to make the system
to recognize as ping
as prefix
discord.js
Hm... then you can go with contabo yes
ok
i need more mines 😄
that was turn 1
lol
@earnest phoenix ~ discord
@earnest phoenix i currently host my live bot on digital ocean. but i got a new vps from contabo and am moving there.
How much
i'd recommend ny for less discord js latency
5 euro per month luuulz
for 4 core 8gb ram 200mb per sec up/down
excellent value, you wont find better.
but their website is trash af, you have to be comfortable with command line and setting things up from there
How much disc space
200gb ssd
Powerful VPS hosting – SSD storage, snapshots, virtual machines equipped with brand new hardware, 100 mbit/s unlimited traffic, starting at just 3,99 EUR/month.
i intend on upgrading my service with them to 6 core 8gb and 400gb ssd
they do have hdd options, but who wants to use an hdd now-a-days?
all of their ssd options have a max 200mb per sec upload, but some have higher download speeds available
and it costs an extra euro per month to host in usa
Thanks for sharing
thats a graph of the cpu usage, its normally like that, it spikes when i load netdata to view the info, but otherwise its normally aorund 3%
Is it possible to define new methods for existing Discord classes?
Like say I wanted to make a method to return the channel name but with a "#" in front of it
Called channel.fullname()
Would that work?
And how would I define it?
In discord.js
any clue on how i can change the bot status to mobile?
hey, i have a problem. I copy my Token from the developer portal, but i get:
UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
Please help me
@sullen salmon you can use the Structures class https://discord.js.org/#/docs/main/stable/class/Structures
is there any api i can call to translate stuff
hey, i have a problem. I copy my Token from the developer portal, but i get:
UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
Please help me
@radiant estuary
are you sure you got the right token
yes
is there any api i can call to translate stuff
@earnest phoenix
google translate's api
flamex are you sure it's the token and not the client secret
google apis are annoying af imo
i was using their map api to make a game like pokemon go. yes they are.
they charge an insane amount when you go over the allocated limits
i used google's speech to text api last year for my cs finals lol
also google translate costs money
ie - 1k map reloads = $20
Yes. When i paste it directly in my code, it works. But i want to save them in a json file. I always do that
Thanks @cinder patio
then you're reading the json file wrong or you didn't save it
for a small project it'd be ok, but foir something that has to make multiple api calls each minute to be functional, it gets expensive real quick
yes. I saved that.
For reading I use: const config = fs.readFileSync('config.json', 'utf-8');
And to read I use: client.login(config.token);
This is my JSON file:
{
"token": "TOKEN"
}
but in my real file, is the real token
okay. Thank you. I am asking, because that always worked
either require it like dekita said or JSON.parse it
oh, yeah. thank you
channel.guild.members.fetch(logs.entries.first().executor.id).roles.remove([channel.guild.members.fetch(logs.entries.first().executor.id).roles])
TypeError: Cannot read property 'remove' of undefined
fetch is a promise
with guilds, channels, member and users too
again, fetch is a promise
they're also lacking .cache, but fetch being a promise is their primary issue
TypeError [INVALID_TYPE]: Supplied roles is not an Array or Collection of Roles or Snowflakes.
Supplied roles is not an Array or Collection of Roles or Snowflakes.
Can someone help:
if (!message.client.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"]))
^
TypeError: message.client.hasPermission is not a function
at Client.<anonymous> (C:\Users\Jon\Desktop\SpiderBot Project\index.js:95:27)
at Client.emit (events.js:224:7)
at MessageCreateAction.handle (C:\Users\Jon\Desktop\SpiderBot Project\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Jon\Desktop\SpiderBot Project\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Jon\Desktop\Spider
how do i check if my bot has permission
How do I make a simple ping command on my bot?
If you do a quick search on youtube or something along the lines you can get a lot; ||https://www.youtube.com/watch?v=Y7FhVze3krc|| might be helpful as it was just uploaded and is up-to-date then.
Also if you're asking that I would make sure to read the discord.js docs and node.js docs to understand the basics
An 18m video of them telling you what they are doing
and how it works
is better than 2m video of just code
yea i checked, thats still insanely long.
like, if the dude actually spoke
the video woulda been liek 5 minutes long
isntead of watching him type out what hes doing lol
an 18m video with 2 minutes of coding and 17 minutes of commentating
how to make a ping command: send a message, wait for the emssage to send, get the timestamp of that message, edit the message to show how long it took. done
just fyi ~ that took less than a minute to write.
I dont even do that
takes a date.now()
send message
edit it with date.now()-previous date.now()
thats basically the same thing lol
just different means of date calculations
im taking the date discord timestamped the message that i sent versus the date that the person requesting the ping's message was timestamped
In the role information command, the role is displayed separately. What is the code?
good translate
lmao
not bot related but, is there any way to get current discord username in c# ?
ive seen some app do that but cant find a way to do it
Is it difficult to implement a database into code?
maybe at first but it's easy to get used to it
const { MessageEmbed } = require("discord.js")
module.exports = {
name: 'kick',
description: 'kick a specific user',
execute(client,message, args) {
const user = message.mentions.members.first();
const reason = args.slice(1).join(" ")
if (!user) message.reply("Who you kicking bruh")
if (!reason) message.reply("I need a reason")
if (user && reason) {
let embed = new MessageEmbed()
.setColor("RANDOM")
.setTitle(`Kicked ${user}`)
.addField("User Kicked", `${user.username}`)
.addField("Reason", `${reason}`)
message.channel.send(embed)
user.kick(reason)
}
},
};``` this happens it kicks the user but does this
members don't have a username property
.displayName or .user.username
how can i make it show the person being kicked discriminator?
that's an embed
i see that there's an "api key" for my bot for the api, the really really long one. but isn't there another key for the webhook authorization?
which is a much shorter chunk of text
that's an embed
@warm cloud how do I make that blue url?
that's just a link
So the title is different
and yo can you not ping
@uncut river Authorization field on your bot's Edit page?
You create it yourself
Thanks
thank you
hi. i finally begin to switch from quickdb to mongodb. But I just saw that to connect to mongodb in a nodejs program, I have to connect the db with mongoClient.connect() and disconnect it with mongoClient.close() but is it more efficient to open the db each time I need it, or open it in the beginning of the code and close it in the end?
you probably wanna keep it open while the bot is running
im not sure how discord api lbs in js work
but in python we like to set the db connection object as an attribute of the client object
not sure how much of that is transferrable to js
as an attribute of the command object? you mean smth like <client>.db ? i don't think that it's possible in js x)
client object sir
I didn't fully understood what you meant
don't answer; i'll learn python it'll be better x)
so im trying to convert a string of text into :regional_indicator_letterid:
and whenever i convert the string directly, the emojis mess up, but if i map to ${emoji} (the emoji with a space after) it works fine
^ without spaces
^ with
anyone any idea why the hell that happens?
hey
can someone help
@bot.command()
async def giveaway(ctx, waitTime, *arg):
reactEmoji = '🎉'
embed = discord.Embed(colour=0xff0000,description=f'**React with {reactEmoji} to participate in this giveaway!**\nTime remaining: **{waitTime} minutes!** 🕰')
embed.set_footer(text='1 winner')
messageObject = await ctx.send(embed=embed)
await messageObject.add_reaction(reactEmoji)
waitTime = int(waitTime) #*60 # amount of seconds to wait
reactorsList = []
print('waiting')
await asyncio.sleep(waitTime)
print('I have waited!')
messageObject = await messageObject.channel.fetch_message(messageObject.id)
allReactions = messageObject.reactions
print(allReactions)
for reaction in allReactions:
print('checking reaction')
print(str(reaction.emoji))
if str(reaction.emoji) == reactEmoji:
print('found reaction!')
print(reaction)
users = await reaction.users().flatten()
print(reactorsList)
winner = random.choice(reactorsList)
await ctx.send(f'The winner of the giveaway for {arg} is <@!{winner}>')
this isnt working 
One message removed from a suspended account.
let me get that for u
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\xdswe\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\xdswe\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\xdswe\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: IndexError: Cannot choose from an empty sequence
One message removed from a suspended account.
One message removed from a suspended account.
😭
One message removed from a suspended account.
ok.
One message removed from a suspended account.
there are many many many changes from v11 -> v12
One message removed from a suspended account.
no?
well, no. you need to understand the changes that were made, and then change those relvant things
just 3 things
for example, client.guilds now has a cache, so you use client.guilds.cache.size instead of without the cache
^
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
technically they already have a cache 'in them' now, your just not referencing it, and instead are trying to get the size property, which no longer exists, and thus, you are getting an undefined error when trying to get the localestring for the value held in the size property.
One message removed from a suspended account.
One message removed from a suspended account.
yea you will likely have more than one thing that needds changed
it took me weeks to update from 11->12
One message removed from a suspended account.
lots of things changed, not just caches. i'd read over all of the documentation in the link i gave before. there are a LOT of changes.
@limber flume You dont assign reactorslist anywhere other than []
which choice cant pick from
@neat ingot reading back up, have you fixed your issue?
the emoji space issue thing? nah, im just gonna have a space in between them fk it
lol
@limber flume You dont assign reactorslist anywhere other than
[]
@modest maple how do you mean
okay so basically it's because flag emojis are actually just two regional indicators representing the country code
if you still want no spaces you can use a zero width space
it'll act like a space but it has 0 width so it won't display itself
ooooooohhhhh
good call
that makes sence also lol
tyvm ❤️
\u200b is a zero width space?
yup
