#development

1 messages · Page 942 of 1

golden condor
#
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));
  });
});```
#

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

opaque seal
#

Who is your host
Why?

neat ingot
#

that is simialr code that i use for commands

#

its the same principle but just for events.

golden condor
#

I am talking events

#

I use the same code for commands and events practically

dusk hawk
#

Hey bro I'm new here and i want to know about bot development

golden condor
#

its the same principle but just for events.
@neat ingot Doesn't seem to be the same principle really

neat ingot
#

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

dusk hawk
#

Could anyone tell me which software does i use to make bot without coding and with coding please

neat ingot
#

like, i would have

bot.on('someevent', function(){
  if (eventhandler.has('someevent') {
    // call event handler code from custom js file
  }
});
golden condor
#

Yeah but if the event is already been called with client.on, then you can't change it no?

neat ingot
#

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

golden condor
#

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));
  });
});```
neat ingot
#

lmao, deleting all the wrong letters there 😄

golden condor
#

lol

#

Ok I get it

neat ingot
#

ahhh yea no, that client.on event would be set still even after the event file had been reloaded

golden condor
#
client.on(eventName, (...args) => {
  if(client.events.has(eventName)){
    const event = client.events.get(eventName)
    event.run(client, ...args)
  }
}); ```
#

Like this?

neat ingot
#

yea, with eventName being a valid event name string ofc

golden condor
#

Yeah it is

#

Great I'll test that

neat ingot
#

np, lemme know if it goes well 🙂

golden condor
#

Ok

#
0|index  | (node:26790) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 voiceStateUpdate listeners added to [Client]. Use emitter.setMaxListeners() to increase limit```
neat ingot
#

loooool

#

dont keep adding 'on' the same event

golden condor
#

I am not?

neat ingot
#
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?

golden condor
#

Why?

golden condor
#

But I need that

neat ingot
#

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
golden condor
#

Uhhhh now it is sending messages like a million times

neat ingot
#

your client,.events.has and get should be returning the code that is to be ran whenever that event is emitted

golden condor
#

Ok it is because I did an ooopsy

neat ingot
#

so there is no need to define the on handler for that event within the event loading part of code

golden condor
#

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

golden condor
#

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?
neat ingot
#

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

golden condor
#

I need to

#

And wdym by that

#

The events work

#

Fine

#

But reloading doesn't

neat ingot
#

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

golden condor
#

No

#

It doesn't

neat ingot
#

o0

golden condor
#

It doesn't add another listener

narrow kettle
#

[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?

neat ingot
#

rr.removeListener("theevent", thefunction);

#

seems to be valid for removing an event listener

#

not something ive ever tried myself within node

golden condor
#

Would I have to do that?

modest maple
#

@narrow kettle you'll have to invert the dict

#

no there is no easy way rlly

slender thistle
#

or do list comprehension where you compare a value

golden condor
#

What like this?

      client.removeListener(event.name)
narrow kettle
#

hm ok

neat ingot
#

and the function

#

it needs to know which function to remove from the event handlers

narrow kettle
#

also hey :> didnt see you both in a long time

golden condor
#

Is it like what I showed above?

modest maple
#

i mean:


keys, values = dict.items()
value = keys[values.index('something')]```
#

would work

neat ingot
#

i think so yea, again though, not something ive tried myself 🙂

narrow kettle
#

oki ty

golden condor
#

Ok

neat ingot
#

yea 🙂

golden condor
#
      client.on(event.name, (...args) => { event.run(client, ...args) })
``` Like this?
neat ingot
#

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

golden condor
#

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

naive mantle
#

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

golden condor
#

DMs are off for that user?

naive mantle
#

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*

golden condor
#

You sure someone else isn't dming your bot

naive mantle
#

lmao yes it would log it

#

it only says that when the bot dms the user

neat ingot
#

whats an event i can easily test other than regular message event?

golden condor
#

uhhh, voiceStateUpdate?

neat ingot
#

sure

naive mantle
#

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!")
        });```
golden condor
#

yes easily

naive mantle
#

how

#

pls tell

golden condor
#

bot.on("message", console.log)

naive mantle
#

ok ty

golden condor
#

Wait

#

wait

#

I know why

naive mantle
#

now its an error

golden condor
#

Wait wait wait

#

I know wh

naive mantle
#

why

golden condor
#

It's cos the bot is responding to its own messages

earnest phoenix
naive mantle
#

no

cerulean zinc
#

Anyone know where I can find a list of ratelimits and their times?

naive mantle
#

its not

golden condor
#

Tryna send a message to itself

naive mantle
#

wait what

golden condor
#

Well it is

naive mantle
#

how do you make it not

golden condor
#

Because you don't have anything stopping that

naive mantle
#

how.

#

pls

golden condor
#

You probably want it to stop responding to bots at all

naive mantle
#

yea

golden condor
#

if(message.author.bot) return;

earnest phoenix
#

^

naive mantle
#

ok

earnest phoenix
#

in your message event

neat ingot
naive mantle
#

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;
        });```
earnest phoenix
naive mantle
#

o k

golden condor
#

@neat ingot for some reason the reloading won't work

naive mantle
#

it still logs the bot.

#

even with return

earnest phoenix
#

@neat ingot do u use lavalink?

naive mantle
#

@golden condor it still logs the bots messages even if i put the if function

earnest phoenix
#

if so make sure to run the jar file before the bot

naive mantle
#

that returns

golden condor
#

I guess the event reloading isn't too important but it's nice to have so I don't have to keep restarting

naive mantle
#

pls help-

golden condor
#

Show the code

naive mantle
#
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;
        });```
golden condor
#

Do it before that code

naive mantle
#

ok

golden condor
#

right under the first line

naive mantle
#

YES

#

IT WORKS AND NO MESSAGE

#

woot woot

#

no more lengthy error message that takes up my suggestions

golden condor
#

ok

#

You could just send suggestions to a channel you know

naive mantle
#

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-

neat ingot
#

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

golden condor
#

Well this won't work for me

neat ingot
#

why on earth wouldnt it?

#

you just have to provide the client to your command handler/ command

golden condor
#

I mean what I've done

neat ingot
#

literally just copied and changed my existing command reloading code

golden condor
#
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?
neat ingot
#

yes, improve it by doing something similar to what i outline above 😄

#

im literally doing the same thing

golden condor
#

Well it is kinda hard to read tbh

#

cos its small

neat ingot
#

click image and open orig 😄

golden condor
#

eef

neat ingot
#

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

golden condor
#

I am tryna do what you did but I am not sure how I can implement it into my code

#

I need help

#

lol

coral stirrup
#

Is there a method for collectors to stop them without calling the end event?

golden condor
#

@neat ingot I'm not saying that

neat ingot
#

😛

golden condor
#

I just kinda need some help

neat ingot
#

😄

#

tbh, fuq accidentally drinking w.e crazy acid that is 😐

toxic jolt
#

wtf

neat ingot
#

it is a spoon being melted by acid?

toxic jolt
earnest phoenix
#

Code?

toxic jolt
#

wait

neat ingot
#

your trying to call 'end' on something that is undefined.

toxic jolt
#
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ç'
};
neat ingot
#

at line 26

toxic jolt
#

here

earnest phoenix
#

serverQueue.connection.dispatcher.end('');

#

that one

#

you're trying to get the message id again var serverQueue = queue.get(message.guild.id);

toxic jolt
#

okay

#

thanks

#

for helping

#

oh

#

sorry but i how to fix?

#

@earnest phoenix

#

😄

earnest phoenix
#

lemme check smth

toxic jolt
#

okay

earnest phoenix
#

@toxic jolt can you try removing the '' in serverQueue.connection.dispatcher.end('')

narrow kettle
#

[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

tight plinth
#

why dont u just return songs and not songs[::-1]

narrow kettle
#

it will return the string back words

#

because of the first time i do [::-1]

tight plinth
#

hmm

#

I'll let a python nerd solve ur problem, i suck at py

narrow kettle
#

lmao

pure lion
#

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

neat ingot
narrow kettle
#

btw nvm, found out how

abstract crow
#
<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
quartz kindle
#

same with reverse

#

serverName stays as domain only

dense jetty
#

my invite manager is offline and the commands don't work

abstract crow
#

Gotcha. So @quartz kindle do I just make one big VirtualHost?

quartz kindle
#

not sure if you can make it in one vitualhost

#

actually not even sure if it will work

#

i dont use apache

abstract crow
#

Gotcha. I'll try it

quartz kindle
#

@dense jetty this is not the support server for invite manager

neat ingot
#

lol, so many people come here for support on other bots 😄

dense jetty
#

no speak englesh

quartz kindle
#

Lol

dense jetty
#

im portuguese

neat ingot
#

gj!

abstract crow
#

Unfortunately it didn't work tim

quartz kindle
#

voce está no servidor errado

neat ingot
#

ahahah

quartz kindle
#

este servidor não é do invite manager

dense jetty
#

@quartz kindle br?

neat ingot
#

ofc tim knows portuguese too 😄

dense jetty
#

mais me ajuda pfv

#

n sei oq fazer

#

preciso mt dele

quartz kindle
#

-wrongserver

dense jetty
#

e ele ta off no meu dc

quartz kindle
#

rip

#

voce tem q ir no server deles

dense jetty
#

n tem chat livre la

slender thistle
#

-wrongserver @dense jetty

gilded plankBOT
#

@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 :(

neat ingot
#

tim knows every language, from C++ to zulu warrior tribe speak 😄

dense jetty
#

no chat communication

#

in invite manager

astral yoke
#

not our problem

dense jetty
#

I'm looking for help

#

I need him urgently

neat ingot
#

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 😄

nocturne dagger
#

Is there anyway to have a bot unban everyone from a server?

#

My server was raided and 13k people were banned.

earnest phoenix
#

@dense jetty didnt i sent an invite into support for the actual InviteManager support?

still merlin
#

@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)

earnest phoenix
#

why would you want to bulk unban people tho?

earnest phoenix
#

oh lol

nocturne dagger
#

I don't want to submit it its just going to be used for my server.

earnest phoenix
#

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?

delicate zephyr
#

@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

abstract crow
#

Awesome! Thank you so much. I'll try that rn

delicate zephyr
#

no problem

abstract crow
#

The other thing is that everything redirects to ac.vinniehat.com/races, etc. Not the /server1/races. Do you know how to fix that?

delicate zephyr
#

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

abstract crow
#

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

delicate zephyr
#

yea

#

you'd have to change the redirect from /races to /server1/races

abstract crow
#

Oof ok. The file has no extension so I have no clue what to do with it

delicate zephyr
#

wait

#

is /races a file?

abstract crow
#

No

#

I got 2 files with the manager. A config file, and the file to run for the server manager

delicate zephyr
#

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

abstract crow
#

oh boy

#

I mean

#

if it comes down to it

#

then I'll do it

earnest phoenix
#
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.```
delicate zephyr
#

.addField(`Old Message:`, `${message.content}`)

#

remove .content

earnest phoenix
#

mk

#

same error @delicate zephyr

#

nothing helped from here because my name and values aren't empty

hardy vector
#

how can i host a music bot on a vps

#

that uses lavalink

#

bc lavalink needs java 11

earnest phoenix
#

.addField(`**Platform:**`,member.presence.clientStatus)
is this right

sudden geyser
#

clientStatus is an object.

earnest phoenix
#

alr

radiant estuary
#

How can I get the Activity from a User? When you want to answer me, please ping me 😄

neat ingot
#

@radiant estuary

#

nty

radiant estuary
#

?

neat ingot
#

sorry, dont want to answer, just wanted to ping 🙂

#

^javascript

radiant estuary
#

Tank you

zenith terrace
#

@earnest phoenix u do know its easier to use the message edited event instead of the module.exports

radiant estuary
#

I thinked about this too

earnest phoenix
#

@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

topaz fjord
#

its probably embeds

#

embeds are sent as message edits

#

@earnest phoenix

#

so the oldMessage will be empty

earnest phoenix
#

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

topaz fjord
#

im saying if a embed in sent

#

not from the bot

#

from something else

earnest phoenix
#

idk

halcyon ember
#

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?

coral stirrup
#

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

halcyon ember
#

oh

#

but what about the replying

coral stirrup
#

same thing, fetch the message sent by the mods and send it via dm

slim heart
#

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
quartz kindle
#

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

slim heart
#

seems like pretty much the same thing

#

except i add a mysecret which im sure would be more secure

quartz kindle
#

and crypto.randomBytes

slim heart
#

which is just a securer way of doing the random part lol

quartz kindle
#

but also slower afaik

#

well idk

slim heart
#

probably

slim heart
#
<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?
sudden geyser
#

I mean, n, i and a are quite vague key names.

slim heart
#

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?

sudden geyser
#

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.

slim heart
#

i mean just for the sake of good looking code

#

probably a one line way of doing it without the absurd returning and stuff

earnest phoenix
#

in which

#

library

quartz kindle
#

@slim heart you can do x => ({n: x.name, ...})

earnest phoenix
#

try catch the fetch method from UserManager

slim heart
#

oo alr thats a bit better

quartz kindle
#

@slim heart you can also do this

slim heart
#

hmm maybe

quartz kindle
#

or this

slim heart
#

ye

digital ibex
#

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
halcyon ember
#

wait so if i fetch it how do i make my bot know the correct user to dm a reply to

static trench
#

Is there a discord.py command to see how many servers your bot is in? Like !servers and it tells you the number?

glacial thicket
#

yeah i have a command set up @static trench

#

ill send it gimme a sec

unique nimbus
#

Don't spoonfeed

glacial thicket
#

oh okay, well i found out how to do in by googling, so @static trench just look it up, not that hard to find

unique nimbus
#

it isn't hard

#

to find

#

but you should look at docs

#

ben

static trench
#

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

glacial thicket
#

yeah thats right!

static trench
#

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

earnest phoenix
#

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)```
tight heath
#

canal isn't defined

#

meaning "logs" doesn't resolve to a channel id

static trench
#

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

hardy vector
#
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
static trench
#

Ok???

digital ibex
#

@hardy vector u getting any errors?

hardy vector
#

TypeError: user.avatarURL is not a function

digital ibex
#

well

#

then theres ur issue

#

iirc its displayAvatarURL

golden raven
#

@hardy vector u got an answer

hardy vector
#

oh

#

lol

hardy vector
#

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)
          }
    },
};```
earnest phoenix
#

How do I make reaction buttons using Eris?

sudden geyser
#

@hardy vector displayAvatarURL is only available on the User class. You're calling it on a GuildMember instance.

hardy vector
#

oh

#

so what do i do

pale vessel
#

get the user object from the member

#

that would be user.user because the first user is actually a member

#

you named it wrong

oak stratus
#

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

earnest phoenix
#

How i delete all messages of my bot?

golden condor
#

That's not possible

#

In any way

#

Unless all the messages were sent under 2 weeks ago

earnest phoenix
#

Mmm

golden condor
#

Even then you would have to go through every single channel and fetch tons and tons of messages and delete tjem

earnest phoenix
#

And in a server?

#

Just in one

prime glacier
#

missing a help.name, or help.name is not a string

#

error

pale vessel
#

please give more details

hardy vector
#

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

pale vessel
#

read guides on how to install nodejs and stuff, if that's what you want to do

prime glacier
#

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.

pale vessel
#

you can add js module.exports.help = { name: "foo" } and move the help information there

prime glacier
#

ok wait

#

it says cannot read property of help of undefined

pale vessel
#

where did you add that

#

oh

#

it's module.exports

prime glacier
#

sorry i forgot to do exports 😂 but now again

pale vessel
#

look in your file, it's missing an s

prime glacier
#

i added it now but same error

pale vessel
#

where did you add the help that I sent

#

module.exports.help

#

send the file

prime glacier
#

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;
}
    
  }
pale vessel
#

undo everything

#

you need to separate them, not combine them

prime glacier
#

embed?

pale vessel
#

alternatively, you can change help.name to just name

#

no

prime glacier
#

oh i corrected it

pseudo wedge
#

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;
    }
}
sudden geyser
#

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)?

pseudo wedge
#

Yeah that's true, message.channel doesn't need to be assigned to a variable.

pale vessel
#

you also should have a dynamic help command, it helps

pseudo wedge
#

Also, .then(msg => { channel.send(embed1)}) doesn't need to be there while you can just add another line message.channel.send(embed1);.

hardy vector
#

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: []
}

indigo tapir
#

If I were to use Config Vars, could it be const Prefijo = require(process.env.Prefijo); or const Prefijo = process.env.Prefijo;?

vivid crescent
#

I don't use JS, but probably the second

indigo tapir
#

Hmm, ok.

vivid crescent
#

Isn't require for importing external scripts

indigo tapir
#

I'm new to JS since I use Lua or Phython.

#

But thanks. I'll try

pale vessel
#

the second yeah

sudden geyser
#

@hardy vector check the directory where the node command was run.

hardy vector
#

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

indigo tapir
#
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.

sudden geyser
#

new.Discord.Collection is not a thing.

indigo tapir
#

?

#

Oh

#

Sorry

#

Found the error

copper cradle
#

lmfao

indigo tapir
#

I'm such a bad coder dude

#

I'm getting a SyntaxError on line 47 but my code only has 45 lines

astral yoke
#

ok

turbid bough
#

you are prob not saving the file when editing, or you are launching the wrong file

copper cradle
#

yesh

earnest phoenix
#

snowflake = id ??

#

it is ??

somber verge
#

a snowflake is a unique id

tight plinth
#

^

spice smelt
#

hello! i’m currently using quick.db, but i’m looking for a better and more complete solution. do you have any suggestion?

tight plinth
#

maybe mongodb or sql

flat vine
#

i have making a bot @frigid wolfmemer 2

#

you also invite the bot

plucky heart
#

e.e

flat vine
#

the bot are in beta version

tight plinth
#

@flat vine please dont send top.gg links of your bot

#

its considered as an ad

flat vine
#

i new here

#

oke

tight plinth
#

now u know

flat vine
#

yes

earnest phoenix
#

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?

tight plinth
#

editing messages cooldown is very short, so I guess it cant be considered as api abuse

zenith terrace
#

I mean quite a few bots use embed reacts

modest maple
#

Editing messages are the same as sending

tight plinth
#

oh

#

I though it was smth like 1 edit every 0.25s

modest maple
#

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

iron scroll
#

How i can get amount of voice connections (discord.js 12)
This not work

tight plinth
#

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

earnest phoenix
#

can u give me example for snowflake

mossy vine
#

545490362568015873

earnest phoenix
#

ok . . . .

#

thx

tight plinth
#

714393258616422453

mossy vine
earnest phoenix
#

yes i am reading it

past wave
#

D tr

#

D tr

#

Rd td tr

#

R

#

D tr

#

D tr

tight plinth
#

?

zenith terrace
#

Uh

#

Spam much?

strong tundra
#

is there a macro for nsfw channels in serenity

#

or do i have to get is_nsfw on the channel

mossy vine
#

pretty sure you just check is_nsfw

#

youd probably have better luck asking in the serenity discord server tho

strong tundra
#

ah

#

just wanted to see if there was a simpler way

mossy vine
#

not that i know of

earnest phoenix
#

hey

#

can i ask smth

mossy vine
#

dont ask to ask

still merlin
#

Don't ask to ask a question

earnest phoenix
#

how can a person change my bot's name?

#

is that possible

#

it just happened

#

and i have 2fa

flat vine
#

Bot awaiting approval - Please be patient, us humans take time to verify bots!

#

who can verify my bot

earnest phoenix
#

"Please be patient"

flat vine
#

yes I know but I just wanted how long that will take @earnest phoenix

summer torrent
#

1 week or more

flat vine
#

o thnx

summer torrent
opaque seal
#

How do you make a message like this?
I know I can use ``` but what do I put next to that?

nocturne grove
#

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?

earnest phoenix
#

real name

opaque seal
#

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?

nocturne grove
#

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

opaque seal
#

uhm ok

#

thx

neat ingot
#

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
bitter sundial
#

I dont think you can really reverse it

#

you'd get many possible solutions

neat ingot
#

yea idk if it can be reversed either lol

#

everything i try is just wildly off lol

earnest phoenix
#

@neat ingot go in this server and ask

#

they have Big Brain

#

they will answer

neat ingot
#

lmao

#

nah im not gonna join a server to ask a question then leave :D
thats savage af 😄

earnest phoenix
#

LMAO

#

:))

neat ingot
#

idk if ill be able to make my minesweeper minigame without sorting the formula though 💔

earnest phoenix
#

lol

neat ingot
#

need it to calculate the adjacent squares :/

earnest phoenix
#

hi

#

im trying to write json but i get this problem

modern sable
#

Your JSON syntax is broken

neat ingot
earnest phoenix
neat ingot
#
const configWrite = {};
configWrite[guildid] = {
    
}
#

do it that way

earnest phoenix
#

oh it works now, tnx

neat ingot
#

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 😄

earnest phoenix
#

why does it write it like that lol

neat ingot
#

uhhh

#

idk why the first { } but the rest is valid

earnest phoenix
#

it writes it like that

#

just adds new {}

neat ingot
#

your saving to a file yea? using json stringify?

earnest phoenix
#

yeah

neat ingot
#

why null, 2 in your filesync? thats not valid according to the doc

#

your third arg should be an object, no 4th arg

earnest phoenix
#

i was reading this tutorial

neat ingot
#

likely not the issue, just thought i'd mention

#

lol, the null, 2 is for json stringify options 😛

earnest phoenix
#

lemme explain

#

i want to add new values into json

#
{
  guildid: {
    somevalue: "asdasd"
  }
  otherguildid: {
    value: "asdasdasd"
  }
}
neat ingot
#

yea i got that already 😄

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

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

earnest phoenix
#

i need to save 2 variables

neat ingot
#

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 🙂

earnest phoenix
#

ill try this above, sec

neat ingot
#

(dont copy my code word for word, it wont work if you do)

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

thats literally the only thing i store in json.

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

any guild or player config is handled by an actual databasing system: mongodb.

#

what your bots do jimboo?

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

nice 🙂

#

i've never seen the point in making a music bot tbh

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

there are so many really good ones already

#

hard to make one thats able to compete enough imo

earnest phoenix
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

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

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

well, i made a few commands, then decided it'd be best in its own bot

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

so now here i am, almost two bots in 😛

#

eww python

#

🤮

earnest phoenix
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

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

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

yea which language

earnest phoenix
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

why u wanna switch?

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

fair enough i guess 😄

#

personally id go c++

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

like, if i was gonna change

mossy vine
#

@earnest phoenix thats just your code being shit lmao

neat ingot
#

lullllz ~ shots fired

mossy vine
#

not even shots, its just the truth

neat ingot
#

tbh tho, why are you able to even try execute a command that doesnt exist?

earnest phoenix
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

👀

#

never heard of such a thing lol

opaque seal
#

@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
@neat ingot thx

neat ingot
#

np 🙂

earnest phoenix
#
const dbl = new DBL(api_token, { webhookPort: 5000, webhookAuth: 'password' });

what i have put at the webhookPort when i use heroku ??

#

oops wrong channel

neat ingot
#

i think heroku gives you a specific port in the ENV

#

idk if it allows you to have access to other ports

earnest phoenix
#

wut

#

is

#

wait

#

ok

restive furnace
#

process.env.PORT

#

?

neat ingot
#

yea i think thats what they use

#

yup

nocturne grove
#

yes it's that

muted wave
#

Hi

neat ingot
#

slowly getting there 😄

bronze fossil
#

Heyy

muted wave
#

@bronze fossil can you help me huh

bronze fossil
#

Sure

earnest phoenix
#
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

quartz kindle
#

do you have a web dyno enabled?

earnest phoenix
#

yes

#

http://webhook.herokuapp.com/dblwebhook is this correct

#

??

neat ingot
#

i highly doubt you have the url webhook.herokuapp.com

earnest phoenix
#

what ?

#

wdym

neat ingot
#

you should be going to myappname.herokuapp.com/webhookpath

earnest phoenix
#

oh shit

#

oops

neat ingot
#

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

earnest phoenix
#

oh

neat ingot
#

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*

earnest phoenix
#

OMFG

#

it work

#

OMFG

#

I dont need vps anymore

#

yey

slender thistle
#

If you want a proper machine, you do

earnest phoenix
#

bro vps cost money

#

:((

#

wait

#

does dyno work 24/7

#

or it will shutdown until there is request

neat ingot
#

im sweeping the mines ^_^

earnest phoenix
#

@neat ingot does web dyno shutdown

#

when there is no request

neat ingot
#

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.

wheat swallow
#

You can bypass it by making your app request itself in a given interval

earnest phoenix
#

oh

wheat swallow
#

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

neat ingot
#

lmao

earnest phoenix
#

lmao

wheat swallow
#

😉

earnest phoenix
#

@neat ingot where did ya host ur bot

#

????

#

i neeed some low cost host

wheat swallow
#

you can have an affordable VPS for 5 / 8€

earnest phoenix
#

oh

#

-vps

tulip wave
#

contabo has cheap plans

earnest phoenix
#

oof

#

@neat ingot what are u making that game in

wheat swallow
#

@earnest phoenix In which country do you want the server to be ?

earnest phoenix
#

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

wheat swallow
#

Hm... then you can go with contabo yes

earnest phoenix
#

ok

neat ingot
#

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.

earnest phoenix
#

oh

#

wtf that look cool

neat ingot
#

contabo is also a german company

#

with options for hosting in germany or usa (ny)

vivid crescent
#

How much

neat ingot
#

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

vivid crescent
#

How much disc space

neat ingot
#

200gb ssd

#

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

vivid crescent
#

Thanks for sharing

neat ingot
#

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%

sullen salmon
#

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

slender wagon
radiant estuary
#

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

cinder patio
#

@sullen salmon you can use the Structures class https://discord.js.org/#/docs/main/stable/class/Structures

earnest phoenix
#

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

radiant estuary
#

yes

earnest phoenix
#

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

neat ingot
#

google apis are annoying af imo

earnest phoenix
#

they aren't

#

except the youtube one

neat ingot
#

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

earnest phoenix
#

i used google's speech to text api last year for my cs finals lol

#

also google translate costs money

neat ingot
#

ie - 1k map reloads = $20

earnest phoenix
#

f that

#

had no issues whatsoever

radiant estuary
#

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

sullen salmon
#

Thanks @cinder patio

earnest phoenix
#

then you're reading the json file wrong or you didn't save it

neat ingot
#

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

radiant estuary
#

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

neat ingot
#

no

#

require your json file

#

const config = require('myconfig')

earnest phoenix
#

readFileSync returns the string/buffer

#

it isn't the object

radiant estuary
#

okay. Thank you. I am asking, because that always worked

earnest phoenix
#

either require it like dekita said or JSON.parse it

radiant estuary
#

oh, yeah. thank you

earnest phoenix
#

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

radiant estuary
#

roles.cache

#

?

earnest phoenix
#

yea it v12 cache.get?

#

one cache?

radiant estuary
#

with guilds, channels, member and users too

earnest phoenix
#

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.

mossy vine
#

Supplied roles is not an Array or Collection of Roles or Snowflakes.

still merlin
#

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

neat ingot
#

first game of minesweeper ive won in my life lol

jolly nimbus
#

How do I make a simple ping command on my bot?

twin marsh
#

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

neat ingot
#

wtf

#

an 18 minute video for a ping command

unique nimbus
#

An 18m video of them telling you what they are doing

#

and how it works

#

is better than 2m video of just code

neat ingot
#

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

tight plinth
#

an 18m video with 2 minutes of coding and 17 minutes of commentating

neat ingot
#

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.

tight plinth
#

I dont even do that

#

takes a date.now()
send message
edit it with date.now()-previous date.now()

neat ingot
#

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

earnest phoenix
#

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

ripe epoch
#

Is it difficult to implement a database into code?

pale vessel
#

maybe at first but it's easy to get used to it

ripe epoch
#

Sweet

#

Thanks

hardy vector
#
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
cinder patio
#

members don't have a username property

hardy vector
#

oh

#

so how do i make it show the user kicked

cinder patio
#

.displayName or .user.username

hardy vector
#

how can i make it show the person being kicked discriminator?

grizzled raven
earnest phoenix
#

How do I show text in these box things

warm cloud
#

that's an embed

uncut river
#

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

earnest phoenix
#

that's an embed
@warm cloud how do I make that blue url?

warm cloud
#

that's just a link

earnest phoenix
#

So the title is different

warm cloud
#

and yo can you not ping

earnest phoenix
#

From the actual url

#

How

uncut river
#

you use markdown

slender thistle
#

@uncut river Authorization field on your bot's Edit page?

#

You create it yourself

earnest phoenix
#

Thanks

uncut river
#

thank you

spice smelt
#

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?

warm cloud
#

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

spice smelt
#

as an attribute of the command object? you mean smth like <client>.db ? i don't think that it's possible in js x)

warm cloud
#

client object sir

spice smelt
#

I didn't fully understood what you meant

#

don't answer; i'll learn python it'll be better x)

neat ingot
#

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?

limber flume
#

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 cry

earnest phoenix
#

One message removed from a suspended account.

limber flume
#

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
earnest phoenix
#

One message removed from a suspended account.

#

One message removed from a suspended account.

limber flume
#

😭

earnest phoenix
#

One message removed from a suspended account.

limber flume
#

ok.

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

there are many many many changes from v11 -> v12

earnest phoenix
#

One message removed from a suspended account.

topaz fjord
#

no?

neat ingot
#

well, no. you need to understand the changes that were made, and then change those relvant things

topaz fjord
#

just 3 things

neat ingot
#

for example, client.guilds now has a cache, so you use client.guilds.cache.size instead of without the cache

topaz fjord
#

^

earnest phoenix
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

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.

earnest phoenix
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

yea you will likely have more than one thing that needds changed

#

it took me weeks to update from 11->12

earnest phoenix
#

One message removed from a suspended account.

neat ingot
#

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.

modest maple
#

@limber flume You dont assign reactorslist anywhere other than []

#

which choice cant pick from

earnest phoenix
#

@neat ingot reading back up, have you fixed your issue?

neat ingot
#

the emoji space issue thing? nah, im just gonna have a space in between them fk it

#

lol

limber flume
#

@limber flume You dont assign reactorslist anywhere other than []
@modest maple how do you mean

earnest phoenix
#

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

neat ingot
#

ooooooohhhhh

#

good call

#

that makes sence also lol

#

tyvm ❤️

#

\u200b is a zero width space?

earnest phoenix
#

yup