#development

1 messages · Page 1354 of 1

abstract coyote
#

ye ik c:

rotund vale
#

What's the code to put client.users.cache.size in my bot's custom status

carmine summit
#

@abstract coyote lemme guess... Sharded?

rotund vale
#

I tried once, it didn't go so well

earnest phoenix
#

What's the code to put client.users.cache.size in my bot's custom status
@rotund vale there is no exact code for anything

#

send yours

#

we'll help debug it

carmine summit
abstract perch
#

I see wait

earnest phoenix
#

@carmine summit send code mate

rocky hearth
#

Can I populate a field, after exec() is run?

SomeModal
   .findOne({blalala})
   .exec()
   .then(doc => doc.populate('some-ref'));

fluid basin
#

@carmine summit stop posting the same error without any context or code

abstract coyote
#

@abstract coyote lemme guess... Sharded?
sorry? I am not sure what sharding stands for here :/

carmine summit
#

I didnt even know

#

how that thing

#

just popped

earnest phoenix
#

sorry? I am not sure what sharding stands for here :/
@abstract coyote he's asking if you're trying to get the users/guilds amount for a sharded bot or not

fluid basin
#

I don't think doc has a populate method @rocky hearth

earnest phoenix
#

@carmine summit send code pls

abstract coyote
#

nah its not sharded

abstract perch
#

omg, lol

#

fixed it

earnest phoenix
#

then client.users.cache.size

abstract perch
#

I am stoopid

earnest phoenix
#

replace users with guilds if.. you know what I'll say

abstract perch
fluid basin
#

yes @abstract perch

#

please debug your code the next time

abstract perch
#

Yes, I am sorry! 🙂

abstract coyote
earnest phoenix
#

@abstract coyote everyone ain't cached

abstract coyote
#

o

#

hmph

#

XD

earnest phoenix
#

d.js only stores stuff in cache if the thing interacts with the bot in some way

abstract coyote
#

oh okay

carmine summit
#

uh

fluid basin
#

well same story if you don't have guild member intents

waxen tinsel
#

yeah ik i was just harassing

#

I still have not even updated to intents

fluid basin
#

I didnt even know
@carmine summit since I see you're in the discord bugs server, you should know that we can't really help you with something that is not easily reproducable

quartz kindle
#

@abstract coyote you can use guild.memberCount

#

to get the total number of members in a specific guild, regardless of caching

abstract coyote
#

yeah

rotund vale
#

@earnest phoenix btw I found the code for client.users.cache.size in bot status

waxen tinsel
#

"found"

#

bruh

stoic girder
#

I have a JSON list of hundreds of games formatted like this:

{
    "cod1": "Call of Duty 1",
    "cod2": "Call of Duty 2",
}

What would be the best way to paginate those?

I saw a few pagination node packages for Discord.js but all rely on embeds.
There should be a better way than making a new embed every 10th game in a for loop?

If you answer, please ping me as I come and leave frequently.

rotund vale
#

I tried 3 times ok

#

None of them worked

waxen tinsel
#

its like a line that would be ez to make urself if you checked the docs tbh lol

sturdy star
#

what's the problem in here? (Language: JavaScript)

    if(!message.member.hasPermission('BAN_MEMBERS')) 
        message.channel.send("Missing Permissions!");
    else {
        let bannedMember = await message.guild.members.ban(args);
        if(bannedMember){

        try {
            console.log(bannedMember.tag + " is banned.");
            message.channel.send (`${bannedMember} has been banned!`)
        }
            catch(err) {
            console.log(err);
        }
    }
}
}

module.exports.config = {
    name: "ban",
    description: "Bans a Users",
    usage: "b!ban",
    accessableby: "Admins",
    aliases: []
}```
earnest phoenix
#

if i do fs.readFileSync("/path/to/some/file/without/extension") will it return the data inside the file as a normal string or smth else?

sturdy star
#

it does nothing when i write b!ban

fluid basin
#

@sturdy star please color-code your code, add js after the ```

earnest phoenix
#

I have a JSON list of hundreds of games formatted like this:

{
"cod1": "Call of Duty 1",
"cod2": "Call of Duty 2",
}
🙏 Please call a doctor 🙏

sturdy star
#

how to color-code?

#

im just new to coding

fluid basin
#

```js
my code
```

earnest phoenix
#

im just new to coding
@sturdy star then it's not a good idea to start work on a bot right now

stoic girder
#

@earnest phoenix Regarding the format? I can change it, I guess. What about an array of objects that look like this { code: "cod", name: "Call of Duty" }?

sturdy star
#

i mean like im only 5 days into coding

earnest phoenix
#

@earnest phoenix Regarding the format?
@stoic girder no I'm talking about why the fuck are you storing a huge list of games

stoic girder
#

ahh, it's from gamedig node.js library

#

list of supported games

#

even worse, they store it in a badly(?) formatted txt file

#

i parsed it and converted into json

rocky hearth
#

I don't think doc has a populate method @rocky hearth
@fluid basin There IS a populate method on document

fluid basin
#

did you check?

rocky hearth
#

yes

fluid basin
earnest phoenix
#

why does res.send make my browser download the file instead of parse it as HTML
express.js

fluid basin
#

if there isn't a document

#

you can't populate

#

¯_(ツ)_/¯

rocky hearth
#

what??

#

u mean to check for nulls before?

boreal iron
#

why does res.send make my browser download the file instead of parse it as HTML
express.js
@earnest phoenix Wrong content-type maybe?

earnest phoenix
#

i set is as text/html

#
res.set("Content-Type","text/html");

res.send(`stuff`);
carmine summit
#

welp

boreal iron
#

hmm ok, weird

carmine summit
#

I fucked everything up and wiped half of my servers my bot is in

boreal iron
#

Just try plain/text to test @earnest phoenix

carmine summit
#

stupid verification

rotund vale
#

I fucked everything up and wiped half of my servers my bot is in
@carmine summit oof what happened?

carmine summit
#

i was forced to code a thing where the bot will check weekly for activeness

#

each command run = +1 activeness

rocky hearth
#

Well that's so sad 😦

carmine summit
#

so what happened is, instead of db.delete('activeness.'+ guild.id), What I accidentally coded is: db.delete('activeness')

#

which deletes the whole array

#

and leaves no data behind

earnest phoenix
#
res.set("Content-type","plain/text");

res.set("Content-Type","plain/text");

testing if the problem is with the header name

carmine summit
#

then I stupidly ran the ?purge command without knowing waht is happening

#

so yeah...

pale vessel
#

header name should be case insensitive

carmine summit
#

tf

pale vessel
#

so it doesn't matter

earnest phoenix
#

used axios to send a request to the server and it shows this:

headers: {
content-type: "application/octet-stream"
}
pale vessel
#

wtf

#

content-type:

#

how is that even valid

earnest phoenix
#

yeah

#

minus sign

pale vessel
#

should be "content-type":

earnest phoenix
pale vessel
#

oh shit

#

you changed your pack and enchanted the apple

earnest phoenix
#

axios is nuts

faint prism
#

gotta be valid JSON

pale vessel
#

not json but just a js object in general

earnest phoenix
#

how is axios returning that

#

HOW

pale vessel
#

oh

#

chrome formatted that you dingus

earnest phoenix
#

lmao

drifting wedge
#

for dpy

#

but i didnt get it

#

how would i like find what shard the bot is on?

pale vessel
#

you're using AutoShardedClient, right?

drifting wedge
#

yes

subtle kiln
#

Hello!
I was wondering: using Discord.js we always have to choose between "resolve" functions that return an object (Guild, Member, User, Message) or the "fetch" functions that return the same thing but async (with a Promise). What's the difference? Does the "resolve" functions use only the cache and are not truth-worthy?

pale vessel
#

resolve uses the cache. fetch is async since it tries to look in the cache first. if not found, it will try to fetch it from the API

#

fetch is better to use if you're unsure whether something you're looking for is cached or not

earnest phoenix
#

the status code was 304 lemme try reloading the page with clear cache and hard reloard

#
Resource interpreted as Document but transferred with MIME type application/octet-stream

WHY

faint prism
#

Maybe it doesn't support that MIME type

#

And defaults to document

earnest phoenix
#

thonk

subtle kiln
#

fetch is better to use if you're unsure whether something you're looking for is cached or not
@pale vessel thanks. Some "fetch" functions seam to not be related to cache, they don't have the cache or force boolean parameters. Example UserManager.fetch vs GuildMemberManager.fetch Do you know why?

pale vessel
#

both of them have it

earnest phoenix
#

it's my CDN acting up bruh

subtle kiln
#

both of them have it
@pale vessel Yes my bad. It's just that these flags are given in the option parameter for the GuildMemberManager.fetch function

feral arch
#

Hi n.n

#

I have problems displaying messages on embed with no breakline ):
It shows like this

#

I want that commands appeared just under the category, not after that breakline

#

and the breakline would have to be below commands description to separate categories

quartz kindle
#

dont add a field for every single command

#

use a field for a category, then use the field data for the commands

boreal iron
#

@earnest phoenix I'm back... did plain/text still open a file stream?

pale vessel
#

what was working for weeks

earnest phoenix
dense patio
#

can you get the number of users in each shard without the server members intent? (discord.js v12)

pale vessel
#

yis

dense patio
#

how

pale vessel
#

fetchClientValues?

dense patio
#

oh i see thanks

#

can you not access client.users.cache without the intent

#

same with guilds

pale vessel
#

you can, all of them

#

this only affects when receiving them

dense patio
#

hm

pale vessel
#

if you don't have the intent, you can't request guild members

#

so it could be empty but still accessible

grizzled raven
#

if you have a bot with say 11k guilds, using a sharding manager is better than internal sharding, right?

pale vessel
#

yea

dense patio
#

i've just restarted my bot for the first time since the new enforcement, and i'm getting the same error as with my other (non verified) bots, which was fixed by just enabling the intents on the application page; but i can't very well do that for the verified one

pale vessel
#

kurasuta is a good one

#

i've just restarted my bot for the first time since the new enforcement, and i'm getting the same error as with my other (non verified) bots, which was fixed by just enabling the intents on the application page; but i can't very well do that for the verified one
@dense patio you can, contact https://dis.gd/support

dense patio
#

agh

grizzled raven
#

okay yeah maybe i shouldn't still be internal sharding KEKW

dense patio
#

this is gonna take forever

#

thanks for your help

grizzled raven
#

what makes kurasuta good?

pale vessel
#

all good, why didn't you request for it in the first place in the application?

dense patio
#

didn't think i'd need it

#

still don't know what's causing the issue

#

i didn't think i'd need the intents for anything

pale vessel
#

@grizzled raven i heard it handles everything better than discord.js's shardingmanager

#

plus chip uses a modified version of kurasuta iirc

grizzled raven
#

guild member intent is for guild_member_xyz events and other guild member related stuff

#

oh yeah because like people always say it's better but like i've never actually heard a reason as to why, or stuff that it does better

pale vessel
#

i don't think discord.js shardingmanager allows clustering, does it?

dense patio
#

the only thing i use guild members for is fetching a user from their username i think

pale vessel
#

if not then kurasuta is definitely better

dense patio
#

what does clustering do

dire obsidian
#

HELLOU

pale vessel
#

what does clustering do
@dense patio shards, but bigger 5head

dire obsidian
#

on web servers, someone know why there is a IIS 404.0 error when trying to open it on the http://localhost/ protocol?

grizzled raven
#

oh okay that's a great reason

dense patio
#

will using kurasuta make restarting my bot faster? it takes bloody forever if i want to restart it on the fly

pale vessel
#

nah

dense patio
static nexus
#

anyone here know tweepy

grizzled raven
#

wdym takes forever?

dense patio
#

my bot won't start rn and i'm getting this error
Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
which happened on my other bots; fixed by enabling intents

static nexus
#

i need to know how to delete my last message

grizzled raven
#

oh

floral rune
#

i have never had issues with djs taking a long time to restart

pale vessel
#

did you have fetchAllMembers enabled in your client options?

dense patio
#

?

#

uhh

#

yeah

#

is that it

quartz kindle
#

then thats the problem

dense patio
#

what a pain

pale vessel
#

it's trying to fetch all members on each guild, but no members were sent since the bot didn't have the intent

#

so it'll keep waiting until the timeout

quartz kindle
#

furthermore, djs is dumb and doesnt check if the members intent is enabled before trying to fetch all members

#

so it just fetches then waits forever until it crashes

dense patio
#

smart

#

will i still be able to fetch a user from their username if i don't have the intent?

solemn latch
#

Well, lots of programming is like that.

pale vessel
#

will i still be able to fetch a user from their username if i don't have the intent?
@dense patio yes you can

quartz kindle
#

you can use guild.members.fetch({query:"usernamehere"})

#

and it will return a list of people with similar usernames in that specific guild

dense patio
#

oh you can do that? i wish i knew that before lol

#

i was making it search the guild users for a user with that username

quartz kindle
#

ye

dense patio
#

thanks for your help 👍

#

does guild.members.fetch({query:"usernamehere"}) return an array?

dire obsidian
#

TIiiiiiim

quartz kindle
#

a promise<collection>

dense patio
#

ok thanks

dire obsidian
#

aka master dev

#

somebody know about web servers?

quartz kindle
#

many people

dire obsidian
#

well so, im making the classic localhost

#

aaaand im getting a iis 10 404 http error

#

but the file exist

quartz kindle
#

you're making an IIS webserver?

dire obsidian
#

yes

quartz kindle
#

i've never used IIS so idk

dire obsidian
#

okthen

quartz kindle
#

IIS is weird af

dire obsidian
#

thanks

quartz kindle
#

are you on windows?

dire obsidian
#

correct

#

i've never touched linux

quartz kindle
#

you want to work with php or what?

dire obsidian
#

hmmm no php

quartz kindle
#

there are many webservers out there you can use instead of IIS

dire obsidian
#

is just a simply web server

#

ok so, apache one?

quartz kindle
#

for example

#

or even node.js

dire obsidian
#

ok thanks

#

time to google for 3 days more

fluid basin
dire obsidian
pale vessel
#

var moment

dire obsidian
#

it work

#

var, let, const, etc

hollow sedge
#

Can you elaborate on the etc.

dire obsidian
#

just say a = "a"

hollow sedge
#

Ah ok..

quartz kindle
#

do you need websockets?

dire obsidian
#

yes

#

eventually

floral rune
#

there is a nice module called express-ws I've used that integrates nicely with express

whole crater
dire obsidian
#

well cyber

#

as i used when i maked bots

floral rune
#

does the bot respond if you send non-embeds

dire obsidian
#

i use this

whole crater
#

yes, it responds

floral rune
#

does the bot have embed permissions

whole crater
#

yes

floral rune
#

ok now that the dumb questions are out of the way send the code that responds with an embed

lunar knot
#

is there anyone else who can't login with their bot right now? I'm using JDA and it doesn't go further than 'connected to websocket'

whole crater
#
const { MessageEmbed, Channel } = require('discord.js')

module.exports = {
  commands: ['help', 'cmds', 'commands'],
  description: 'Displays help menu',
  usage: null,
  minArgs: null,
  maxArgs: 1,
  permissions: [],
  requiredRoles: [],
  callback: (message, args) => {
    const { guild } = message
    const icon = guild.iconURL()

    if (!args[0]) {
      const categories = new MessageEmbed()
        .setTitle('Command Help')
        .setDescription('Here are the different command categories!')
        .setThumbnail(icon)
        .setColor('#aec6cf')
        .setFooter('More commands coming soon!')
        .addFields(
          { name: 'COMMAND', value: '`COMMAND`', inline: true },
          
        )
        Channel.send(message)
  }
 }
}
#

code is like this

dire obsidian
#

hmm

#

cahnge the channel.send(message)

quartz kindle
#

@lunar knot check if there was any update or new information regarding intents in JDA

#

since discord pushed new changes

dire obsidian
#

to channel.send(categories)

floral rune
#

there's one other issue here

#

you are calling send on a prototype of Channel, you need to call it on message.channel

dire obsidian
#

also youre sending the var "message"

#

when the embed var is categories

#

so message.channel.send(categories)

whole crater
#

it'll respond to normal commands but wont repond to embeds command

dire obsidian
#

let embed = MessageEmbed()
.description("pong");
message.channel.send(embed)

floral rune
#

Here is the issue:
Channel.send(message) - this will take an uninitialized Channel object and try to send a Message class to it. Not only will the message go nowhere you also can't send a Message class. Further, you don't use categories at all.

You need message.channel.send(categories) instead - this will send a message to the channel the message came from containing the categories embed.

dire obsidian
#

ok why am i using web servers when i can just use repl.it

earnest phoenix
#

@earnest phoenix I'm back... did plain/text still open a file stream?
@boreal iron res.set is doing nothing to change the content type header and/or res.send is changing it to a text/octet-stream for some reason

floral rune
#

@earnest phoenix the correct mimetype is text/plain

plucky topaz
#

is there anyone else who can't login with their bot right now? I'm using JDA and it doesn't go further than 'connected to websocket'
@lunar knot I have the same problem

lunar knot
#

Enabling Gateway Intents fixed it for me, created a ticket for my verified bot tho

floral rune
#

yeah I just opened a ticket to get whitelisted for intents

#

how long does it take

lunar knot
#

idk yet

#

just created the ticket

floral rune
#

ah

#

it seems that my bot sometime last night stopped receiving guild join/leave events so I think something changed

broken yacht
#

Is anyone else having an issue with their bot not passing the "on_ready" event

#

My bot has been working fine

#

but today deiceded that it doesent want to start

floral rune
#

yes, try enabling privileged intents

broken yacht
#

thanks for the help

floral rune
#

For other people who are having issues with their bot -> https://dis.gd/gwupdate

boreal iron
#

@earnest phoenix And axios using headers will return a stream, too?

#

If so take a look at the request config param transformResponse

earnest phoenix
#
client.shard.broadcastEval("const name = message.args[0].toLowerCase(); delete require.cache[require.resolve(`./${name}/js`)]; ..")

-> message is not defined
Anyone has a solution to my query?

#

I want to reload commands on every shard.

pale vessel
#

/js

earnest phoenix
#

the problem is, is that it says that name is undefined

#

and when I have the code out of the broadcastEval, it says the same

floral rune
#

@earnest phoenix And axios using headers will return a stream, too?
@boreal iron my guess is because he used plain/text instead of text/plain something in the chain converted it to an octet stream

boreal iron
#

lmao did I write plain/text ?

prime glacier
#

code let propose = new discord.MessageEmbed() await propose.react("✔️");
error propose.react is not a function

pale vessel
earnest phoenix
#

#react() only works on messages

prime glacier
#

#react() only works on messages
@earnest phoenix then how can we do it on embed

pale vessel
#

the same way '

earnest phoenix
#
const my_message = await channel.send({ embed: my_embed });
my_message.react(emoji);
prime glacier
#

embed: propose?

earnest phoenix
#

what do you think

prime glacier
#

ok got it

earnest phoenix
#

no problem

prime glacier
#

ty

earnest phoenix
#

@boreal iron my guess is because he used plain/text instead of text/plain something in the chain converted it to an octet stream
@floral rune i noticed that error and changed it to text/plain

boreal iron
#

And the result still is a stream?

earnest phoenix
#

Yes

#

I'm pretty sure it's my CDN

#

Adding a console.log inside the app.get callback does not run

boreal iron
#

Did u try axios as mentioned?

earnest phoenix
#

Mentioned where?

#

Also I'm on phone

boreal iron
grizzled raven
#

at how many servers/shards do you recommend to start clustering

tame kestrel
#

after 1k try switching to a sharding system if you feel like your bot could use a tiny bit of performance, it's mandatory after 2500

grizzled raven
#

i mean clustering

drifting wedge
#

In my team we’re doing 3 shards per cluster

#

For a start

quartz kindle
#

does your vps have multiple cpu cores? do 1 process per cpu core
does yout vps have only 1 cpu core? use internal sharding

grizzled raven
#

is it like multiple shards for each core

quartz kindle
#

1 process per core, multiple shards per process

grizzled raven
#

got it

#

and uh since it's one process with multiple shards, would those processes still need to use those async methods to interact with the shards or is it kinda like internal sharding

quartz kindle
#

processes cannot talk to each other without a communication channel

#

stuff like djs's shardingManager creates a communication channel between the manager and the processes

grizzled raven
#

i meant, say if you have one process with 3 shards, will those 3 shards sorta be like internal sharding, where it's one process with the guilds of 3 shards or whatever

quartz kindle
#

yes

grizzled raven
#

okay thanks

jagged spruce
#

What should I do for the bot to automatically delete the message it sends after some time?

obtuse jolt
tulip ledge
#

Alright so I'm tryna make a "Trivia" command and I'm probably doing it wrong, but I basically have an array of wrong answers and 1 right answer, I want to add the right answer and then 2 random unique other "wrong answers" this is my code, it works but for some reason after I do it multiple times it only shows the right answer.

    let allAnswers = questions[keys[0]].wrongAnswers;
    let toAnswer = [];
    toAnswer.push(questions[keys[0]].rightAnswer)
    let randomPick = Math.floor((Math.random() * allAnswers.length - 1) + 1);
    toAnswer.push(allAnswers[randomPick])
    allAnswers.splice(randomPick, 1)
    toAnswer.push(allAnswers[Math.floor((Math.random() * allAnswers.length - 1) + 1)])

(It's ChickenDev btw I changed my name and pfp)

earnest phoenix
#

@tulip ledge hi vigintillion this is planck length

rose warren
#
message.reply('Your command response here')
  .then(msg => {
    msg.delete({ timeout: 10000 })
  })
  .catch(/*Error handling if the Message isn't returned etc*/);```
#

@jagged spruce 👆

earnest phoenix
#

@tulip ledge Can you show an example of what you're trying to do? I kinda didn't get what you meant

tulip ledge
#

I did it differently and it's working now

#

I do have a different issue

earnest phoenix
#

Hmm?

tulip ledge
#
        const filter = (reaction, user) => {
            console.log(1)
            console.log(reaction.emoji.name)
            return  ['🇦', '🇧', '🇨'].includes(reaction.emoji.name) && user.id === message.author.id;
        };
        
        const collector = message.createReactionCollector(filter, { time: 15000 });
        
        collector.on('collect', (reaction, user) => {
            let picked = 0;
            if(reaction.emoji.name === '🇧') picked = 1;
            if(reaction.emoji.name === '🇨') picked = 2;
            message.channel.send(askedAnswers(picked))
        });

nothing is logging, nothing is happening on collect

earnest phoenix
#

Are you creating the reaction collector on the correct message?

tulip ledge
#

🤦‍♂️

#

I feel dumb rn

earnest phoenix
#

Oof

tulip ledge
#

haha

hot crest
#

is there any good alternative to nekos.life?

#

nekos.life kinda weird

earnest phoenix
#

nekos.life API endpoints are not allowed here either, it shows up loli (minor) nsfw content

#

Reddit API can be used however

#

Some APIs can't be trusted nowadays

hot crest
#

bruh you guys are confusing

#

u guyssaid sfw nekos.life is allowed

#

no its not

earnest phoenix
#

When did we say that

jagged spruce
#

@jagged spruce 👆
@rose warren thank you happy

upper elm
#

so I'm working with dblapi.js

#

and I'm trying to show the server count

obtuse jolt
upper elm
#
const bot = new Client();
const dbl = new DBL(token.toptoken, bot);

bot.on('ready', () => {
    console.log('Cookies are ready!');
    setInterval(() => {
        dbl.postStats(bot.guilds.cache.size);
    })

})``` and this gives me an error
earnest phoenix
#

i create a bot

#

called kitana

#

it's so good

upper elm
#
(node:132260) UnhandledPromiseRejectionWarning: Error: 429 Too Many Requests
    at IncomingMessage.<anonymous> (C:\Users\Andy\Desktop\Cookie bot test 1\node_modules\dblapi.js\src\index.js:118:25)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:132260) 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: 40)
earnest phoenix
#

but language = portuguese

hollow sedge
earnest phoenix
upper elm
#

can anyone help me with fixing this it spams that error over and over

obtuse jolt
#

@hollow sedge yes it was, ty

boreal iron
#

@upper elm Dude, u need to actually defined an interval

obtuse jolt
#

@upper elm well, the problem is in the error it's pretty self explanatory

upper elm
#

oh my god

boreal iron
#

For example 12h

upper elm
#

bruh I'm dumb

obtuse jolt
#

you need to set time in between each request

#

I do it every 5 minutes but you can choose any time that isnt like every 3 seconds

upper elm
#

I set it to half an hour

boreal iron
#

setInterval(function() { dbl.postStats(bot.guilds.cache.size); }, 60 * 60 * 1000);

#

would be each hour

upper elm
#

cool it works now but I still get the error

earnest phoenix
#

You don't even have to set an interval, dblapi.js posts server count on it's own

#

Hello

#

I am beggining in .js

upper elm
#

oh so I can just do dbl.postStats outside of an interval?

earnest phoenix
#

And I don't understand why this not worked

#

`const {
GiveawaysManager
} = require("discord-giveaways");

const manager = new GiveawaysManager(client, {
storage: "./giveaways.json",
updateCountdownEvery: 1,
default: {
botsCanWin: false,
exemptPermissions: ["MANAGE_MESSAGES", "ADMINISTRATOR"],
embedColor: "#FF0000",
reaction: "🎉"
}
});

client.giveawaysManager = manager;

client.on("ready", () => {
console.log("I'm ready !");
});

client.login(settings.token);

client.on("message", (message) => {

const ms = require("ms");
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();

if (command === "gcreate") {


    client.giveawaysManager.start(message.channel, {
        time: ms(args[0]),
        prize: args.slice(2).join(" "),
        winnerCount: parseInt(args[1])
    }).then((gData) => {
        console.log(gData);
    });

}

});`

boreal iron
#

cool it works now but I still get the error
@upper elm Yes, because you're being rate limited the next hour.

earnest phoenix
#

No just don't put anything

boreal iron
upper elm
#

thanks

earnest phoenix
#
dbl.on("posted", () => console.log("Server count posted!"));``` just put this in
obtuse jolt
#

^^

earnest phoenix
#

You'll see it's posting it, without interval

upper elm
#

oooh I think I got it

#

so I'm sort of being stopped from send the request to poststats because I already did it like a shit ton?

obtuse jolt
#

is there a way to create a client defined variable in a start.js file?

boreal iron
#

Yes

upper elm
#

ok

boreal iron
#

You're blocked for one hour

upper elm
#

thanks for ur help

boreal iron
#

np

earnest phoenix
#

is there a way to create a client defined variable in a start.js file?
@obtuse jolt You can create the client and export it through other files

tulip ledge
earnest phoenix
#

Show code maybe

tulip ledge
#

Theres a hastebin link 😛

earnest phoenix
#

Oh wait you did

boreal iron
#

lmao

tulip ledge
#

aye FakE u got bot developer

#

Pog

boreal iron
#

Is line 47 just an issue pasting into hatebin? @tulip ledge

#

return [':regional_indicator_a:', '��', ':regional_indicator_c:'].includes(reaction.emoji.name) && user.id === message.author.id;

tulip ledge
#

its just the icons

#

🇦 🇧 🇨

boreal iron
#

@tulip ledge Aye bot got approved after a few weeks.

tulip ledge
#

Nice one 😄

marble copper
#

hello guys ! i added my server to top gg but it doesnt show up in my profile ! what's the issue ?

tulip ledge
#

It's ChickenDev btw

boreal iron
#

Aye remembered ur profile status Social Incapable

tulip ledge
#

haha

#

but anyone got the issue by any chance? ;-;

earnest phoenix
tired nimbus
#

what are the main things that canvas takes the longest to load

earnest phoenix
#

See what it returns

#

what are the main things that canvas takes the longest to load
@tired nimbus Images but that depends

tired nimbus
#

hm yea

#

what are the others?

tulip ledge
#
Master Necromancer -> Picked
Master Necromancer -> Right

Elementalist -> Picked (but not actually picked)
Stalker -> Right
Stalker -> Picked
Stalker -> Right

Wither Lord
New Necromancer
New Necromancer
New Necromancer
earnest phoenix
#

Which is which vigi

#

[Visible confusion]

tired nimbus
#

Im just really curious how people use canvas for general things such as rank cards that are created quickly

tulip ledge
#

so

#

the weird part is

#

Right

earnest phoenix
#

They're either done in other processes or use few properties on creation

tulip ledge
#

Lets say the first question had
A: Elementalist
B: New Necromancer

You pick B, but on the next question you pick A it shows A Elementalist as ur first pick and then ur actualy pick

#

I'm so confused

ionic dawn
#

let json = [{name: "Jack"}]

console.log(json.name)

#

shouldnt this work wtf

tulip ledge
#

no

#

json is an array

#

json[0].name

boreal iron
#

Does the first question works all the time?

earnest phoenix
#

Lets say the first question had
A: Elementalist
B: New Necromancer

You pick B, but on the next question you pick A it shows A Elementalist as ur first pick and then ur actualy pick
@tulip ledge Hmm, might be a wrong order push, lemme do an experiment on this, eval mode activate

tulip ledge
#

haha

#

YEs FakE

#

They all work

#

It's just scuffed

earnest phoenix
#

But before anything, i need to see how your questions are stored

boreal iron
#

No I mean answering the first question works all the time?

tulip ledge
#

Questions

earnest phoenix
#

What are the object keys for?

#

Like scarf, watcher, bonzo

tulip ledge
#

to shuffle the array of keys

#

oh

#

to shuffle basically

sly marten
#

if (message.includes ("give me nekos")) {
^

TypeError: message.includes is not a function
at Client.<anonymous> (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\bot.js:42:13)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\nickl\OneDrive\Υπολογιστής\NKBot Project\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)

#

how do i fix this

tired nimbus
#

message is an object

tulip ledge
#

message.content.includes()

sly marten
#

ohh updated

tulip ledge
#

nope

#

always has been like that

sly marten
#

;-;

#

the video i saw

#

whatever

solemn latch
#

Videos are terrible sources

tired nimbus
#

the video predefined message

umbral zealot
#

It has never been message.includes , not in the history of discord.js since version 6 at least.

sly marten
#

;-;

floral rune
#

if the video is older than a year it is false

solemn latch
#

There was a major api change yesterday

#

Any video older than 24 hours contains false info

boreal iron
#

You should try to log both of the askedAnswers[picked] and questions[keys[i]].rightAnswer
@tulip ledge Did u do that already?

#

I dont really see any issue so far, just guessing ur shuffled array keys are not accurate

#

Please log console.log(askedAnswers); console.log(reaction.emoji.name); console.log(askedAnswers[picked]); console.log(questions[keys[i]].rightAnswer); right after line 57, before if(askedAnswers[picked] === questions[keys[i]].rightAnswer)

#

and post the results

tulip ledge
#
[]
[ 'Stalker', 'Elementalist', 'Professor' ]
�
Stalker
Stalker
[]
[ 'Stalker', 'Elementalist', 'Professor' ]
�
Professor
Professor
[]
[ 'Wither Lord', 'Stalker', 'Professor' ]
�
Professor
Professor
[]
[ 'Stalker', 'Elementalist', 'Professor' ]
�
Elementalist
Apprentice Necromancer
[ 'Wither Lord', 'Stalker', 'Professor' ]
�
Stalker
Apprentice Necromancer
[
  'Master Necromancer',
  'Shaman Necromancer',
  'Apprentice Necromancer'
]
�
Shaman Necromancer
Apprentice Necromancer
[ 'Wither Lord', 'Apprentice Necromancer', 'Shaman Necromancer' ]
�
Apprentice Necromancer
Apprentice Necromancer

The weird part is that there's only 3 questions it asked yet it logged like 5 or 6 times

#

Ignor the [] they're something different

boreal iron
#

The console logs are in the same order as I posted?

tulip ledge
#

yES

boreal iron
#

Ok, so I read, 1st question u selected the right answer but still the error?

tulip ledge
#

its so weird

#

1st was right

#

Then I had the 2nd one right but it logged twice?

#

And then I had the 3rd one right too but it did all the possible answers?

#

i'm confused

boreal iron
#

askedAnswers is the first array, means ur 2nd question has the same 3 answers as the first one

#

oh I see, your answers are placeholders yet and are similar anyway

floral rune
#

do this instead ```js
console.log({
askedAnswers,
emoteName: reaction.emoji.name,
picked: askedAnswers.picked,
answer: questions[keys[i]].rightAnswer
});

granite trout
boreal iron
#

not needed, the emojy is correct

tulip ledge
#

I4; confused

floral rune
#

How can I make [0] be random between 0 and 3?
@granite trout is this js

granite trout
#

ye

boreal iron
#

Please add the question to the log I guess I know what's going wrong

floral rune
#

Math.random() will give you a number between 0 and 1

granite trout
#
 ${json.list[Math.random()].definition} ```?
boreal iron
#
console.log(questions[keys[i]].rightAnswer);
console.log(askedAnswers);
console.log(askedAnswers[picked]);```
@tulip ledge
quartz kindle
floral rune
#

@granite trout it gives a random decimal number between 0 and 1

quartz kindle
#

you're using a recursive function which creates reaction collectors

#

each answer creates more and more collectors running at the same time

floral rune
#

so do something like Math.floor(Math.random()*4) for a number between 0 and 3

granite trout
#

@floral rune i dont think it it works where it is

tulip ledge
#
[]
What is the **status** of **Bonzo**?
New Necromancer
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
New Necromancer
[]
What is the **status** of **Livid**?
Master Necromancer
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
Professor
What is the **status** of **Livid**?
Master Necromancer
[ 'Young Wither', 'Professor', 'Master Necromancer' ]
Master Necromancer
[]
What is the **status** of **Livid**?
Master Necromancer
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
Master Necromancer
[]
What is the **status** of **The Professor**?
Professor
[ 'Young Wither', 'Professor', 'Master Necromancer' ]
Young Wither
What is the **status** of **The Professor**?
Professor
[ 'Professor', 'Elementalist', 'Wither Soldier' ]
Professor
What is the **status** of **The Professor**?
Professor
[ 'Master Necromancer', 'New Necromancer', 'Professor' ]
Master Necromancer
What is the **status** of **The Professor**?
Professor
[ 'Young Wither', 'Professor', 'Master Necromancer' ]
Young Wither
What is the **status** of **The Professor**?
Professor
[ 'Professor', 'Elementalist', 'Wither Soldier' ]
Professor
What is the **status** of **The Professor**?
Professor
[ 'Professor', 'Stalker', 'Shaman Necromancer' ]
Professor
boreal iron
#

Aye Tim is right

#

U see?

each answer creates more and more collectors running at the same time

#

Same question over and over again

tulip ledge
#

still doesn't work

quartz kindle
#

youre still creating multiple event listeners

tired panther
#

How to show current shard for avatar

tulip ledge
#

D.

quartz kindle
#

anyway a collector is not the best way for this kind of thing

#

use awaitReactions

tulip ledge
#

oh ok

tired panther
#

@quartz kindle you know it xD, you are here the sharding expert

quartz kindle
#

wdym current shard for avatar

#

avatar is the same in all shards

tired panther
#

show the current shard in client.user.setActivity @quartz kindle

quartz kindle
#

ah

#

for set activity is the other way around

#

you chose which shard you want the activity to be for

tired panther
#

how then?

#

client.user.setActivity(`%command & %help | Shard ${client.shard.id}` );

#

it does not give the Shard @quartz kindle

quartz kindle
tired panther
#

so I can not no in differnt guilds, which shard they are , becuase of the differnt status?

quartz kindle
#
client.user.setActivity("this activity will be on shard 0 only", { type: "WATCHING", shardID:0 })
client.user.setActivity("this activity will be on shard 1 and 2", { type: "WATCHING", shardID:[1,2] })
tired panther
#

ah , so I have to define it for every shard?
I have the auto manager

quartz kindle
#

yes

tired panther
#

okay thats to much work for me xD, because the Activity is everytime same

quartz kindle
#

if you're using the sharding manager, you can do shardID: client.shard.ids[0]

tired panther
#

ah okay

tulip ledge
tired panther
#

okay thx a lot

blissful coral
#

What is the best way to set up a premium version of a bot

quartz kindle
#

._emoji is the raw data for the emoji

#

you should be able to use .emoji which is a getter and returns the formatted data as an Emoji class

tulip ledge
#

TypeError: Cannot read property 'name' of undefined

#

reaction._emoji.name

#

console.log(reaction._emoji)

#

undefined

blissful coral
#

is this python?

#

@tulip ledge

tulip ledge
#

no

#

js

boreal iron
#

ffs hastebin text is tiny as fuck on mobile

blissful coral
tulip ledge
#

no not on awaitReactions

blissful coral
#

It doesn't?

#

oh on await not collector

quartz kindle
#

@tulip ledge show code

tulip ledge
ancient nova
#

Error: input stream: Status code: 416

#

can anyone tell me what this error is?

quartz kindle
#

@tulip ledge console.log reaction.emoji

ancient nova
#

randomly happens while streaming music or downloading it using ytdl

quartz kindle
#

oh nvm

#

@tulip ledge reaction is a collection of reactions

#

since its awaitReactions

tulip ledge
#

undefined

quartz kindle
#

so you have to reaction.first().emoji

boreal iron
#

The HyperText Transfer Protocol (HTTP) 416 Range Not Satisfiable error response code indicates that a server cannot serve the requested ranges. The most likely reason is that the document doesn't contain such ranges, or that the Range header value, though syntactically correct, doesn't make sense.

ancient nova
#

I'll look into it

tulip ledge
#

await reaction.users.remove(message.author.id) how do I remove the reaction now

ancient nova
#

I see, maybe I had the highWaterMark set too high

quartz kindle
#

@tulip ledge same thing

#

your reaction is a collection of reactions

#

not 1 reaction

tulip ledge
#

Now its working

earnest phoenix
#

Hey,
so i want to remove some roles in a function, that you define by def func(): some code

it says you can't have await in a non async function
how to fix this?

quartz kindle
#

async def func()

earnest phoenix
#

kk

ancient nova
#

@hollow sedge if the ytdl crashes whilst setting highWaterMark too high, then how do I prevent the audio from being laggy and choppy otherwise?

hollow sedge
#

Idk, I just looked up your problem lol

ancient nova
#

oh I see

hollow sedge
#

@ancient nova you should look it up yourself though, more than likely someone had the same problem

modest smelt
#
SyntaxError: 'await' outside async function
``` how to fix this?
ancient nova
#

I've tried, google didn't help much

solemn latch
#

await needs to be in async functions

hollow sedge
#
SyntaxError: 'await' outside async function
``` how to fix this?

@modest smelt don't use await outside of async 😆

ancient nova
#

the only thing that I've done that worked

#

I've set highWaterMark to 550

#

but it created those weird 216 errors

#
  • randomly
solemn latch
#

216 errors, just a few

earnest phoenix
#

@hollow sedge @solemn latch the function is defined as:

async def function():
  #some code
#

it is part of an async func

ancient nova
#

where are the brackets

hollow sedge
#

where are the brackets
@ancient nova it's PYTHON

modest smelt
#

lawl

ancient nova
#

ooooooooooooooooooooooooooooooooooh

#

that's why I hate python

#

it's so weird

hollow sedge
#

Lol it's supposed to be more readable

earnest phoenix
#

so whats the fix?

#

because it is in an async func

hollow sedge
#

@earnest phoenix where is the await

ancient nova
#

well it's just my opinion, but yeah it wants to be more visible, instead it hurts my eyes

earnest phoenix
#

it is part of #some code

hollow sedge
#

Can you just put the actual code there

earnest phoenix
#

kk

#
async def job():
  guild= client.get_guild(764893841068261447)
  for role in guild.roles:
    if role.id ==765213445997068319:
      for member in guild.members:
        if role in member.roles:
          await member.remove_role(role)  
  nothing = {}
  with open('correctpotd.json', 'r') as f:
    json.dump(nothing, f)
  with open('incorrectpotd.json', 'r') as f:
    json.dump(nothing, f)
  with open('progress.json', 'r') as f:
    json.dump(nothing, f)
  with open('potd.json', 'r') as f:
    data= json.load(f)
  today = date.today()
  todays= data[str(today)]
  problem = todays["problem"]
  yesterday= str(today-timedelta(days = 1))
  yesterdays= data[yesterday] 
  source= yesterdays["source"]
  answer = yesterdays["answer"]
  points = yesterdays["points"] 
  channel = client.get_channel(764903892081180682)
  await channel.send(f"Source: ||{source}||")
  await channel.send(f"Answer: ||{answer}||")  
  await channel.send(f"Points Received: ||{points}||")
  await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")```
ancient nova
#

if anyone has fix to ytdl core audio being laggy, please dm me

hollow sedge
#

kk
@earnest phoenix it'd check the spacing on all of them and see if you might have accidently put one outside

#

Otherwise 🤷

earnest phoenix
#

hm ok

obtuse jolt
tulip ledge
earnest phoenix
#

edit the content

obtuse jolt
#

You could just edit to be something else like "Congrats you won" etc

earnest phoenix
#

Just

<message>.edit("", {
embed: // your embed here
});``` @tulip ledge
blissful coral
#

@obtuse jolt what db you using

obtuse jolt
#

MySQL

blissful coral
#

YESSIR

obtuse jolt
#

does anybody know any websites that set off vt detection?

tulip ledge
#

<Message>.reactions.remove() is not a function

obtuse jolt
#

reactions.removeAll()

#

^^ requires manage messages ^^

earnest phoenix
#

That removes all reactions mate

obtuse jolt
#

yeah could want to do that

tulip ledge
#

Yeah thats what I wanted to do

#

I'm just incapable

stable eagle
#

<Message>.reactions.cache.remove()

quartz kindle
#

^wat

earnest phoenix
#

<message>.reactions.cache.get("emoji you want to remove here").remove()

obtuse jolt
#

uwu it's tim

#

WRONG SERVER

#

i actually cant find any virus links

earnest phoenix
#

This is kinda really confusing

#

state property is nullable

dusky garden
#

whats the code?

#

oh

obtuse jolt
earnest phoenix
#

state && state.includes(<whatever here>)

obtuse jolt
#

@earnest phoenix remove the link from it

earnest phoenix
#

That's already the fix

dusky garden
#

oki

#

that menas that state = null

obtuse jolt
#

do you have presence updates enabled in settings?

earnest phoenix
#

state && state.includes(<whatever here>)

quartz kindle
#

@earnest phoenix pretty sure .react() doesnt accept emojis :like_this:

obtuse jolt
#

in the developer portal theres a setting called presence updates

dusky garden
#

u spelled status wrong

earnest phoenix
#

@earnest phoenix pretty sure .react() doesnt accept emojis :like_this:
@quartz kindle It does accept this 🇦 but when putting it's actual unicode, it doesn't

#

@earnest phoenix Yes

obtuse jolt
#

@dusky garden help me find virus links

dusky garden
#

oh where

earnest phoenix
obtuse jolt
#

i need them for testing purposes

dusky garden
#

ah ok

obtuse jolt
#

but I cant find any that aren't already cached

dusky garden
#

just make one then lmao

obtuse jolt
#

I need uncached links that set off virustotal

tulip ledge
#

how do u make a "virus link checker"?

obtuse jolt
#

VirusTotal api

earnest phoenix
#

I think he means how does it check for "virus"

quartz kindle
#

@earnest phoenix it works with the unicode for me, but it doesnt work with the emoji string

earnest phoenix
#

Now that's suspicious

quartz kindle
earnest phoenix
#

That worked for me too

dusky garden
#

it might be a feature in one of the libraries ur using

quartz kindle
obtuse jolt
#

imagine a bot that checks your status for an ad then kicks you from every guild with anti ad on

tulip ledge
dusky garden
#

LOL

tulip ledge
earnest phoenix
#

Anyway to parse it to that emoji like 🇦 before passing it as a parameter to react() ? @quartz kindle

quartz kindle
#

nope

obtuse jolt
#

100 guild ban speedrun 2020

quartz kindle
#

you have to map them to unicodes yourself

tulip ledge
#

lol

earnest phoenix
#

Welp, @tulip ledge we failed on that

#

@earnest phoenix it'd check the spacing on all of them and see if you might have accidently put one outside
@hollow sedge i just checked there is no spacing error

#

@earnest phoenix That's what it's supposed to log

tulip ledge
#

haha but Tim fixed it lol

#

It's working

earnest phoenix
#

Wait really? What was wrong

dusky garden
#

@earnest phoenix u spelled status wrong in the code u sent us

tulip ledge
#

It was making multiple collectors since it was a recursive function

earnest phoenix
#

Not you, was talking to vigi

dusky garden
#

in state.includes

earnest phoenix
#
async def job():
  guild= client.get_guild(764893841068261447)
  for role in guild.roles:
    if role.id ==765213445997068319:
      for member in guild.members:
        if role in member.roles:
          await member.remove_role(role)  
  nothing = {}
  with open('correctpotd.json', 'r') as f:
    json.dump(nothing, f)
  with open('incorrectpotd.json', 'r') as f:
    json.dump(nothing, f)
  with open('progress.json', 'r') as f:
    json.dump(nothing, f)
  with open('potd.json', 'r') as f:
    data= json.load(f)
  today = date.today()
  todays= data[str(today)]
  problem = todays["problem"]
  yesterday= str(today-timedelta(days = 1))
  yesterdays= data[yesterday] 
  source= yesterdays["source"]
  answer = yesterdays["answer"]
  points = yesterdays["points"] 
  channel = client.get_channel(764903892081180682)
  await channel.send(f"Source: ||{source}||")
  await channel.send(f"Answer: ||{answer}||")  
  await channel.send(f"Points Received: ||{points}||")
  await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")

ERROR: SyntaxError: 'await' outside async function

#

@tulip ledge OMEGALUL

placid parcel
#

I want to add my bot to top.gg. Can anyone help?

dusky garden
obtuse jolt
#

@dusky garden is ur bot offline?

dusky garden
#

yea

#

f

obtuse jolt
#

damn

dusky garden
#

imma about to add a new one though

#

i abandoned @high mulch

obtuse jolt
#

what's ur new one gonna do?

dusky garden
#

i migrated from js to python

obtuse jolt
#

smh

dusky garden
#

python is so much fucking easier

obtuse jolt
#

SMH

earnest phoenix
#

ikr

#

python god

#

can someone help me?

dusky garden
#

with what

earnest phoenix
#
async def job():
  guild= client.get_guild(764893841068261447)
  for role in guild.roles:
    if role.id ==765213445997068319:
      for member in guild.members:
        if role in member.roles:
          await member.remove_role(role)  
  nothing = {}
  with open('correctpotd.json', 'r') as f:
    json.dump(nothing, f)
  with open('incorrectpotd.json', 'r') as f:
    json.dump(nothing, f)
  with open('progress.json', 'r') as f:
    json.dump(nothing, f)
  with open('potd.json', 'r') as f:
    data= json.load(f)
  today = date.today()
  todays= data[str(today)]
  problem = todays["problem"]
  yesterday= str(today-timedelta(days = 1))
  yesterdays= data[yesterday] 
  source= yesterdays["source"]
  answer = yesterdays["answer"]
  points = yesterdays["points"] 
  channel = client.get_channel(764903892081180682)
  await channel.send(f"Source: ||{source}||")
  await channel.send(f"Answer: ||{answer}||")  
  await channel.send(f"Points Received: ||{points}||")
  await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")

ERROR: SyntaxError: 'await' outside async function

dusky garden
#

ur await has to be in a async def

earnest phoenix
#

it is

dusky garden
#

no its not

earnest phoenix
#

async def job

dusky garden
#

oh it is

#

im dum

obtuse jolt
#

smh

earnest phoenix
#

@earnest phoenix Instead of all that you could have just done this

if (newpresence.activities.find(a => a.type === "CUSTOM\_STATUS") && newpresence.activities.find(a => a.type === "CUSTOM\_STATUS").state && newpresence.activities.find(a => a.type === "CUSTOM\_STATUS").state.includes("Some server link")) newpresence.member.roles.add("630855613093642240");```
dusky garden
#

that is so complicated

earnest phoenix
#

anyone got a fix?

#

for my code?

dusky garden
#

nah i dont

#

i dont know whats wrong

#

it should work

#

python right?

#

@earnest phoenix its in python correct?

earnest phoenix
#

yeah

dusky garden
#

ok

earnest phoenix
#

thats what i thought as well

#

but its not working

dusky garden
#

OH

#

await channel.send(f"@POTD New POTD! Submit your answers by DMing me! POTD: {problem}")

#

that line is wrong

#

no

#

i got that wrong

marble juniper
#

@swift umbra should already be I think

dusky garden
#

can u send me a screenshot of ur line in vsc @earnest phoenix

earnest phoenix
#

whats wrong in that line @dusky garden

#

i use repl

marble juniper
#

im stupid then

dusky garden
#

yea send me the line

#

like screenshot it

earnest phoenix
#

like a ss?

#

ok

#

@earnest phoenix Put that inside the event

dusky garden
#

ah

#

ok then idk what wrong

earnest phoenix
#

o ok

#

i am sad

#

because that doesnt work

dusky garden
#

thought u had a indent problem on the last part of the string

earnest phoenix
#

o

#

not indent probem

#

it is an await problem

hollow sedge
#

@earnest phoenix can you share your repl here

#

like send the link to it

earnest phoenix
#

no sry

hollow sedge
#

if its public

#

ok nvm then

boreal iron
#

@swift umbra Docs are mostly not up to date. Since discord took 6 months for the intents to get in place v6 won’t live long anymore I guess

earnest phoenix
#

Np

#

does anyone know a reason it could be failing?

dusky garden
#

also i have a question

earnest phoenix
#

yeah

dusky garden
#

in python, the discord.User object detects what

earnest phoenix
#

im not sure

hollow sedge
#

what is that supposed to mean

dusky garden
#

python

hollow sedge
#

detects?

earnest phoenix
#

^

dusky garden
#

i mean like im trying to make a unban command

#

using discord.ext.commands

hollow sedge
dusky garden
#

i took a look already

hollow sedge
#

well take a second look

dusky garden
#

ah lemme try converting it to str

hollow sedge
#

@earnest phoenix can you at least share the py file..otherwise no one can help you

dusky garden
#

who else uses heroku to host their bots cause they dont wanna pay

hollow sedge
#

i dont think heroku would "just break"

earnest phoenix
#

You shouldn't use heroku as a bot host, it's meant for hosting websites not hosting bots

hollow sedge
#

oh i see what you're saying

earnest phoenix
#

kk

#

lemme share it

hollow sedge
#

i hate 2 space tabs

willow mirage
#

How i can get create in a category ?

dusky garden
#

same

willow mirage
#

im js

earnest phoenix
#

o

#

then idk

umbral zealot
#

"js" is a language. What library are you using?

earnest phoenix
#

@hollow sedge @dusky garden do you see a problem anywhere?

dusky garden
#

no

earnest phoenix
#

😦

dusky garden
#

2 space tabs are annoying

#

ngl

earnest phoenix
#

wdym

hollow sedge
#

yeah thats what i said @dusky garden

earnest phoenix
#

sry

hollow sedge
#

in repl you can go into settings and change it to 4 space

earnest phoenix
#

o where?

#

nvm found it

hollow sedge
#

yeah lol its simple

placid iron
#

you know what is worse than 2 space tabs? 8 space tabs that notepad likes to do

dusky garden
#

wheres the @bot.command()

#

you know what is worse than 2 space tabs? 8 space tabs that notepad likes to do
@placid iron oh no

earnest phoenix
#

its not a cmnd

#

its a func

dusky garden
#

ah ok

willow mirage
#

@earnest phoenix any idea how i can create a channel in a categroy ?

earnest phoenix
#
<client>.on("presenceUpdate", (oldPresence, newPresence) => !oldPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) && newPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) ? newPresence.member.roles.add("Role ID" : oldPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) && !newPresence.activities.find(a => a.type === "CUSTOM\_STATUS" && (a.state && a.state.includes("Server link here")) ? newPresence.member.roles.remove("Role ID") : null);``` @earnest phoenix
#

Spoonfeed moment

dusky garden
#

try moving schedule.every().day..... under the bot.event

earnest phoenix
dusky garden
#

can someone help me

#

like im trying to make a unban command but i cant get the bot unban the id said

earnest phoenix
#

@earnest phoenix any idea how i can create a channel in a categroy ?
@willow mirage js <Guild>.channels.create(<Channel name>, { parent: <Category channel ID> });

dusky garden
#

its saying "id" is not a member

ancient nova
#

not sure where to go with this, but, I've set up an official Discord announcement channel in my server, but nothing was popping up there since the time I set it up

#

can anyone help me?

dusky garden
#

code?

ancient nova
dusky garden
#

dont think thats what this channel is for

#

can soemoen help me

ancient nova
#

I know that

dusky garden
#

what do u want to pop up there

earnest phoenix
#

try moving schedule.every().day..... under the bot.event
@dusky garden thats not the problem and if i move it, then the thing done in bot.event wont be defined

ancient nova
#

the official discord server announcements

dusky garden
#

ah ok bob

ancient nova
#

lol

earnest phoenix
#

so

dusky garden
#

ah

#

follow it

earnest phoenix
#

anything else to fix?

hollow sedge
#

@earnest phoenix well..did it work?

willow mirage
#

@willow mirage js <Guild>.channels.create(<Channel name>, { parent: <Category channel ID> });
@earnest phoenix uh no u have to do channel.setParent("parentID"), just googled

dusky garden
#

try refollowing it

earnest phoenix
#

@earnest phoenix well..did it work?
@hollow sedge no 😦

ancient nova
#

no, the official discord announcement server, it gets i's own notifications'

earnest phoenix
#

@willow mirage No

ancient nova
#

like you don't have to follow anything

willow mirage
#

yes

ancient nova
#

you set it up once you gain 500 members to have your server visible

#

to others

earnest phoenix
#

You can set the parent channel on creation of the channel

dusky garden
#

can someone help me

earnest phoenix
#

Look at the channel creation documents CutieCat

#

Remove <>

dusky garden
#

i tried making a unban command in python and the bot does not recongize the id that the person sent, and its saying that "id" is not a member

earnest phoenix
#

And you forgot a )

willow mirage
#

@earnest phoenix then how i can set the type

dusky garden
#

ive been using the discord.User object

earnest phoenix
#

@willow mirage Channel type?

zenith knoll
#

oops

dusky garden
#

bruh

#

lol

zenith knoll
#

lmao

dusky garden
#

regen it right now

zenith knoll
#

i clicked vsc but it brought me to discord

#

nah its fine

willow mirage
#

@earnest phoenix give me docs

#

give me link

earnest phoenix
#

@earnest phoenix newPresence.member.roles.add("Role ID" <= here

floral rune
#

n014tok3nn014tok3nn014tok3nn014tok3nn014tok3n.n014tok3nn014tok3n

zenith knoll
#

cause i deleted 10 chars

willow mirage
#

i can't find it smh

dusky garden
#

@floral rune fake

earnest phoenix
willow mirage
#

What is the command

#

cuz i have docs command 2

floral rune
#
n 0 1 4 t o k 3 n
n o t a t o k e n
dusky garden
#

c a n s o m e o n e h e l p m e

#

the semicolon

#

theres a extra bracket

earnest phoenix
#

@earnest phoenix Place a ) after ("Server link here"))

#

On all of them

dusky garden
#

wahhh i need help

hollow sedge
#

@earnest phoenix use discord.ext.commands.tasks instead of schedule

earnest phoenix
#

@earnest phoenix use discord.ext.commands.tasks instead of schedule
@hollow sedge but it worked

hollow sedge
#

what?

earnest phoenix
#

WAIT I AM NOT SAYING IT WORKED

#

so basically

#

instead of all the await stuff

#

i just put

#
def func():
  print('bruh')
floral rune
#

@earnest phoenix ```js
bot.on('presenceUpdate', (_,newPresence)=>{
if (newPresence.activities.find(({type,state})=>type==='CUSTOM_STATUS'&&state&&state.includes('server link'))) {
newPresence.member.roles.add('role id')
} else {
newPresence.member.roles.remove('role id')
}
})

earnest phoenix
#

and tried the timing

#

and it worked

hollow sedge
#

yes but that func isnt even async

earnest phoenix
#

ik

hollow sedge
#

so how is that the same

earnest phoenix
#

but it worked

hollow sedge
#

but it doesnt mean anything

earnest phoenix
#

the schedule module worked

#

its just that the async screws it up

hollow sedge
#

srsly, just use tasks

earnest phoenix
#

srsly, just use tasks
@hollow sedge ok

floral rune
#

different approach

dusky garden
#

nvm

earnest phoenix
#

That won't check if they had the custom status containing the link then removed on the newPresence nununoisy

floral rune
#

it will only check if the newPresence has it or not

#

although i am being slightly lazy by calling add/remove regardless of whether or not they have the role or not

earnest phoenix
#

my bot stopped working for good

#

out of the blue

#

;-;

#

OMEGALUL Bruh

floral rune
#

my bot stopped working for good
@earnest phoenix discord api changed, update libraries and make sure you don't need privileged intents

earnest phoenix
#

does not answer any command or mention

#

ok

floral rune
#
earnest phoenix
#

ok sir

hollow sedge
#

why am i getting ratelimited whenever i try to test on repl.it

floral rune
#

it's not that, you need to make sure you aren't using any privileged intents

#

do you have join/leave/boost messages or are you keeping track of presences

earnest phoenix
#

all

floral rune
#

you need to turn on privileged intents on the Developer page

earnest phoenix
hollow sedge
#

@earnest phoenix were you able to get it working with tasks?

#

i was able to get it working on my side

earnest phoenix
#

you need to turn on privileged intents on the Developer page
@floral rune ok!

#

Are already active

floral rune
#

also update discord js

earnest phoenix
#

@earnest phoenix were you able to get it working with tasks?
i was able to get it working on my side

@hollow sedge can you send the code?

dark grove
#

can anybody tell me of a bot-hosting site that is not too expensive? picked up discordjs as more of a side project so in case I drop it I don’t want to have wasted a bunch of money on hosting

earnest phoenix
#

also update discord js
@floral rune ok

#

@dark grove some are free

hollow sedge
#

@earnest phoenix oliy no, but i can help you figure out how to do it

earnest phoenix
#

ok

#

how would i start?

hollow sedge
#

you have to use the @tasks.loop(hours=<hours>) decorator

earnest phoenix
#

but i want it at a specific time every day

#

then if i restart my bot

#

..

hollow sedge
#

hmm

floral rune
#

@earnest phoenix what are you trying to do

hollow sedge
#

calculate the time until that time and asyncio.sleep until that

#

@earnest phoenix what are you trying to do
@floral rune they're trying to run an async function every day at a specific time

floral rune
#

if you need the delay to persist across restarts you will need to store the 'next run time' somewhere

#

then you can check if the time is past that time

earnest phoenix
#

calculate the time until that time and asyncio.sleep until that
@hollow sedge great idea!

#

but wouldnt we need to use functions again bringing us back to that function error @hollow sedge

hollow sedge
#

🤷 the only thing we can do is try

earnest phoenix
#

kk

#

@floral rune i did it all

#

but now how would it be to activate?

#

i can put this?

floral rune
#

if you updated discord.js and everything it should just work

earnest phoenix
#

const client = new Discord.Client({ ws: { intents: Discord.Intents.ALL }})

floral rune
#

you shouldn't need that

earnest phoenix
#

ok

#

I give up

floral rune
#

It's saying that the supplied ID isn't a role

#

hmm

hollow sedge
#

@earnest phoenix i figured it out

#

took me a while as i havent really used datetime

floral rune
#

I give up
@earnest phoenix open a ticket with support I'm not sure at this point

earnest phoenix
#

how would you calculate the number of seconds from now till the specified time @hollow sedge

floral rune
#

The error is Supplied roles is not an Role, Snowflake, etc.

#

so for some reason it doesn't recognize the role ID

#

does the role still exist

hollow sedge
#

@earnest phoenix

  1. get current time
  2. get later time: datetime.datetime(now.year, now.month, now.day, hour=10, minutes=10)
  3. wait_for_seconds = (current_time-later_time).total_seconds()
  4. and then sleep for wait_for_seconds
  5. after sleep start task with <name_of_function>.start() (assuming you are using discord.py tasks)
earnest phoenix
#

thx

#

but how do you get the later time

#

cant i just specify it?

hollow sedge
#

i edited it

earnest phoenix
#

thx

hollow sedge
#

this is assuming you want it to start at 10:10

earnest phoenix
#

@earnest phoenix open a ticket with support I'm not sure at this point
@floral rune okok

#

thx!

hollow sedge
#

👍np

floral rune
#

hmm interesting

earnest phoenix
#

is now a variable @hollow sedge

hollow sedge
#

@earnest phoenix now is datetime.datetime.now

earnest phoenix
#

kk

#

also

#

i want to check the time for tomorrow

#

until tomorrow