#development

1 messages · Page 889 of 1

earnest phoenix
#

Hey i want to know how to bump our server on top.gg?

opaque kite
#

Are you good in python?

true tundra
#

No

earnest phoenix
#

My server is their but on third position on tag

opaque kite
#

Then the error it's probably from your code

true tundra
#

How can i get discordjs if im on chromebook

earnest phoenix
#

I need help where to visit??

green vale
#

get discord.js using something like glitch

opaque kite
true tundra
#

idk how to work glitch

opaque kite
#

@true tundra learn a language first.👍

true tundra
#

bruh

green vale
#

yeah

#

you need to learn a lang before using something like glitch

true tundra
#

Why did u tell me to use glitch then

green vale
#

Use Glitch once you learn how to use a lang

#

Glitch is a way to host a Discord.js bot

true tundra
#

Im on chromebook though

opaque kite
#

Then use mee6 and it's customizable

green vale
#

yeah

true tundra
#

omg

glass sundial
#

Help me

#

Plz

#

How do I join the pokecord discord

green vale
#

Wrong channel and uh check their website? This is the wrong server to ask in

queen needle
#

whyd my bot get muted?

scenic kelp
#

You can check for a reason by searching in: mod-log <your bot ID>

queen needle
#

got it

#

says it responds to other bots but it doesnt?

turbid bough
#

(not rly)

queen needle
#

how do i make it so my bot doesnt respond to other bots like how do i make it so my bot only repsponds to users (discord.js)

turbid bough
#

User.bot

ember atlas
#

That's not it

queen needle
#

so like

ember atlas
#

Not it either thaun

#

Let me get the doc link

queen needle
#

if(!User.bot)

turbid bough
ember atlas
#
#

Just if the message author is a bot, return

scenic kelp
#

eg if (message.author.bot) return

turbid bough
#

idk what was wrong what i said lol

queen needle
#

and i set return to nothing

#

so it cant be if (message.author.bot) return message.channel.send("Your a bot")

scenic kelp
#

No, because then you're responding to a bot

ember atlas
#

No its literally return;

queen needle
#

okay thank you

ember atlas
#

@turbid bough They were looking for message.author.bot which returns a boolean to then return on it

turbid bough
#

you dont want to recieve a message, check if its a bot, send a message back that it is a bot. then the other bot starts doing the same and it does a forever loop

#

i thought he already knew that message had a user variable :/

remote yacht
#

i am unable to change prefix of my bot in this server using quick.db

#

im trying to do it using eva;

#

eval

#
.eval const db = require('quick.db')
let guildID = "264445053596991498"
let a = "1s"
db.set(`prefix_${guildID}`, a)```
marble juniper
#

did you try that eval command in this server

remote yacht
#

no

marble juniper
#

or another server

remote yacht
#

cant as bot is muted

marble juniper
#

k

remote yacht
#

trying to do that by getting the guild id of this server

marble juniper
#

did you try restarting the bot

#

maybe idk

remote yacht
#

it would give syntax error

#

although there's no syntax error

marble juniper
#

can you show the error

sick cloud
#

how do i convert an integer color to a hex code

remote yacht
#

SyntaxError: Invalid or unexpected token

#

@marble juniper nvm fixed it

marble juniper
#

bruh

remote yacht
#

i thought the ` would need to escape

#

as in discord its prefix and not `prefix`

#

but i dont have to escape `

sick cloud
#

learn js

#

` is a template literal

#

another sort of " or ' but allows template literals in them

earnest phoenix
#

It is possible, but its not for beginners at all
@modest maple im not begginer

marble juniper
#

then do it

regal jacinth
#
@client.command()
async def f(ctx):

    image1 = Image.open('Yato_2.png')


    font = ImageFont.truetype("Nowharehouse.ttf", 20)
    draw = ImageDraw.Draw(image1)
    draw.text(xy=(50, 50),text="hehe",fill=(255,69,0),font=font)
    await ctx.channel.send(file=discord.File(image1))```
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: expected str, bytes or os.PathLike object, not PngImageFile```
 ok this cmd does write on the picture but I can't make the bot send it  , this error is what I get when I use the cmmd
if I put image1.show() instead of the await line , it will show me the pic with the font
it turns out that it makes the pic into jpg , soo how do I change it into png again ?
queen needle
#
 let prefixes = JSON.parse(fs.readFileSync("./prefix.json", "utf8"));
  let botconfig = require("./botconfig.json")
let PREFIX = botconfig.prefix

  if(!prefixes[message.guild.id]){
    prefixes[message.guild.id] = {
      prefixes: botconfig.prefix
    }
  }
  
  let prefix = prefixes[message.guild.id].prefixes
  if(message.content.startsWith(PREFIX + 'prefix')){
  if(!message.member.hasPermission("MANAGE_SERVER")) return message.reply("You need a higher permission")
  if(!args[0] || args[0 == "help"]) return message.reply("Useage: ^prefix <desired prefix here>")
 
  prefixes[message.guild.id] = {
    prefixes: args[0]
  }
  
  fs.writeFile("./prefix.json", JSON.stringify(prefixes), (err) => {
        if (err) console.log(err);
      }).then(message.channel.send({
      embed: {
          color: dblue,
          title: "Prefixes",
          fields: [
            {
              name: "Prefix set",
              value: `Set to ${args[0]}`
            }
          ]
        }```
#

i dont understand why my command doesnt change the prefix

#

in the prefix.json it says what i set it too

regal jacinth
#

many if

#

dude

#

change the 2nd and 3rd if into elif

queen needle
#

sorry

regal jacinth
#

under the let

queen needle
#
 if(message.content.startsWith(PREFIX + 'prefix')){
 else if {
   (!message.member.hasPermission("MANAGE_SERVER")) return message.reply("You need a higher permission")
 }
  else if {
    (!args[0] || args[0 == "help"]) return message.reply("Useage: ^prefix <desired prefix here>")
  }```
#

like that

regal jacinth
#

this is python ?

queen needle
#

no?

#

discord.js

regal jacinth
#

oh sorry then

queen needle
#

do i not need the else ifs

regal jacinth
#

I thought it was python

#

well idk + I said elif not else if XD

edgy heron
#

well

#

it's 12+ days now. i didnt get any reply of my verification till now

keen fern
earnest phoenix
#

@keen fern you need to participate in the discord Developer Verification program if your bot is in 75 guilds or more

keen fern
#

Ooh

#

ok thanks

earnest phoenix
#

👍

keen fern
#

btw how I got that nickname?

modest maple
#

@modest maple im not begginer
Trust me after seeing your previous posts you are not ready for ot

idle mountain
#

@keen fern probably had ads in your status or something, and mods maybe nicked you because you were showing on the top of the user list due to your name starting with A

honest perch
#

He has an ad in his status to yeah

idle mountain
#

oh that wasn't showing when i wrote that message MegaThonk

queen needle
#

just used my first ever db

#

for a setprefix command

true tundra
#

Is there a way to make the bots status go back and forth from streaming and playing?

queen needle
#

yes

#

wait

#

idk

true tundra
#

Oh

queen needle
#

i thought like switch what you were playing

#

you might be able to with set interval

turbid bough
#

js has a think like setinterval, atm im just seeing its just for websites

#

or is it not a good idea to use it at all

marble juniper
#

I mean you can use setinterval for more than just websites

#

you can do checks like if something exists or not

#

or change something over time

#

like switch back and forth

#

its not useless

#

and not really bad

turbid bough
#

ok, just making sure it was like safe to use

marble juniper
#

I mean depending what bit system you use if you set the interval too high it will be set to 1ms

turbid bough
#

ahaha nah, i dont think it will be that no

marble juniper
#

thats only a problem on 32 bit

#

to be honest

#

also you can clear intervals

#

to make intervals stop after a certain condition

#

or over time

#

however you want

#

like make it add a number and once it reaches 100 make it stop the interval

#

just an example but there are many use cases

turbid bough
#

how would it go if it is going to run forever?

marble juniper
#

well

#

it runs forever

#

untill you stop the process

turbid bough
#

obviously yeah

marble juniper
#

if it runs forever it runs forever

turbid bough
#

i mean forever in-program

#

if you want it to be literate

marble juniper
#

im not gud at explaining so

#

dunno

turbid bough
#

meh you're fine

marble juniper
#

Also I got some work to do so cya

turbid bough
#

o/

coarse spade
#

Hello, i am looking for a developer who works in discord.js. I am trying make my bot change the name of a voice channel at a set time of day. For example every day at 3pm the voice channel name changes to group meeting. It is going to be a bot on my private friend server and i will not be sharing your hard earned work with anyone.

turbid bough
#

ooh, so thats what you meant, lol i thought you wanted a clock on the channel

coarse spade
#

Are you able to help now? Sorry if i didnt explain well before

opaque kite
#

You can do it

turbid bough
#

all i can say that you would use setinterval with a small timer like 1 minute or so, add if statments from date.now and change channel name from id

coarse spade
#

Okay thank you

opaque kite
#

Yes you can do it with setInterval()

coarse spade
#

hmm okay ill see what i can do

#

if i made testchannel a var and did testchannel.setName("meeting") would that work?

turbid bough
#

nvm, setName should work too

torn nebula
#

that will work

opaque kite
#

message.channel.setName("testing") .catch(console.error) ...

grizzled raven
#

if you set an id property in a schema, will mongoose's _id id getter override it?

coarse spade
#

@woven sundial With const chan = client.channels.get("CHANNEL ID") client is not defined

#

that works

golden condor
#

It works

#

If he uses client then let him use client

#

Ok

#

Sorry

#

O

coarse spade
#

its okay

#

everything worked out

#

lol

#

Now i need the bot to detect when its 9:15 am and change the channel name

torn nebula
#

check if Date.now() is equal to 9:15 am

sacred mountain
#

Does anyone know how I could put the amount of servers my bot is in, in the status? Because when I start it grabs the correct amount but then when it is added to another server it doesn’t update until I restart the bot

#

I have it in the status as like bot.guilds.cache or something

twilit rapids
#

Updating the status on guild Join or Leave could be rather spammy if it's a big boat

sacred mountain
#

It’s not

#

It’s in I think 68 servers

#

Yh

#

Why is that bad

turbid bough
#

Guild join, or member join?

sacred mountain
#

Guild

#

When the bot is added to another server

#

Oh

coarse spade
#

@torn nebula how do i check if the date is equal to 9:15

sacred mountain
#

Does anyone know the answer to my problem? The bot I’m trying to do it on is @safe harness. It is stuck on 68 until I restart the bot

coarse spade
#

What does your code look like SaltySpamz?

sacred mountain
#

Lemme get it one sec

torn nebula
sacred mountain
#

@coarse spade bot.on('ready', () =>{ console.log('BOT SUCCESSFULLY STARTED'); bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error) })

coarse spade
#

one sec

earnest phoenix
coarse spade
#

@sacred mountain bot.on("ready", () => { console.log("This bot is online!"); bot.user.setActivity(bot.guilds.size + ' servers for cc!help', {type: 'WATCHING'}); })

#

try this

sacred mountain
#

I tried that

#

It says undefined

coarse spade
#

what is undefined

sacred mountain
#

The bot.guilds.size

earnest phoenix
#

@sacred mountain =>
bot.guilds.cache.size

sacred mountain
#

I am currently using that

earnest phoenix
#

Hmm... What version of discord.js are you using?

sacred mountain
#

12

earnest phoenix
#

Hmm wait lemme see...

sacred mountain
#

The cache.size works

#

It’s just it doesn’t update

earnest phoenix
#

What doesn't update?

sacred mountain
#

The status

torn nebula
#

string breaks code @earnest phoenix

earnest phoenix
#

@sacred mountain you mean like the activity get updated every time it joins a new guild?

sacred mountain
#

Yh

earnest phoenix
#

@torn nebula in which line?

torn nebula
earnest phoenix
#

Hmm... I don't see an issue on that

torn nebula
#

that's fixed img

earnest phoenix
#

Oh...

#

Lemme see

balmy knoll
#
client.user.setStatus("dnd");```
Why doesn't this code work? (It always set online status)
lament yoke
#

đŸ€Š

coarse spade
#

client.user.setActivity

earnest phoenix
lament yoke
#

No > client.user.setActivity
@coarse spade

turbid bough
#

programming on a mobile lol?

lament yoke
#

.setPresence

earnest phoenix
#

@turbid bough yes... Big brain

balmy knoll
#

@coarse spade This is for setting the bot activity

coarse spade
#

Oh sorry

#

Missread

earnest phoenix
#

@balmy knoll setStatus is correct...
The setStatus function is just completely drunk

balmy knoll
#

So how can i set the dnd status on the bot?

earnest phoenix
#

@balmy knoll idk... Just set it with what you did and you have to wait a long time

torn nebula
#

version?

earnest phoenix
#

setStatus is just fully drunk

#

@torn nebula me?

lament yoke
#

@balmy knoll wair

torn nebula
#

no

vital geyser
#

Hey

balmy knoll
#

@earnest phoenix I wait, but nothing change

earnest phoenix
#

@balmy knoll hmm... Then that's discord.js's problem

#

@torn nebula so as said... Did you spot any difference between what i showed in that screenshot or the code you showed lol?

coarse spade
#

How can i make the bot detect when its a certain time like 9:15am

earnest phoenix
#

the bot isn't aware of that, your app is

coarse spade
#

and then .setName

#

people have been telling me to use Date.now()

still plover
#

I don't set invite manager bot

#

To welcome channel

turbid bough
#
if(Date.now().getMinutes() >= 15 && Date.now().getHours() >= 9)
``` is one way
#

something similar to that

still plover
#

Please help me

earnest phoenix
#

@still plover this is not a server for a specific bot support

torn nebula
earnest phoenix
#

Oh i see

#

K lemme fix that

coarse spade
#

will this work @turbid bough if(Date.now().getMinutes() >= 15 && Date.now().getHours() >= 9) message.channel.send("hello")

turbid bough
#

that will send a message everytime you try to check yes and both of them are over those values

still plover
#

@earnest phoenix what is about this server please dercribe in some sentences

hasty sparrow
#

@torn nebula That isn't an issue, as he's using backticks for the string

earnest phoenix
hasty sparrow
#

What happens when you start the bot?

earnest phoenix
#

@still plover it's about the bots you've built and support on their development for them

coarse spade
#

Thaun how do i set it to always check for it

turbid bough
#

use setInterval

still plover
#

Ohh i see you are build tha bot right

earnest phoenix
#

@hasty sparrow i mean that... The node just doesn't start up the bot after my bet command was written

coarse spade
#

how?

hasty sparrow
#

Does the bot start if you comment out the command?

earnest phoenix
still plover
#

You can give me a bot

turbid bough
#
var myVar;

function myFunction() {
  myVar = setInterval(alertFunc, 3000);
}

function alertFunc() {
  alert("Hello!");
}```
earnest phoenix
#

@hasty sparrow i mean the bot just doesn't start up completely after i wrote that command

clear zealot
#

mm,

still plover
#

Answer bot i need but i cant find

hasty sparrow
#

Have you verified that it's the command itself causing the issue (commented it out and run the bot)?

earnest phoenix
hasty sparrow
#

Also do yourself a favour and don't use a JSON file as database

earnest phoenix
#

Ik i'll switch to a db

#

These are just the test phases if the commands would work then i would switch to a db

late hill
#

This is one issue in your code

if (`${randomoutcomes} === "Win"`){```
earnest phoenix
#

The quotations are the issue?

late hill
#

yes

earnest phoenix
#

Hmm k lemme remove them real quick

late hill
#

the `

earnest phoenix
#
    at <anonymous>
    at runMicrotasksCallback (internal/process/next_tick.js:122:5)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)
(node:1464) 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(). (rejection id: 23)```

220. satırda nasıl bi hata var ?
hasty sparrow
#

@earnest phoenix Line 19 you have a semicolon after setDescription

earnest phoenix
#

Oh do i?

hasty sparrow
#

Nvm, pastebin added it

#

It's not in the raw code

earnest phoenix
#

@late hill also... That quotations that i removed still didn't resolve the issue

coarse spade
#
    var myVar;

function myFunction() {
  
  const chan = bot.channels.get("684266247302414377")
       
   if(Date.now().getMinutes() >= 15 && Date.now().getHours() >= 9)
        chan.setName("Meeting")
  
     
  myVar = setInterval(alertFunc, 3000);
}

function alertFunc() {
  alert("Hello!");
}
        
     ``` is this correct?
hasty sparrow
#

Try it out

earnest phoenix
#

Try it and SEE

coarse spade
#

If i want to set it to a pm time do i have to do 24 hour time

#

like 18 = 6pm

late hill
#

the reason it didn't run was likely because of the issue dukeofsussex mentioned

#

the issue i mentioned is why it wouldn't work properly if it did get to run

torn nebula
earnest phoenix
#

I inspected both the issues but no luck @late hill

coarse spade
#

If i want to set it to a pm time do i have to do 24 hour time

hasty sparrow
#

Comment out all of the bet command code, run the bot and if it works, uncomment it code block by code block and rerun it to find the issue

earnest phoenix
#

Hmm k lemme test this whole thing out...

coarse spade
#

If i want to set it to a pm time do i have to do 24 hour time

#

If i want to set it to a pm time do i have to do 24 hour time

earnest phoenix
#

Also i think my node spots an error that doesn't start up (After i updated my phone to android 10 it never showed the errors in start up... It just didn't start up the bot)

hasty sparrow
#

No need to spam the same question

torn nebula
#

If i want to set it to a pm time do i have to do 24 hour time
No
you can check it's am or pm

coarse spade
#

please tell me how sai chinna

lament yoke
#

Why he send me an error has channel :

const channelID = '659082642116968448';
const channelID2 = '659085499872444416';

client.on('guildMemberAdd', member =>{
    let embed = new Discord.RichEmbed()
        .setDescription(':tada: **' + member.user.username + '** a rejoint ' + member.guild.name)
        .addField('Nous sommes désormais ' + member.guild.memberCount, "** **") 
        .setFooter('Bienvenue ' + member.user.username)
    member.guild.channels.get('471566867518193664').send(embed)
    member.addRole('MEMBRE')
 
});
 
client.on('guildMemberRemove', member =>{
    let embed = new Discord.RichEmbed()
        .setDescription(':cry: **' + member.user.username + '** a quitté ' + member.guild.name)
        .addField('Nous sommes désormais ' + member.guild.memberCount, "** **")
        .setFooter('Bye ' + member.user.username);

    member.guild.channels.get('471566867518193664').send(embed)
 
});

client.on('guildMemberAdd', function (member) {
    updateStatusOnline(member.guild);
    updateStatus(member.guild);
});

client.on('guildMemberRemove', function (member) {
    updateStatusOnline(member.guild);
    updateStatus(member.guild);
});

client.on('presenceUpdate', function (member) {
    updateStatusOnline(member.guild);
    updateStatus(member.guild);
});

function updateStatusOnline(guild){
    let online = guild.members.filter(m => m.presence.status != 'offline').size-1;
    let formatString = 'En ligne : '+online;
    let channel = guild.channels.get(channelID);
    if(channel.name !== formatString){ <-- Here
        channel.setName(formatString);
    }
}
function updateStatus(guild){
    let max = guild.memberCount-1;
    let formatString = 'Membres : '+max;
    let channel = guild.channels.get(channelID2);
    if(channel.name !== formatString){ <-- And here
        channel.setName(formatString);
    }
}
earnest phoenix
#

you tell us

#

we can't debug for you

coarse spade
#

i give up

#

cya guys

lament yoke
#

u want the bug report ?

hasty sparrow
#

What is the error?

torn nebula
#

use any npm package to check time JOHN611

lament yoke
#

/home/debian/Bot/index.js:51
if(channel.name !== formatString){
^

TypeError: Cannot read property 'name' of undefined
at updateStatusOnline (/home/debian/Bot/index.js:51:13)
at Client.<anonymous> (/home/debian/Bot/index.js:43:2)
at Client.emit (events.js:189:13)
at PresenceUpdateHandler.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/handlers/PresenceUpdate.js:48:16)
at WebSocketPacketManager.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/debian/Bot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:189:13)
at Receiver.receiverOnMessage (/home/debian/Bot/node_modules/ws/lib/websocket.js:789:20)

earnest phoenix
#

@hasty sparrow also to show you...
I cut and paste the code somewhere else out of my code file and the bot starts up...
Welp... I think it's investigation time to resolve some codes...

hasty sparrow
#

Channel wasn't found

finite bough
#

check the Id again

#

if that doesnt work

#

check it by name

#

if that also doesnt work

#

debug

hasty sparrow
#

@earnest phoenix Really should use a proper editor for your code, would make your life so much easier 😉

earnest phoenix
#

Yea... Thx for the advice btw... And yea... Let's go to the start of investigation...

#

@lament yoke

#

hey

torn nebula
#

no

lament yoke
#

no

torn nebula
#

id is wrong

lament yoke
#

channel is definied

torn nebula
#

log channel thing

earnest phoenix
#

haa

#

Is the channel defined?

torn nebula
lament yoke
#

id is wrong
@torn nebula
No it's for member count, and id is valid

earnest phoenix
#

haaa

#

write

torn nebula
earnest phoenix
lament yoke
#

new error if (typeof value === 'undefined') throw new Error('Value must be specified.');
^

Error: Value must be specified.
at Map.find (/home/debian/Bot/node_modules/discord.js/src/util/Collection.js:499:45)
at updateStatusOnline (/home/debian/Bot/index.js:49:33)
at Client.<anonymous> (/home/debian/Bot/index.js:42:2)
at Client.emit (events.js:189:13)
at PresenceUpdateHandler.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/handlers/PresenceUpdate.js:48:16)
at WebSocketPacketManager.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/debian/Bot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:189:13)

#

i have change let by const

sacred mountain
#

Does anyone know how I can make my bots status update? It shows how many guilds it is in but is there a way to update that when it joins a new server because at the moment i have to restart the bot for the status to update. Is there maybe a way to make a function where the status refreshes when bot.guilds.cache.size changes?

lament yoke
#

make a var

restive furnace
#

make it on guildAdd n Dlete event

#

@sacred mountain^

sacred mountain
#

What do u mean

pale vessel
#

guildAdd event

sacred mountain
#

I’m not sure how I would write it out

clear zealot
#
21 error errno 1
22 error create-discord-bot@2.0.0 start: `node ./src/index.js`
22 error Exit status 1
23 error Failed at the create-discord-bot@2.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]```
#

any solution

torn nebula
#

no you can't update status on guild join

sacred mountain
#

Rly?

#

So is it impossible?

#

I swear I have seen bots with it before

torn nebula
#

ready event fires when bot starts up

lament yoke
#

make a var for exemple "Servers" and use guildAdd or guildDelet

#

and use the var on the ready

sacred mountain
#

so how would i do it with this:

#
    console.log('BOT SUCCESSFULLY STARTED');
    bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})```
torn nebula
#

u can setinterval it updates after sometime

sacred mountain
#

How would I do that

lament yoke
#

so how would i do it with this:
@sacred mountain
use the var

torn nebula
#

lol

restive furnace
#

@torn nebula you can lol...

#

you can change clients presence on guildAdd, and guildDelete event.

pale vessel
#

this could work ```js
client.on("guildCreate", () => client.user.setActivity(something));

restive furnace
#

yes

lament yoke
#

USE VAR

#

no setactivity

restive furnace
#

wdym

sacred mountain
#

Don’t u need to apply for an intent to use guildCreate?

restive furnace
#

lol

#

@sacred mountain no

sacred mountain
#

Oh

#

I saw it on a list of stuff u get with the intent

pale vessel
#

in that case you can just use setInterval

sacred mountain
#

K

earnest phoenix
#

What would be the best way to setup a premium system for by bot using patreon?

pale vessel
#

premium status in db using user ids

lament yoke
#
let servers = bot.guilds.size;

bot.on('guildCreate', function(guild) {
  servers++;
}
bot.on('guildDelete', function(guild) {
  servers--;
}

bot.on('ready', () =>{
    console.log('BOT SUCCESSFULLY STARTED');
    bot.user.setActivity(servers+ ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})

Use that

earnest phoenix
#

I want it to be so they can only use it on one guild tho.

pale vessel
#

no @lament yoke

lament yoke
#

it works

pale vessel
#

no var

hasty sparrow
#

No var and it doesn't make sense

lament yoke
#

why ?

pale vessel
#

also, you can just remove guild from the event since you're not going to use it

restive furnace
#

bruh dont use var, use let and const instead.

earnest phoenix
#

let > const > var

#

Hi

green kestrel
#

@earnest phoenix so what i'd do is.... i'd have it so theres a scheduled task or cron job on your server

#

every day, hour, whatever you want, it wakes up

earnest phoenix
#

mhm

green kestrel
#

looks for new subscribers to your service via patreons api

#

and in your user records you have two flags

frozen topaz
#

i need help

green kestrel
#

"has_donated" and "credits"

earnest phoenix
#

ok

green kestrel
#

so has_donated is flipped from false to true if they donate, and you skip over any that already have it set to true

#

with me so far?

frozen topaz
#

when i downloaded vs code it made a auto folder and i cant find it

green kestrel
#

and then, when they donate, credits also has one added

earnest phoenix
#

Ok

hasty sparrow
#

Or use a webhook so you don't have to constantly poll the servers for updates

earnest phoenix
#

I get that part

green kestrel
#

then they can use that credit to apply to a server, you subtract from that credits value but preserve the has_donated = true

earnest phoenix
#

So if user_donated = true give 1 credit basically

elder moss
#

atheonsphantom

green kestrel
#

thats how i'd do it

#

yup, but only once

earnest phoenix
#

Yup

green kestrel
#

otherwise each time your script runs on cron, youll keep giving them more and more credit 😂

#

which would be funny for all of a few minutes 😄

earnest phoenix
#

Could I also do it so I set Tier 1 to give role1 tier2 to give role2

green kestrel
#

yeah the tiers are provided by the api calls

earnest phoenix
#

and then have it to let say give 1 credit to users with role1

#

and 2 credits to users with role2

elder moss
#

what is API...

green kestrel
#

only thing is you should probably store a mapping of user ids that have donated in the past

#

that way if they arent on your server when they donate, or they leave and come back, their roles can be auto assigned if and when they join your guild at a later date

earnest phoenix
#

Is there anyway to test this with patreon without me subscribing to my own bot? xD

green kestrel
#

no

#

they dont have a test server 😩

earnest phoenix
#

😩

elder moss
#

what's api

green kestrel
#

you could make a patreon tier for testing with a minimum donation of a cent

elder moss
#

what's api

earnest phoenix
#

Yeah could do

green kestrel
#

application programming interface @elder moss a way for two systems to talk to each other

earnest phoenix
#

I was also thinking of another system.

frozen topaz
#

is command prompt and node.js command promt diffrent?

elder moss
#

OK thx

#

caps

green kestrel
#

if the internet was a plug and a plug socket, an api would be the electricians hand book that says what voltage and amperage 😄

elder moss
#

lol xD

frozen topaz
#

is command prompt and node.js command promt diffrent?

earnest phoenix
#

Let say I make a big db of a bunch of 'premium' keys.

green kestrel
#

and hand them out?

earnest phoenix
#

this is outside of patreon

#

Yeah basically

green kestrel
#

sure that works

#

BUT

#

be very careful about generation of the keys, they must be cryptographically random

#

e.g. dont just use Math.rand()

earnest phoenix
#

Yeah 16 digit etc and totally random.

#

I was thinking that then I can just have a site made that a user will be able to purchase 1 key

green kestrel
#

use /dev/random or something for them

earnest phoenix
#

and then just do -redeem [key]

green kestrel
#

or openssl

#

yeah

earnest phoenix
#

Alright

green kestrel
#

also you need to protect those keys like they were users financial details

#

even though theyre not

#

they have monetary value and will be a target of hackers

#

so encryption, every layer of security you can on those keys, keep as few on hand as you can get away with

earnest phoenix
#

Yup got it.

#

But I am seeing one possible issue with the keys

green kestrel
#

i wrote a site once for a photography course where they'd give out keys like this on gift cards

#

it was fun, but a pain in the ass to ensure security

earnest phoenix
#

lol yeah

#

but how hard would it be be / long it take to make this key system that I am talking about?

green kestrel
#

not long, depends how quick you code

#

it would take me a couple of days with distractions i think?

earnest phoenix
#

Alright thanks for the info.

green kestrel
#

no problem 🙂

earnest phoenix
#

1 thing

#

So the user now has 1 token on their user ID

#

then can do -redeem premium

#

And the guild they did it in now has premium

green kestrel
#

not neccessarily

earnest phoenix
#

How would I go around making it expire in 30 days?

green kestrel
#

ah

earnest phoenix
#

oh ok

green kestrel
#

set an expiry date on either the key when you generate it in the table

#

so it has to be used within 30 days of generation

#

or set a timestamp in your guild details when its redeemed

#

i'd go with a timestamp in the guild data

earnest phoenix
#

alright

#

What system would you say is easier and better

green kestrel
#

a timestamp in the guild, for sure

earnest phoenix
#

I meant like patreon or key system 😆

green kestrel
#

but you may also want an expiry on the keys anyway, depending.... to stop people hoarding them, also your keys table might want a 'revoked' flag

earnest phoenix
#

Yeah just in case

green kestrel
#

so if someone hacks you, or hacks a user, and steals a key, you can revoke that key, and it will still be in the db so you can log attempts to use it

earnest phoenix
#

Alright

green kestrel
#

a good example of how to do all this is steam's backend for game developers, unfortunately i cant show you that

#

im bound by NDA to not share it 😄

#

but i can tell you how it works, for sure

#

as its pretty generic

earnest phoenix
#

Alright which system you think is better tho for my first premium system?

#

Patreon or this key system

green kestrel
#

hmm i'd go with the key system

#

another reason to go with the key system is, you dont have to use patreon to take the donation

#

patreon take a large percentage of small amounts

#

so if youre asking for say $3 donation for a tier you wont see most of it

earnest phoenix
#

Damn

green kestrel
#

if you used paypal or something instead, youd get a bigger slice of the pie

#

or even stripe, if you can wing it

earnest phoenix
#

I would use paypal but now I would probably need to get a site made.

green kestrel
#

this is why i didnt get around to doing my own donation system properly

#

because i was going to use patreon and someone here pointed out to me that i wouldnt see much of if any of the money lol

#

and i could be bothered to carry on creating it considering nobody wants to donate, they all want freebies

earnest phoenix
#

Yeah I have it the other way around xD

#

People want the premium

#

Since it is a giveaway bot so most people that use it have money to spend on premium

green kestrel
#

ah 🙂 good idea then

#

i had a couple of people who said if there was premium for my bot they'd pay for it

#

so i set up a patreon, without specific attachment to the bot, and promised them something special in return manually if they did become patrons, neither did

#

all talk 😄

earnest phoenix
#

😭

#

That is sad

#

or general

green kestrel
#

hmm, probably an #memes-and-media lol... <mad hatter> CHAAAANGE PLACES!!! </mad hatter> đŸ€Ł

earnest phoenix
#

hlep

frozen topaz
#

when im writing the package name in node.js command prompt it keeps failing

earnest phoenix
#

what

#

can you give me an example

#

im new js

tight plinth
#

pichu stats

#

oh f-

#

wrong chan

earnest phoenix
#

@earnest phoenix what kind of help do you need?

tight plinth
#

and apparently nothing happens

#

the bot still works

turbid bough
#

you are trying to do something that hinders the sharding manager to spawn more shards

tight plinth
#

idk what

#

and apparently bot activity isnt set for one of the shard

#

but is for the other

earnest phoenix
#

@earnest phoenix do you fixed it?

marble juniper
#

@earnest phoenix you can not do '${bot.user.username}' because ' and " don't allow template literals so you need to do inside ``

#
"This text has " + variable + " cookies"
`This text has ${variable}`
#

this is how you use variables in strings with either " and ' or `

hasty sparrow
#

Forgot the + in your first example

earnest phoenix
#

does anyone know why when i host mine on heroku it works but then it goes down an hour later

#

make that a few minutes

marble juniper
#

yes

#

Im stupid

#

I forgot the plus

sacred mountain
#

Is there a way for a bot to send a message if it doesn’t have the required perms? I’ve been looking online but can’t find an answer

hasty sparrow
#

Yes

sacred mountain
#

How

marble juniper
#

get the member object of the bot

#

get the permissions

#

then check if it includes send messages

frozen topaz
#

IM SOOO ANGRY

#

I WAS CODING MY BOT AND THEN MY CODING GOT GLITCHED

marble juniper
#

ok

frozen topaz
#

and i cant get it back

#

-bots

gilded plankBOT
#

tickNo This user has no bots

marble juniper
#

wdym by "glitched"

frozen topaz
#

no like

marble juniper
#

for bot commands

frozen topaz
#

it just randomly zoomed in

#

ok

#

it just randomly zoomed in

storm bluff
#
    models.guilds.findOne({guild: message.guild.id},
      (err ,guild)=>{
        if(err) console.log(err)
        if(!guild) {

          var newguild = new models.guilds(mconfig.Settings.guilds(message.guild.id))

          newguild.save();
        }
      })
});```
earnest phoenix
#

then zoom out

marble juniper
#

bruh

frozen topaz
#

and then i accidentally click remove page rather them minimise

earnest phoenix
#

that's a you problem

mossy vine
#

@storm bluff you dont get a message in guildCreate 200iq

frozen topaz
#

i know

earnest phoenix
#

why aren't you using a proper IDE

frozen topaz
#

idk

storm bluff
#

@mossy vine guild and message not work

frozen topaz
#

i know how to follow a yt tutorial

marble juniper
#

was that sublime or what

frozen topaz
#

now*

marble juniper
#

or notepad

storm bluff
#

if i put guild not and message not work @mossy vine

mossy vine
#

then you should also know that yt tutorials are garbage

marble juniper
#

yes

#

don't use yt tutorials

frozen topaz
#

i dont really care

knotty steeple
#

guildCreate doesnt provide a message object

sacred mountain
#

I have a problem. I tried to make a function where the bots status updates whenever it joined a new guild but it doesn’t seem to work... the code is below:

#
    console.log('BOT SUCCESSFULLY STARTED');
    bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})

bot.on("guildCreate", () => {
    bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})```
knotty steeple
#

it provides a guild object

frozen topaz
#

yt tutorials arent that bad

knotty steeple
#

they are shit

#

and outdated

frozen topaz
#

no

knotty steeple
#

yea they are

marble juniper
#

yes they are

frozen topaz
#

no

knotty steeple
#

find me a up to date tutorial right now

#

oh yea u fucking cant? thats what i thought

frozen topaz
#

ok calm down

knotty steeple
#

even if u do they are most likely bad

#

u dont learn how to code from yt tutorials

mossy vine
#

are you srsly gonna argue about shitty tutorials with people who know what theyre talking about omegalul

frozen topaz
#

why are you being so mean?#

marble juniper
#

why repost the same twice

earnest phoenix
knotty steeple
#

cyber

#

shush

sacred mountain
#

Is someone able to help me

frozen topaz
#

im dming a moderator

knotty steeple
#

lmao

marble juniper
#

lmfao

knotty steeple
#

hi whats ur problem

sacred mountain
#

I have a problem. I tried to make a function where the bots status updates whenever it joined a new guild but it doesn’t seem to work... the code is below:

    console.log('BOT SUCCESSFULLY STARTED');
    bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})

bot.on("guildCreate", () => {
    bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})```
marble juniper
#

this can't get any worse

earnest phoenix
#

this is the 2020 equivalent of calling 911 on someone shit talking on xbox live

marble juniper
#

@sacred mountain any errors?

knotty steeple
sacred mountain
#

@marble juniper dont think so

marble juniper
#

k

sacred mountain
#

lemme check again

mossy vine
#

except we shouldnt be talking shit but directing them to better resources

knotty steeple
#

yes

#

â„ąïž

#

sololearn

storm bluff
mossy vine
#

cool

knotty steeple
#

i see mongoose

#

im gone

marble juniper
#

advice: don't copy paste code from random discord.js guides try to understand it

earnest phoenix
#

mega advice: read the text above the shiny colorful code blocks

storm bluff
#

@knotty steeple yes mongoose

knotty steeple
#

advice: dont copy paste

marble juniper
#

advice: use brain

frozen topaz
#

but i can still use yt tutorials

#

i only started coding yesterday

#

and im just trying to learn the basics

marble juniper
#

this will be one hell of a ride

#

trust me

#

I mean you can use yt tutorials if you want but I dont encourage you to watch them

knotty steeple
#

a better place

mossy vine
#

sololearn only teaches syntax, not logic

frozen topaz
#

i do javascript

knotty steeple
mossy vine
#

and guess what u need for programming

#

thats right

#

🎉 logic 🎉

knotty steeple
#

thats like the only 2 sites i know

marble juniper
#

just learn js before making a bot with js

frozen topaz
#

ok

knotty steeple
#

i self teach myself most languages

marble juniper
#

same

knotty steeple
sacred mountain
#

Hi. Is there a way to send a message if the bot doesn’t have the right perms (also like if it doesn’t hav perms to send messages, send a dm saying that)

#

I can’t find any info on it online

knotty steeple
#

the docsâ„ąïž

marble juniper
#
  1. why delete that and repost it
  2. to send a dm do message.author.send()
sacred mountain
#

But like how do I check it it has right perms

pale vessel
#

you guys have it easy while we have to fetch the dm channel

marble juniper
#

read

#

the

#

docs

#

member objects

knotty steeple
#

flazepe what lib do u use

sacred mountain
#

ok

pale vessel
#

guess

knotty steeple
#

idk eris

jovial nexus
#

Hi, how can i detect when a person joins a voice channel.

marble juniper
#

pls not eris

pale vessel
#

why not?

knotty steeple
#

there is an event on voice channel join

#

i t h i n k

marble juniper
#

read the docs

pale vessel
#

read the doctors

marble juniper
pine aspen
#

Hey.

#

Do you use

#

role.cache.get?

marble juniper
#

Hi

pine aspen
#

DJS 12

pale vessel
#

oh yes

#

roles*

knotty steeple
#

even roles are cached

marble juniper
#

yes

pine aspen
#

I'm upgrading so V12

#

It's all too confusing.

pale vessel
#

upgrade to 0.12.0

marble juniper
#

haha yes

pine aspen
#

Degrade to 11.5.1

knotty steeple
#

in discordcr i have to do mostly everything manual

#

thats what it says anyway

pine aspen
#

Ok

#

Thanks for the help.

marble juniper
#

np

pale vessel
knotty steeple
#

^ very useful

marble juniper
#

^

pine aspen
#

Yep.

knotty steeple
#

now how tf do i filter an array in crystal

pine aspen
#

I'll take a read.

#

Ty y'all.

marble juniper
#

@knotty steeple u filter it

knotty steeple
#

ok ill just assume there isnt gonna be any more files

#

cuz i somehow cant find the function in crystal docs lmao

sacred mountain
#

Can’t find what I’m looking for on the docs.... how do I check if the bot has a certain permission?

earnest phoenix
#

in which library

modest maple
#

hes js if i rememebr

sacred mountain
#

Oh hi Yh I am

pale vessel
#

read the docs correctly smh

sacred mountain
#

I did

marble juniper
#

member objects

#

they have a permission property

sacred mountain
#

I searched that

pale vessel
#

property of guildmember

marble juniper
#

yes

pale vessel
#

can you not read

#

sorry if i sound harsh

sacred mountain
#

I know .haspermissions

marble juniper
#

but

sacred mountain
#

It’s just how do u do it for a bot

pale vessel
#

omg

sacred mountain
#

I only know how to do it for a member

marble juniper
#

omfg

#

just

#

get the member object of the bot

pale vessel
#

for client user, it's guild#me, for a bot, just do the same

#

a bot is a member too ya know

sacred mountain
#

if(guild.me.hasPermission("SEND_MESSAGES")?

earnest phoenix
#

@sacred mountain
if (message.guild.me.hasPermission())
Or
if (message.guild.member(<client>.user).hasPermission())

pale vessel
#

try. it. and. see

earnest phoenix
#

Jesus

pale vessel
#

don't ask us

marble juniper
pale vessel
#

also, array works too

#

so no need for ||

#

unless you're on eris

earnest phoenix
#

why doesnt my bot turn on again if i use heroku

#

it went offline once now it doesnt let me turn it on longer then 5 minutes

pale vessel
#

tldr; don't use heroku?

earnest phoenix
#

i cant use the paid ones

quartz kindle
#

check your logs, there should be a reason for crashing after 5 mins

#

an error or something

earnest phoenix
#
if(args[0] === "reset") return connection.dispatcher.setVolume(100/100).then(message.channel.send(reset))

(node:11353) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined
#

um
i dont get whats wrong with then

#

What do u want to do?

#

set the volume to 100/100 and then send a message

#

hlep

modest maple
#

congrats u managed to show everything but the actual error

earnest phoenix
#

đŸ€Šâ€â™€ïž

#

@quartz kindle therei snt

#

my token is correct

#

why

#

there is only "Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect..."

fleet chasm
#

hyro, what are you trying to do, and whats the error

earnest phoenix
#

Show full error @earnest phoenix

#

Oh

#

my token got leaked so it closed off

fleet chasm
#

zoomeyes

earnest phoenix
#

i found

#

np

#

lol

fleet chasm
#

oh ok

earnest phoenix
#

lol

#
if(args[0] === "reset") return connection.dispatcher.setVolume(100/100).then(message.channel.send(reset))

(node:11353) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined

@earnest phoenix

#

nvm thats not the reason

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.on(eventName, (...args) => eventFunc.run(client, ...args));
  });
});``` Is this how you do an event handler? d.js v12
earnest phoenix
#

the token was out of date but it wont go online for longer than 10 seconds

tight plinth
#

Try it and see

golden condor
#

kk

#

kk

earnest phoenix
#

okay- can someone explain to me why whenever my bot turns on it decides to change its token..

grizzled raven
#

if you set an id property in a schema, will mongoose's _id id getter override it?

uneven lichen
#

does anyone know how to finish a whole script in discord js?

grizzled raven
#

return;

#

now if you set an id property in a schema, will mongoose's _id id getter override it?

uneven lichen
#

ok thanks

earnest phoenix
#

i need a lot of help-

#

my bots token is changing every damn second

#

can someone explain why .then wont work for me?

#
if(args[0] === "reset") return connection.dispatcher.setVolume(100/100).then(message.channel.send(reset))

(node:11353) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined

@earnest phoenix

golden condor
#

What conetxt

tight plinth
#

@earnest phoenix set Volume returns undefined

#

It does smth, but it doesn't return smth

earnest phoenix
#

confused af

golden condor
#

@earnest phoenix it is this
connection.dispatcher.setVolumeLogarithmic(100 / 100);

tight plinth
#

Just remove the .then

earnest phoenix
#

but i want it to send a message after tho

pale vessel
#

@earnest phoenix that's normal, you should be able to use old ones until you regenerate it

golden condor
#

Use what I said

earnest phoenix
#

what is Logarithmic

golden condor
#

.setVolume isn't just it on it's own

earnest phoenix
#

?

tight plinth
#

Remove the .then,keep message.channel.send

golden condor
#

The same thing

#

Try that with .then

quartz kindle
#

@earnest phoenix tokens are made of two components, a timestamp and the actual code. when you view your token in the discord developers website, the token will be generated with the timestamp of the current date, so every time you reload the page, the token will look different because the timestamp is different, but the actual code component doesnt change unless you regenerate the token. the code part of the token is whats actually important, it doesnt matter if the timestamp part of it changes, it works the same

earnest phoenix
#

you both are giving different options

#

let me try one first

golden condor
#

Okie

tight plinth
#

Both works

earnest phoenix
#

Lunmap

#

i used your way and it worked

#

thanks

#

but im still confused tho

tight plinth
#

Nice

#

Y r u confused

earnest phoenix
#

becuase .then didnt work
im confused on why

#

oh

#

but then why doesnt it boot up

quartz kindle
#

likely because you have something wrong in your code

#

and there should be an error telling you that

earnest phoenix
#

theres no errors

#

and it was working just fine and i havent updated it

#

how can i stop the connection?

tight plinth
#

The set Volume function does his job, but u can't .then it beacause it returns undefined

earnest phoenix
#

oh ok

quartz kindle
tight plinth
#

And u can't .then something not defined

earnest phoenix
#

how can i stop connection?
becuase when i play a song, it will say its playing the old song and the new one

#

so i want to stop the current connection playing

#

its staying on for longer

#

and then play the new one

tight plinth
#

Connection.dispatcher.end()

quartz kindle
#

@earnest phoenix you need to figure out where the errors go to, there is always an error somewhere, otherwise you're blindfolded

tight plinth
#

It will trigger the "end" or "finish" event depending on your djs version

earnest phoenix
#

it works now

#

it didnt work like i wanted it to
when i play a song, it will say now playing and song name
but when i play another song, it will say now playing oldsongname and then now playing newsongname

tight plinth
#

Show your play command code

earnest phoenix
#
    if(command === "play") {
      
      let nosong = new Discord.RichEmbed()
      .setDescription("Please specify a song name.")
      .setColor(config.Red)
      
      let vc1 = new Discord.RichEmbed()
      .setDescription("You are not in a voice channel.")
      .setColor(config.Red)
      
      let noresults = new Discord.RichEmbed()
      .setDescription("No results found.")
      .setColor(config.Red)
      
      if(!args.join(" ")) return message.channel.send(nosong)
    if(!message.member.voiceChannel) return message.channel.send(vc1)
      await message.member.voiceChannel.join()
    const search = require("yt-search")
    const ops = require("ops")
    const ytdl = require("ytdl-core")
    search(args.join(' '), function(err, res) {
      if(err) return message.channel.send("ERROR")
      let videos = res.videos.slice(0, 10)
      
      let resp = ''
      for (var i in videos) {
        resp += `**[${parseInt(i)+1}]:** \`${videos[i].title}\`\n`
      }
      if(res.videos.length == 0) return message.channel.send(noresults)
      resp += `\nChoose a number between \`1-${videos.length}\``
      message.channel.send(resp)
      const filter = m => !isNaN(m.content) && m.content < videos.length+1 && m.content > 0
       const collector = message.channel.createMessageCollector(filter)
       collector.videos = videos
      collector.on("collect", async function(m) {
      
        let video = videos[m.content-1];
        let connection = await message.member.voiceChannel.join();
        connection.playStream(ytdl(video.url))
        
        let nowplaying = new Discord.RichEmbed()
        .setDescription(`Now playing ${video.title}`)
        .setColor(config.Green)
        
        message.channel.send(nowplaying)

        
    })
  })}```
#

im new to it so i first used a tutorial lmao

tight plinth
#

You don't handle what happens if a song ends

earnest phoenix
#

so like
connection.on("end")?

pale vessel
#

not quite

#

you need to define the dispatcher

tight plinth
#

Connection.play... .on('end', () => {
\here you take the song list and remove the first element and retrigger the play function
})

earnest phoenix
#

i can use connection.dispatcher tho

pale vessel
#

yes. connection.dispatcher.on("end", () => {})

#

lumap's answer is better though

earnest phoenix
#

it will still not work
it will send that it stopped playing and disconnect
then the same thing
oldsong is playing, then newsong is playing

#

if a song is currently playing and i try to play another one, it will send that the old one is playing, and then the new one

pale vessel
#

what's your end event code?

earnest phoenix
#
 connection.dispatcher.on("end", () => {
          message.channel.send(stoppedplaying).then(message.guild.me.voiceChannel.leave())
        })```
#

ik its wrong but i have no idea how to fix it so it stops the last song and then play the new one

pale vessel
#

do you even have a queue

earnest phoenix
#

no

#

uh my bot still wont turn it

#

on again

lyric mountain
#

have you checked your log?

pale vessel
#

maybe something's wrong with the code if it's not outputting anything

storm bluff
#

// A pretty useful method to create a delay without blocking the whole script.
const wait = require("util").promisify(setTimeout);

client.on("ready", () => {
  // "ready" isn't really ready. We need to wait a spell.
  wait(1000);

  // Load all invites for all guilds and save them to the cache.
  client.guilds.cache.forEach(g => {
    g.fetchInvites().then(guildInvites => {
      invites[g.id] = guildInvites;
    });
  });
});```
why??
quartz hill
#

Bot need Create Instant Invite permission

knotty steeple
#

^

#

also whatever ur trying to do is against tos without the consent of the owner

#

if ur trying to make invites for all guilds

#

thats what im getting from ur code

quartz hill
#

Trying to get the invitation link of all servers. I guess.

#

You can add this permission in the bot invitation link. But server owners do not have to open this permission. Therefore, it will be useful to use the try catch structure separately.

#

It would not be good for the bot to collapse only because of someone's did not allow permission.

storm bluff
#

@quartz hill have administrator

quartz hill
#

Not all server owners can grant admin authority.

storm bluff
#

oh

quartz hill
#

You can edit the permissions while taking the bot to the server.

#

Especially in bots with admin privileges, server owners revoke this permission.

knotty steeple
#

or just

#

dont randomly make invites?

#

because u have the perm doesnt mean u can abuse it or just use it completely any way you want

quartz hill
#

Use try catch. Try to give all necessary permissions except admin permission.

knotty steeple
#

thats

#

not the point

quartz hill
#

If a server owner already allows it, I think it's okay to use it.

#

Of course, do not abuse anyway.

nimble escarp
#

Would anyone be able to help with sharding in discord.js with typescript?
Currently when I create a new ShardingManager and point it to a .ts file it throws an error saying SyntaxError: Cannot use import statement outside a module.

restive furnace
#

"Cannot use import statement outside a module"

mortal flare
#

I would like to ask, how do I fix the msg.guild.roles.fetch(role => role.name === "Blessing of Cuteness"); which returns me some discord API error mssing permission.

quartz kindle
#

where did you get that from?

#

roles.fetch fetches a role from the API using a role ID

#

or all roles if left empty

#

it doesnt take a function as a parameter

#

in any case you would never need to use that because roles are all cached by default

gaunt blade
#

@mortal flare I think you're looking for .some or .filter maybe

quartz kindle
#

or find

restive furnace
#

^

gaunt blade
#

yeah

quartz kindle
#

in any case, better explain what you're trying to accomplish than asking how to fix X, just to make sure X isnt the wrong thing to do regardless

gaunt blade
#

.find(thestuffheputinthe.fetch)

maiden mauve
#

MessageReaction object has like 1,000,000 undefined objects inside of it

#

change my mind

#

😭

quartz kindle
#

wat

maiden mauve
#

Trying to manually do reaction-based menus

#

edit message with new richembed

gaunt blade
#

oh that

maiden mauve
#

It's just difficult to find the objects that have the powerful methods

gaunt blade
#

I've done that before, ur using awaitReactions right?

maiden mauve
#

Nah, I gave up on that method since I wanted it to be long term

#

I'm doing it off client messageReactionAdd

gaunt blade
#

u can make a loop function lol

#

w/a timeout

quartz kindle
#

my menu uses ReactionAdd as well

gaunt blade
#

mine doesnt

maiden mauve
#

but the problem I'm at is

#

the variables reaction and user correlate to a "MessageReaction" object

#

that only removes my bots reaction, not the human

quartz kindle
#

you need to fetch the message

gaunt blade
#

awaitReactions is easier than using that event tbh

maiden mauve
#

oh, like redefine the message and use the better functions?

quartz kindle
#

you're trying to make it work long term right? ie: never expire

maiden mauve
#

yeah

quartz kindle
#

old messages will not be cached

#

you need to make sure the message is available

maiden mauve
#

well, it's just a help menu its not the end of the world if it expires

mint cypress
#

Hey If i Submitted my bot should be to many users used ?

quartz kindle
#

so you need to fetch the message first

maiden mauve
#

I'm just getting rid of spam and trying to split up the info given

quartz kindle
#

@mint cypress yes, it should be a public bot that anyone can use

mint cypress
#

Ok Thx And How Many ?

quartz kindle
#

@maiden mauve my reaction menu works like this:
on reactionAdd
if reaction = one of reactions that the menu supports
-> fetch message
-> -> if message author = my bot
-> -> -> message.edit

nimble escarp
#

@restive furnace but you can use import statements outside of modules pepeWTF

quartz kindle
#

@mint cypress how many what?

maiden mauve
#

Thanks Tim thats the pseudo I'm going for

#

fetching the message has been a task

#

to verify its the correct menu

nimble escarp
#

I'm basically doing "import" on L1.

maiden mauve
#

the message itself seems to be an object of the reaction but it's not

mint cypress
#

should usere used

#

*users

maiden mauve
quartz kindle
#

if you enable partials, you will get a partial message

mint cypress
#

why ?

quartz kindle
#

so you need to fetch the message by its id

maiden mauve
#

Ah, will that have significant impact to the rest of bot though?

#

When I read that stuff it said all or nothing

quartz kindle
#

its an api request, so it will impact your rate limits, but shouldnt be a problem

maiden mauve
#

Gotcha ty

quartz kindle
#

thats why you should make all possible checks before you fetch it

maiden mauve
#

yeah I've just been inching through the problem for fun

quartz kindle
#

ie: if the reaction is one of the possible reactions your menu uses, to avoid fetching irrelevant messages

#

to help with this task, my menu uses custom emojis only

maiden mauve
#

theoretically, a user could be a dork and try to load menus off reacting to random things

quartz kindle
#

yeah

maiden mauve
#

I validate that it's a DM and one of the two arrow emojis

#

but i need to further validate which embed is currently loaded

#

im guessing ill get that from message

quartz kindle
#

yes, you can get it from the message after fetching it

#

i put an index in the embed footer to track it

maiden mauve
#

oh thats a little smarter than the title

mortal flare
#

in any case, better explain what you're trying to accomplish than asking how to fix X, just to make sure X isnt the wrong thing to do regardless
@quartz kindle okay what i was trying to achieve is i am trying to look for a specific role by name and assign it to someone

quartz kindle
#

@mortal flare then yes, the correct thing is guild.roles.find(role => role.name === "yourname") in v11 or guild.roles.cache.find(role => role.name === "yourname") in v12

#

@maiden mauve also, you dont need to remove the user reaction every time they react

#

you can simply listen to reactionRemove events as well

#

its a little more efficient that way

maiden mauve
#

I was approaching the "keep emojis in order" issue

#

but if I left Page 1 go back to Page 6

#

so you basically double down on both events

quartz kindle
#

i assign the same function to both events

#

so adding or removing does the same thing

maiden mauve
#
if((reaction.emoji.name === ':arrow_forward:') && reaction.count > 1) {
        await reaction.message.edit(embedP1);
#

the inverse would be count < 2 I suppose

quartz kindle
#

you dont need to count

#

just ignore reactions made by bots

maiden mauve
#

oh yeah I guess it doesnt matter

#

I tried using the bot boolean for that

#

but again I didn't have the right object

#

the message is always owned by the bot

mortal flare
#

@mortal flare then yes, the correct thing is guild.roles.find(role => role.name === "yourname") in v11 or guild.roles.cache.find(role => role.name === "yourname") in v12
@quartz kindle .find function is undefined, I am, using v 12.2

maiden mauve
#

but the reaction itself has an identity user right?

quartz kindle
#

yes, the user who reacted is in the user parameter, not in the reaction

maiden mauve
#

☑

quartz kindle
#

@mortal flare show code

maiden mauve
#

thanks for holding down the fort, Tim always helpful without feeding XD

quartz kindle
#

:3

mortal flare
#

` let {cache} = msg.guild.roles;
let newRole = cache.find(role => role.name === "Blessing of Cuteness");

        if(!newRole) 
            return msg.channel.send(`cannot find role: ${newRole} in this server\n please make sure that the role exist in the server`); 
        else{
            if(msg.member.roles.cache.has(newRole.id)){
                msg.channel.send(`@${person.user.tag} has already been blessed with ${newRole.name}\ndon't be greedy.`);
            } else {
                let time = args[2];
                if(!time){
                    msg.channel.send("please specify time in the argument");
                }

                person.roles.add(newRole.id);
                msg.channel.send(`@${person.user.tag} has been blessed with ${newRole.name} for ${ms(ms(time))} (or until this bot dies).`);

                setTimeout(function(){
                    person.roles.remove(newRole.id);
                    msg.channel.send(`@${person.user.tag}'s blessing has expired.`);
                }, ms(time));
            }
        }

`

earnest phoenix
#

how i do randomtext?

quartz kindle
#

```js
code here
```

#

@mortal flare

earnest phoenix
quartz kindle
#

@earnest phoenix your bot is not verified

#

you need to wait for verification

earnest phoenix
#

click on the link

#

my bot has been deleted ??

mortal flare
#
            let newRole = cache.find(role => role.name === "Blessing of Cuteness");

            if(!newRole) 
                return msg.channel.send(`cannot find role: ${newRole} in this server\n please make sure that the role exist in the server`); 
            else{
                if(msg.member.roles.cache.has(newRole.id)){
                    msg.channel.send(`@${person.user.tag} has already been blessed with ${newRole.name}\ndon't be greedy.`);
                } else {
                    let time = args[2];
                    if(!time){
                        msg.channel.send("please specify time in the argument");
                    }

                    person.roles.add(newRole.id);
                    msg.channel.send(`@${person.user.tag} has been blessed with ${newRole.name} for ${ms(ms(time))} (or until this bot dies).`);

                    setTimeout(function(){
                        person.roles.remove(newRole.id);
                        msg.channel.send(`@${person.user.tag}'s blessing has expired.`);
                    }, ms(time));
                }
            }
#

@quartz kindle this is the only way I manage to get find() function working

quartz kindle
#

@earnest phoenix when did you add your bot?

slender thistle
earnest phoenix
#

Yes it's ok

haughty agate
#

Hello.
I'm trying to play music on voice channel using ytdl.
I have imported ytdl, opusscript, and ffmpeg is added into windows global variables.

connection.play(ytdl("https://www.youtube.com/watch?v=GG5cE14G2Gg", {filter: 'audioonly'}));

And I'm getting exception from opusscript:

var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[k[...] (looong line)

TypeError: Cannot convert "null" to int
    at Object.toWireType (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\opusscript\build\opusscript_native_wasm.js:8:47113)
    at OpusScriptHandler$_encode [as _encode] (eval at new_ (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\opusscript\build\opusscript_native_wasm.js:8:36904), <anonymous>:11:26)
    at OpusScript.encode (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\opusscript\index.js:69:28)
    at Encoder._encode (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\prism-media\src\opus\Opus.js:55:25)
    at Encoder._transform (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\prism-media\src\opus\Opus.js:138:30)
    at Encoder.Transform._read (_stream_transform.js:189:10)
    at Encoder.Transform._write (_stream_transform.js:177:12)
    at doWrite (_stream_writable.js:431:12)
    at writeOrBuffer (_stream_writable.js:415:5)
    at Encoder.Writable.write (_stream_writable.js:305:11)
    at VolumeTransformer.ondata (_stream_readable.js:727:22)
    at VolumeTransformer.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    [...]
    at writeOrBuffer (_stream_writable.js:415:5)
    at VolumeTransformer.Writable.write (_stream_writable.js:305:11)

Process finished with exit code 7

@discordjs/opus and node-opus dont work either.
What should I do?
thanks

earnest phoenix
#

how i do randomtext?