#development

1 messages · Page 1211 of 1

pale vessel
#

because it's better, faster, and stronger

timber notch
#

can i get someone to help me and is wanting to come in to testing 1 vc

ripe wadi
#

can someone help me with this.

vc1 = client.channels.fetch("id here dont mind me :b");

for some reason this doesnt work. can someone tell me how to properly store a voice channel by id in a variable

earnest phoenix
#

@ripe wadi

client.channels.cache.get("ID")
ripe wadi
#

oh

#

lemme try

#

it works, tysm <3

pale vessel
#

@ripe wadi your method works if you add await

ripe wadi
#

ohhh okay

split hazel
#

is there even such a method

#

okay there is

blazing ravine
#

giphy api work on discord.js ?

slender thistle
#

An API should work with all programming languages that support HTTP requests

blazing ravine
#

hm

#
const client = GphApiClient(process.env.GIPHYTOKEN)

const searchForGif = (gifName) => {
client.search('gifs', {"q": gifName, "limit": 1})
.then((response) => {
   var gif = response.data[0].url;
   return gif;
 })
 .catch((err) => {
  return err;
 })
}

module.exports.searchForGif = searchForGif;```
ionic dawn
#

@blazing ravine it does

#

If you ever worked with the youtube api is kinda the same

blazing ravine
#

oh

ionic dawn
#

Searh something, get number of objects and select the property you want

#

In your case you want the img url I guess

#

I think theres a guide at giphy

slate oyster
blazing ravine
#

let me try if i get error i wil send here ;dd

drifting wedge
#

author_id = ctx.author.id
    guild_id = ctx.guild.id

    author = ctx.author

    user_id = {"_id": author_id}

    if ctx.author == client.user:
        return

        if ctx.author.bot:
            return

            if(collection.count_documents({}) == 0):
                user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
                collection.insert_one(user_info)

                if(collection.count_documents(user_id) == 0):
                    user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
                    collection.insert_one(user_info)

                    exp = collection.find(user_id)
                    for xp in exp:
                        cur_xp = xp["XP"]

                        new_xp = cur_xp + 1

                        collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)

    #await ctx.channel.send("1 xp up")

    lvl = collection.find(user_id)
    for levl in lvl:
        lvl_start = levl["Level"]

        new_level = lvl_start + 1

        if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
            collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
            await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")``` but its not writing to the db
blazing ravine
#

hmm

#

@ionic dawn can u help me sorry for tag

slender thistle
#

Uhhhhh

#

@drifting wedge Your indents are fucked I believe

#

Yeah they're really fucked

drifting wedge
#

Yeah they're really fucked
@slender thistle ok

#

i fixed em

#

just did

blazing ravine
#

some1 help me pls

drifting wedge
#

@blazing ravine

slender thistle
#

Send the updated code, 0Exe

drifting wedge
#

with?

blazing ravine
#

ye

#

i send

drifting wedge
#

@slender thistle 1 sec

drifting wedge
#
@commands.Cog.listener()
async def on_message(self, ctx):
    mango_url = "url"
    cluster = MongoClient("this is right")
    db = cluster["db1"]
    collection = db["db1"]
    author_id = ctx.author.id
    guild_id = ctx.guild.id

    author = ctx.author

    user_id = {"_id": author_id}

    if ctx.author == client.user:
        return

    if ctx.author.bot:
        return

    if(collection.count_documents({}) == 0):
        user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
        collection.insert_one(user_info)

    if(collection.count_documents(user_id) == 0):
        user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
        collection.insert_one(user_info)

    exp = collection.find(user_id)
    for xp in exp:
        cur_xp = xp["XP"]

        new_xp = cur_xp + 1

    collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)

    #await ctx.channel.send("1 xp up")

    lvl = collection.find(user_id)
    for levl in lvl:
        lvl_start = levl["Level"]

        new_level = lvl_start + 1

    if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
        collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
        await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")```
#

its in a cog

#

btw

slender thistle
#

Are you...

#

creating a client on each sent message?

#

I'd suggest attacking one MongoClient, attach it to the bot object as a property and then use that property

drifting wedge
#

me?
its supposed to level up the user

#

like xp+

slender thistle
#

And you are creating pointless clients instead of using just one

drifting wedge
#

wdym?

slender thistle
#
    cluster = MongoClient("this is right")
    db = cluster["db1"]
    collection = db["db1"]
#

This is in your on_message, so you are creating a new MongoClient each time a message is sent

drifting wedge
#

oooh

#

so how can i just not create a new one?

#

make it global?

slender thistle
#

I'd suggest attacking one MongoClient, attach it to the bot object as a property and then use that property
@slender thistle

drifting wedge
#

so make it global?

ionic dawn
#

Im on my phone rn mate

#

Cant help @blazing ravine

blazing ravine
#

ok

slender thistle
#

In your bot's main file,

bot = commands.Bot(...)
db = MongoClient()
bot.col = db["db1"]["db1"]```
#

Then, in the cog, use self.bot.col

#

You could use also find_one instead of iterating over returned value from .find

drifting wedge
#

1 sec

#

@slender thistle

#

im using client

#

should i replace all the "bots" with client?

slender thistle
#

which client

#

discord.Client?

drifting wedge
#

like im using client intad of bot

slender thistle
#

Then how are you using cogs if discord.Client doesn't support cogs

drifting wedge
#

like client.command

#

not bot.command

slender thistle
#

Ah, the variable

#

Yeah

drifting wedge
#

yea

#

wait @slender thistle

#

wut do i put in the commands.bot(...)

#

?

slender thistle
#

Don't you have that line already

drifting wedge
#

1 sec

#

mango_url = "url"
cluster = MongoClient("u tried")
db = cluster["db1"]
collection = db["db1"]

#

so just make these global?

slender thistle
#

Define "global"

drifting wedge
#

like just put that on the main file

still merlin
#

I'm trying to make a mute command, And a friend of mine who is testing can still talk, His only role is muted, is it because of the @.everyone role?/permissions, The role has send messages permission denied

drifting wedge
#

so i can pull from anywhere

slender thistle
#

Yes, the main file

#

And attach them to the commands.Bot object (client variable)

drifting wedge
#

@still merlin 1. make it so everyone and muted cant talk

slender thistle
#

Is the send messages permission ticked for the everyone role?

still merlin
#

But this bot isnt being used for custom servers, This is a moderation bot im working on with 30+ guilds

drifting wedge
#

wait wut?

#

like attach it?

still merlin
#

Is the send messages permission ticked for the everyone role?
@slender thistle yes

slender thistle
#

the green tick

#

then that's the issue

#

Allowed permissions overwrite the denied ones

drifting wedge
#

oooh

#

so i would put mango_url = "url"
cluster = MongoClient("sneaky boi 6000")
db = cluster["db1"]
collection = db["db1"] in the ()?

slender thistle
#

n

#

o

#

Are you familiar with OOP?

drifting wedge
#

no..

#

wait tho whats the issue? like whats the bug?

slender thistle
#

Any errors you are getting?

pseudo atlas
#

Sa

#

Bura türklerin bundan sonra

#

🇹🇷

#

Ehhe

slender thistle
#

-notr

gilded plankBOT
#

İngilizceden başka dillerde sohbet etmek için #memes-and-media kanalını, top.gg hakkında (Türkçe olarak da) destek almak için #support kanalını kullanın.
Bu kanalda Türkçe konuşmayın.

pseudo atlas
#

Şakaydı*

drifting wedge
#

Any errors you are getting?
@slender thistle no

#

i was yesterday tho

#

same code i think

#

but i dont think its important

pseudo atlas
#

Türkçe konuşun bee

#

Anlamiyorum

#

Ols

#

Pls

#

🎉 🎉 🇹🇷 🇹🇷

slender thistle
#

Are you blind

pseudo atlas
#

nE

#

Translate

midnight blaze
#

He doesnt speak a word in English

#

Just translated what he said

slender thistle
pseudo atlas
#

Ok ok

#

Sorry

drifting wedge
#

@slender thistle

#

so how would i attach it?

#

i saw

#

the message

#

but i dont understand it

slender thistle
#

I'd recommend going over OOP both in general and in Python

#

because my snippet does attach the collection to the bot object that you will later use

grim mesa
#

Shard 1's Client took too long to become ready.

#

can we help me pls?

delicate shore
#

wtf

#

also I use bot instead of client

split hazel
#

Try increase the timeout in client options

nimble kiln
#
    partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
    disableMentions: 'everyone'
});```
Did I do this right for disabling ateveryone? It still pings it ![thonk](https://cdn.discordapp.com/emojis/684488556844154905.webp?size=128 "thonk")
delicate shore
#

Try increase the timeout in client options
@split hazel how ?

#

Sorry i am new

drifting wedge
#
db = MongoClient()
bot.col = db["db1"]["db1"]``` shivaco told me to do this
delicate shore
#

to sharding

pale vessel
#

it's allowedMentions

drifting wedge
#

wut does it mean lol

nimble kiln
pale vessel
#

lemme check

nimble kiln
#

I mean I can do it the other way around, but I dont see anything wrong with what I did

pale vessel
#

same

nimble kiln
#

huh

#

you're disabling everyone and allowing it in the same eval

delicate shore
#

@split hazel pls help my won't go on

pale vessel
#

allowedMentions actually pings them but at the same time not

delicate shore
#

bot*

pale vessel
#

i have to disable that

#

disabledMentions just escapes it with a zws

#

it'll look like this: @pale vessel

#

but it doesn't ping

nimble kiln
#

Ok I'm confused

slender thistle
#

zws is a zero-width-space

nimble kiln
#

^thanks

pale vessel
#

works

#

i didn't need to disable my allowedMentions, it won't ping anyway lmfao

#

i'm so retarded

nimble kiln
#

I just wanted to disable everyone tho

#

Why didnt it pick that up 😄

pale vessel
#

works for me

nimble kiln
#
    partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
    allowedMentions: ['roles', 'users']
});```
This seems to "work" - It now returns an Invalid Form Body-error when everyone is mentioned
#

oh I think I'm understanding it wrong I guess?

#

I'll test around a bit

nimble kiln
#

oh oops

pale vessel
#

if you want to disable for all, just add an empty array for users

#

it'll work for roles too

drifting wedge
pale vessel
#

which isn't what you want...

nimble kiln
#

I guess this works? const client = new discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'], disableMentions: 'all' });

charred geyser
#

does anyone know how to chsnge the default location of the bots automatically created role

slender thistle
#

I doubt that's supported

charred geyser
pale vessel
#

@nimble kiln everyone didn't work?

charred geyser
#

but it lacks the permission to change "Members" nicknames

#

becuase they are above it

#

(node:28169) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions

pale vessel
#

most bots create a new role below their highest position and delete their old one

nimble kiln
#

@nimble kiln everyone didn't work?
@pale vessel Yeah, everyone didnt work as I wanted it. And the user mention still worked

charred geyser
#

most bots create a new role and delete their old one
@pale vessel ok thank you

pale vessel
#

edited

charred geyser
#

oh

#

wdym below their highest position?

pale vessel
#

let's say a bot named mee69 creates a new role to for example change their color. they would create a new role under their role

#

and use that instead

charred geyser
#

but that wouldn't allow it permissions over Member

pale vessel
#

if they have the permissions

charred geyser
#

MEE69 has admin

pale vessel
#

if not, then it can't do that

charred geyser
#

Member doesn't

#

so the command that i get ''DiscordAPIError: Missing Permissions" for is a command that changes all nicknames in a server to whatever you put after the command

pale vessel
#

all? 👀

charred geyser
#

but it only works if i manually move the MEE69 role above the Member role

#

not all but all except admins

delicate shore
#

Please guys

#

Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.

charred geyser
#
    message.guild.members.cache.forEach(member => {
        if(!member.hasPermission('ADMINISTRATOR')){
            member.setNickname(nick);
        }
    });

@pale vessel this is pretty much what it does

#

and nick is ``` let nick = message.content.slice((settings.prefix + "nickmass").length)

pale vessel
#

what role does this?

charred geyser
#

but if i run it when the MEE69 role is at its default location it doesn't have permissions

pale vessel
#

i see

charred geyser
#

only when moved

pale vessel
#

that's because it can't modify any roles that are higher than it, even with admin

#

member is higher than mee69 in this case

charred geyser
#

yeah

pale vessel
#

it's the role hierarchy

charred geyser
#

so how do bots deal with that?

#

generally

pale vessel
#

you have to deal with it

#

make the bot's role highest

#

or at least after administrator

charred geyser
#

yeah

#

so i just have it create a role on joining a guild

#

is it able to create roles higher than itself?

pale vessel
#

nope

#

that would be abusable lol

nimble kiln
#

So I dont know what I did differently, but after a few more restart this works now Confused

    partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
    disableMentions: 'everyone'
});```
pale vessel
#

i'm not sure if that would work since i have no idea what position discord puts for new roles

#

but if it doesn't have the perms, just send a message telling the owner to move the position manually

#

i'm sure there's a better way to do this though

charred geyser
#

yeah

#

i guess i can but that in the message when it joins

#

a guild

#

i finally managed to make my database and start logging settings into it

delicate shore
#

it says recommended shards 1

#

but it is still on 0

#

why

pale vessel
#

because shards start with 0

delicate shore
#

yes but it says 0/1

pale vessel
#

oh

#

shrug

delicate shore
#

:(

nimble kiln
#

It says recommended shards: 1 for me too

#

Shard 0 is your "1" shard, so yeah. Flazepe is right

#

I can't explain why it shows 0/1 tho ¯_(ツ)_/¯

delicate shore
#

okie

quartz kindle
#

shard id 0 out of 1 shards

#

i know its confusing

#

but thats how it works lul

charred geyser
#

tim!

#

there is data in my database 😄

quartz kindle
#

gj

charred geyser
#

thank you so much for your help

weak rain
#
Require stack:
- C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js
- C:\Users\Pujya Kumar\Desktop\Thunder\handlers\command.js
- C:\Users\Pujya Kumar\Desktop\Thunder\server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js:2:19)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\commands\\music\\drop.js',
    'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\handlers\\command.js',
    'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\server.js'
  ]
}
#

why npm is unable to find config.json

charred geyser
#

uhhh

#

idk

#

i use client.config = require('./config');

#

not ../config

#

oh

#

remove the extention

#

@weak rain

#

just type "../"

#

and you should get a thing to select the file but like

#

it shouldn't have an extention i think

weak rain
#

ok

#
Require stack:```
delicate shore
#

Hey @quartz kindle thanks but one more thing
I have the 2 main files
index.js - Sharding one
bot.js - My bot one

So in package.json do I change main to bot.js or leave it index.js only ???

And second thing
I use pm2 for monitoring
So do i do pm2 start index.js or pm2 start bot.js

digital ibex
#

because a config.json doesnt exist in the directory u provided @weak rain

pale vessel
#

@delicate shore the sharding one

weak rain
#

its open but @digital ibex

pale vessel
#

your sharding one starts the bot script

delicate shore
#

@delicate shore the sharding one
@pale vessel for which thing first ques or second

#

ok

pale vessel
#

both

delicate shore
#

but it gives me an error

charred geyser
#
Require stack:```

@weak rain type ../ and it will list the files available

weak rain
#

?

#

where

charred geyser
#

like this

weak rain
#

kk

#

oh

#

done

ionic dawn
#

Relative routes

#

.. means back in the folder and . In the same folder

charred geyser
#

yea

delicate shore
#

@pale vessel it says shard 0 exited before client became ready

pale vessel
#

that, i don't know

#

something with discord

charred geyser
#

bruh.

pale vessel
#

or did the script actually exit?

#

nah

delicate shore
#

what

charred geyser
#

how long should it take for my bot to get checked

pale vessel
#

like 3-4 weeks

charred geyser
#

rip in peaces :((

delicate shore
pale vessel
#

it did exit

#

the process exited

delicate shore
#
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('bot.js', {
    // for ShardingManager options see:
    // https://discord.js.org/#/docs/main/v11/class/ShardingManager

    // 'auto' handles shard count automatically
    totalShards: 'auto', 

    // your bot token
    token: ''
});

// Spawn your shards
manager.spawn();

// The shardCreate event is emitted when a shard is created.
// You can use it for something like logging shard launches.
manager.on('shardCreate', (shard) => console.log(`Shard ${shard.id} launched`));```
#

the process exited
@pale vessel how to solve the issue then

pale vessel
#

ask tim mmLol

#

i haven't shard

delicate shore
#

@quartz kindle can you Help :( 😢

drifting wedge
#

hey

#
async def on_message(self, ctx):
    mango_url = "url"
    cluster = MongoClient("u tried noob")
    db = cluster["db1"]
    collection = db["db1"]
    author_id = ctx.author.id
    guild_id = ctx.guild.id

    author = ctx.author

    user_id = {"_id": author_id}

    if ctx.author == client.user:
        return

    if ctx.author.bot:
        return

    if(collection.count_documents({}) == 0):
        user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
        collection.insert_one(user_info)

    if(collection.count_documents(user_id) == 0):
        user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
        collection.insert_one(user_info)

    exp = collection.find(user_id)
    for xp in exp:
        cur_xp = xp["XP"]

        new_xp = cur_xp + 1

    collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)

    #await ctx.channel.send("1 xp up")

    lvl = collection.find(user_id)
    for levl in lvl:
        lvl_start = levl["Level"]

        new_level = lvl_start + 1

    if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
        collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
        await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")```
#

this is my levels code

#

but its just not working

#

like no errors

#

just not working

delicate shore
#

py weirdsip

charred geyser
#

py

digital ibex
#

whats rong with python

#

?

charred geyser
#

nothing i just haven't learnt it 😄

drifting wedge
#

py

#

also how do i use a command with cogs:

delicate shore
#

why does this happens

charred geyser
#

maybe you ran the bot twice?

delicate shore
#

no

#

i mean it should give number

charred geyser
#

oh

delicate shore
#

of servers

sonic lodge
#

fetchClientValues returns a promise

weak rain
#
Require stack:
- C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js
- C:\Users\Pujya Kumar\Desktop\Thunder\handlers\command.js
- C:\Users\Pujya Kumar\Desktop\Thunder\server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js:2:19)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\commands\\music\\drop.js',
    'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\handlers\\command.js',
    'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\server.js'
  ]
}```
#

why

sonic lodge
#

in your eval command, you should check if the result of eval returns a promise or not

#

if it is, await it

fringe axle
#

he can't find the module

weak rain
#

but

#

i listed it properly

#

:/

charred geyser
#

@weak rain as we said before ../ goes back and ./ is in the dir

fringe axle
#

@weak rain where is your config and where's the file with the ../config

charred geyser
#

are you sure it should be ../

weak rain
#

@fringe axle

fringe axle
#

Yea

delicate shore
#

but i am not missing

fringe axle
#

And your file with the config require?

weak rain
charred geyser
#

where are you requiring it

weak rain
#

like wdym

sonic lodge
#

i meant await the promises in the code for your bot's eval command

charred geyser
#

where are you saying ../config

#

what file

fringe axle
#

In what file?

#

Where is this file?

sonic lodge
#

drop.js

fringe axle
#

Where is drop.js

sonic lodge
#

if you are in: Thunder\commands\music\drop.js
then config.json is supposedly located at: Thunder\commands\config.json
^ that's what you're trying to find atm

weak rain
#

no

sonic lodge
#

where is it located?

weak rain
#

its open

#

just in Thunder\config.json

vale garden
#

hellooooo
i have a question

client.on("message", function(message){
    console.log(`message is created -> ${message}`);
});```
like how this does something when one message is sent
is there a way to have a function that excutes after x messages
#

lol

sonic lodge
#

that's the problem

#

it should be ../../config.json to go back two directories

weak rain
#

oh

vale garden
#

cansomeone

#

help me

delicate shore
#

Can anyone help me with the question I asked above

vale garden
#

same

#

brooo

#

thats my old pfp

charred geyser
#

multi

vale garden
#

lol

sonic lodge
#

i meant await the promises in the code for your bot's eval command

vale garden
#

wat

charred geyser
#

add a counter

vale garden
#

how

#

like in the brackets?

charred geyser
#

let counter = 0;

vale garden
#

oh

delicate shore
#

@sonic lodge i even did in the code itself

vale garden
#

jj

delicate shore
#

did not work

vale garden
#

*kk

sonic lodge
#

@vale garden try channel.awaitMessages()

charred geyser
#

then after every log do counter++;

vale garden
#

wait what

#

which one

sonic lodge
charred geyser
#

if counter = whatever do this

vale garden
#

ok thx

delicate shore
#

bot.shard.fetchClientValues('guilds.cache.size').then(console.log);

I use bot so do I need to change Client Values to BotValues

pale vessel
#

depends on what you're trying to achieve

sonic lodge
#

no

pale vessel
#

it's a function name lol

delicate shore
#

but it resturns a p[romise

pale vessel
#

await it

delicate shore
#

returns* promise*

pale vessel
#

and flatten it if you need to

charred geyser
#

just do bot = good;

#

ez

#

i wish it was that easy pEnSiVe

delicate shore
pale vessel
#

use .then()

delicate shore
#

do i need to use async in eval also

restive furnace
#

no

pale vessel
#

remove await and add the send method inside .then()

#

then(e => message.channel.send(JSON.stringify(e)))

#

don't put e in ``

#

that would be object Object

delicate shore
#

don't put e in ``
@pale vessel where?

pale vessel
#

nm i read it wrong

delicate shore
#

ok

pale vessel
#

add one more )

delicate shore
#

i tried

#

did not work either

pale vessel
#

what didn't work?

delicate shore
#

wait whaat

#

undefined???

restive furnace
#

because it is undefined

#

try this.client.guilds.cache.size

delicate shore
#

try this.client.guilds.cache.size
@restive furnace but i am using ClientValues

pale vessel
#

no [@restive furnace]

sonic lodge
#

doesn't eval() return the return value of the last expression

#

there is no last expression

delicate shore
#

So???

sonic lodge
#

there's nothing to return at the end

pale vessel
#

it's correct

delicate shore
#

So what should I do now ? ;-;

sonic lodge
pale vessel
#

it's not the same as eval

#

it's running it for each shard

#

and return it as array

#

well, it's kind of like eval

#

but not like let x = xxx

#

it just runs that code

sonic lodge
#

it's not about fetchClientValues, it's about the actual eval function

pale vessel
#

so guilds.cache.size is valid

#

oh

#

lmfao

#

that shouldn't matter

delicate shore
#

:(

pale vessel
#

it's supposed to send a message

delicate shore
#

I am so done

sonic lodge
#

did it send a message

delicate shore
#

no

pale vessel
#

check console

delicate shore
#

Ok

#

nothing

sharp swift
#

How can i add a picture to my bot's description? Someone told me I need to learn how to code with html or css

pale vessel
#

you can use markdown

delicate shore
#

Can I do something like const bot = new Discord.Client()
const client = bot

#

will they both work same

pale vessel
#

what

sharp swift
#

you can use markdown
What is markdown?

pale vessel
#

it's what you use on discord, `**hello**` etc

sharp swift
#

ok thx

delicate shore
#

what
@pale vessel can i use bot and client both as same

pale vessel
#

![text](url) can be used for images

delicate shore
#
const client = new Client({
  disableMentions: "everyone"
});
const bot= client;```
pale vessel
#

it's the same

#

discord defines it as client internally

delicate shore
#

so i can do bot.login and client.login also?

pale vessel
#

yes yes

delicate shore
#

it will be same

#

K thanks

pale vessel
#

this is why you would usually name your client as client

#

since having your client defined as bot and accessing something like guild.client would be confusing

#

but that's just how it works

delicate shore
#

ok thnx

#

But @pale vessel what should I do of my other issue

dusky mason
#

lol noob pfp

#

i edited that pfp btw

earnest phoenix
#

Uhhhhh

dusky mason
#

yeah i know off topic

#

im just mentioning it lol

pale vessel
#

the fetchClientValues() one or the shard process exit one?

delicate shore
#

the fetchClientValues() one or the shard process exit one?
@pale vessel Yo I resolved the promise and idk how it worked this time thanks

vale garden
#

hi

#

can someone tell me how you can send messages to a specific channel on a specific server

#

lol

thick gull
#

so, timers usually end when the bot restarts correct? how would I avoid this

ionic dawn
#

Thats a good question

digital ibex
#

use a database

ionic dawn
#

Or run the timers outside the bot realstate

vale garden
#

can someone tell me how you can send messages to a specific channel on a specific server
plz help

#

lol

sudden geyser
#

What library are you using

ionic dawn
#

Select guild and channel

vale garden
#

how

#

do i

ionic dawn
#

fetching by id

#

Djs or py?

vale garden
#

ok

#

js

#

but like how do i do that

ionic dawn
#

Look at discord.guide to get channels and guilds by id

vale garden
#

could you explain a bit more

#

kk

ionic dawn
#

Its pretty easy

#

Just read about it in djs docs

vale garden
#

no but the thing is

#

how do i make it send after getting the ids

ionic dawn
#

Define the channel and the guild

vale garden
#

kkk

#

ill see

#

tehre

#

lol

#

*there

ionic dawn
#

Like

chn = get by id bla bla
chn.send(bla)

#

And the guild has to be before that

#

Test and fail, thats the best way to learn

pale vessel
#

docs*

ionic dawn
#

After read them

pale vessel
#

but yeah it does have predictable abstractions

vale garden
#
bot.on("message", function(message){
    bot.channels.get(`718760245014298654`).send(`${message}`);
});
#

is there something wrong here

pale vessel
#

cache

vale garden
#

oh

#

ohhhh

#

thnx

pale vessel
#

that looks like some huge logger lmao

#

[object Object]
[object Object]
[object Object]
[object Object]

vale garden
#

bot.channels.cache.get?

ionic dawn
#

v12 is full of .cache elmoFast

vale garden
#

cuz that isnt working

pale vessel
#

yes

vale garden
#

lol ik

#

it isnt working for some reason

ionic dawn
#

<Client>.channel.cache.get(channelID)

vale garden
#

thats what i did

#

id in quotes right

ionic dawn
#

Whats the error

#

Yea

vale garden
#

no errorit just isnt working

ionic dawn
pale vessel
#

bruh

ionic dawn
#

do
const chn = (the thing)
chn.send("Hi")

pale vessel
#

that's the same

vale garden
#

hi im back

#

i fixed it nvm

ionic dawn
#

Its channel

#

Not channels

#

Typo

earnest phoenix
#

How do i make my bot send welcome messages?

opal plank
#

which language/library?

earnest phoenix
#

discord.js

opal plank
#

listen to guildMemberAdd event

#

it'll return a member object

#

you can just send the message onto the member guild with the message

earnest phoenix
#

Oh no, member objects, i give up

opal plank
#

you dealing with an OOP lang and you afraid of objects?

#

what

earnest phoenix
#

I'm new ;-;

drifting wedge
#

who can help with mongo?

weak rain
#

My bot exits vc playing music

opal plank
#

start with objects intro then

#

thats like, the whole point of an OOP

#

its the super basics

weak rain
opal plank
weak rain
#

and goes offline

earnest phoenix
#

Aight, thanks Erwin, i'm trying to learn as much as i can 😄

opal plank
#

np mate

#

we all start somewhere, dont be shy to ask

weak rain
#

@opal plank u know anything?

opal plank
weak rain
#

nd then sends this

#

before going offline

ionic dawn
#

When the guildaddmember event is sended you can take the user info and send something to an specific channel using client.channel.cache.get(id)

#

@earnest phoenix

opal plank
#

who needs linters anyway

ionic dawn
#

Like an embed with the username/avatar/welcome message

opal plank
#

@ionic dawn its not guildaddmember

#

i pointed out taht already

weak rain
ionic dawn
#

Whatever the event name is

weak rain
#

;-;

ionic dawn
#

Didnt read your message

#

realstate 👍

opal plank
weak rain
#

Hey sexy_me Why Ignore

opal plank
weak rain
#

i asked

#

;-;

#

@opal plank

ionic dawn
#

He mentioned by using sticker

opal plank
#

of course i dont know everything, theres quite a few things i need to learn as well

ionic dawn
#

What a god

weak rain
#

hm

opal plank
#

im going to start meta stuff soon hopefully

ionic dawn
#

Thunder

#

You using ytdl?

weak rain
#

Yes

ionic dawn
#

Do you have a queue?

weak rain
#

queue limit or command

ionic dawn
#

Music queue

weak rain
#

No

ionic dawn
#

The audio starts playing and then crashes?

weak rain
#

after 10-20 seconds

#

it crashes

#

bot too

ionic dawn
#

Can I see code?

weak rain
#

yea

ionic dawn
#

Also, do you have an error handler?

weak rain
#

Yes

ionic dawn
#

And how is it crashing

weak rain
#

no

opal plank
ionic dawn
#

What

opal plank
#

imagine having an error handler and crashing

weak rain
#

wait

#

i m saying this

#

.catch error one

ionic dawn
weak rain
#

after crashing logs -->>

ionic dawn
#

Send hastebin

weak rain
ionic dawn
#

Yeah that crash log is a mess of ytdl

weak rain
#

oh

opal plank
#

arent you using opus?

weak rain
#

so what should i do

ionic dawn
#

First, hastebin the code blacklol

weak rain
#

music.js

#

or commands

opal plank
#

i hate that my linter does this

#

make one line

vale garden
#

hi

ionic dawn
#

is there any difference between ytdl-core and ytdlDiscord?

#

im not using the "Discord" one

vale garden
#

so this is used to log all messages from my bot guilds

 bot.on("message", function(message){
    bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
});
#

how do i make it not log its own messages

opal plank
#

oh god

#

fam

vale garden
#

me?

opal plank
#

i sure hope your bot isnt public

weak rain
#

yes

opal plank
vale garden
#

lol

digital ibex
#

an if statement

vale garden
#

it isnt but why

#

see this does work

opal plank
#

good cuz thats a good way to get ratelimited

vale garden
#
 bot.on("message", function(message){
      if (!message.author.bot) {return}
      else {
    bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
      }
});
opal plank
#

no need for {}

vale garden
#

whats that tho

opal plank
#

that'd remove bots

#

not self

vale garden
#

ok but still not working

ionic dawn
opal plank
#

also its a true statement not false

#

if (true) return

vale garden
#

oh

#

lmao

#

im dumb

#

lol

opal plank
#

if(!false(true)) return

ionic dawn
#

@weak rain back with you, did you know if theres a difference between packages?

weak rain
#

wdym

ionic dawn
#

ill give a look at your code to see why crashes anyw

opal plank
#

@vale garden also message is an object

#

if you want to send contents of the message, use message.content

#

otherwise you sending the whole object stringyfied

ionic dawn
#

wdym
@weak rain ytdl-core is a package, and ytdl-core-Discord is another

weak rain
#

hm

ionic dawn
#

probably based in the same but with discord stuff

#

anyway ill see the code, brb

weak rain
thick gull
#

use a database
@digital ibex I don't wanna ping the database and check if its time every time a message is sent or every few minutes. Should I check the database every X minutes?
Or run the timers outside the bot :realstate:
@ionic dawn How would I do this?

ionic dawn
#

@weak rain my head is like BoomBam

drifting wedge
#

how do i add commands to cogs?

#

using py

weak rain
slender thistle
#

@commands.command()
async def cmd(self, ctx, etc):

ionic dawn
drifting wedge
#

thats not working

weak rain
drifting wedge
#

wait\

#

it is

#

9im just dumb

digital ibex
#

running timers outside the bot is no different from running it inside the bot bc they’re both processes, also could cause some memory leaks if ur using it as database, also only complicating things since you’d have to do stuff with ipc and stuff. you use setTimeout so you dont need to check the database at all. what you’d do is something like:

<add db stuff here to save the time>
const time = <time in ms from db here>
setTimeout(() => {
      console.log(“time to remind them. the time has ended”);
}, time);
#

im on mobile so there may be slight mistakes i’ve accidentally made

#

@thick gull

drifting wedge
#

discord.ext.commands.errors.ExtensionFailed: Extension 'meme' raised an error: TypeError: cogs must derive from Cog
sys:1: RuntimeWarning: coroutine 'Command.call' was never awaited

#

wut is this/

digital ibex
#

await it

drifting wedge
#

where?

digital ibex
#

before where its erroring, same line

drifting wedge
#

well i dont know where

vale garden
#

hi

#
case 'lol':
      bot.on("message", function(message){
      if (message.author.bot) {return}
      else {
    bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
      }
});
break;
#

so this is the command i mae

#

made

#

so it takes people's messages and sends them in another channel

pale vessel
#

oh lord

vale garden
#

so does anyone know how i can make a command which stops this

#

lol

#

wat

pale vessel
#

use awaitMessages() or createMessageCollector() please

drifting wedge
#

me?

pale vessel
#

multi

opal plank
#

ohmy god wtf

#

an event listener on a switch case?

#

@vale garden

vale garden
#

oof my connection

#

wat

opal plank
#

you dont do that

vale garden
#

broo that doesnt matter

#

lol

opal plank
#

it does tho

vale garden
#

just tell me how do i stop it

#

why

opal plank
#

cuz u adding event listeners onto a switch dude

vale garden
#

yea wdym

opal plank
#

switch im assuming is based off something you fired

#

probably an event

misty sigil
#

is that a message logger I see

slender thistle
#

@drifting wedge class Meme(commands.Cog)

vale garden
#

well see switch case is being used cuz i use it for my command handler

opal plank
#

then you saying when this happens, listen to this.

#

you arent sending anything

vale garden
#

wat

opal plank
#

it'll just start listening

drifting wedge
#

@drifting wedge class Meme(commands.Cog)
@slender thistle i have class meme(commands.Cog): def __init__(self, client): self.client = client

vale garden
#

ik

opal plank
#

just remove bot.on()

#

dont do a listener inside a switch

vale garden
#

why tho

opal plank
#

why u even got that there?

vale garden
#

ok i still dont get it

#

cuz

slender thistle
#

And how are you loading that cog

vale garden
#

switch is used for my cmd handler

#

but

#

eh idk why i didnt just make a file

#

well i will

#

i was just testing here

opal plank
#

dude, other way around

vale garden
#

whatt

#

me

#

?

opal plank
#

listen to event, once event is fired, THEN you get a file to handle it

vale garden
#

oh

#

kk

opal plank
weak rain
#

is music great for a bot?

vale garden
#

so basically

opal plank
#

the listeners need to be always declared on most cases

weak rain
#

or this will be okay

vale garden
#
bot.on("message", function(message){
if (command === "lol") {
      if (message.author.bot) {return}
      else {
    bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
      }
});
}
#

like this?

opal plank
#

yes

ionic dawn
vale garden
#

kk

#

but can you tell

opal plank
#

dont do an event listener on an if, do the logic INSIDE the listener

earnest phoenix
#

E

vale garden
#

me

#

how i can stop it

#

like after executing

weak rain
#

@ionic dawn Pro

opal plank
#

add some logic, set a variable or something

weak rain
#

I seriously need Srcs

#

for music

ionic dawn
#

the queue is fucked and Im workin on another thing so kek

opal plank
#

let stop = true;

if(stop) return;

vale garden
#

can i like

#

see

opal plank
#

there, it'll stop

vale garden
#

can i like

#

make a timer

#

like

#

if there are no messages for x secs

#

it stops automatically

opal plank
#

of course

vale garden
#

if so, how

#

how do i

opal plank
#

just add the logic for it

weak rain
#

do u have any src @ionic dawn

opal plank
#

2 variables and one set interval

ionic dawn
#

ive watch a ytdl video

#

and used the youtubeAPI

weak rain
#

OwO

vale garden
#

or instead

#

can i like just stop it from sending

#

by a command

ionic dawn
#

youtubeAPI prevent to force people to use links

#

user searchs are easier and more comfy

opal plank
#
let stop:boolean = false;
let mCount:number = 0;

setInterval(() => {
if(mCount < threshHold) stop = true;

}, timer)

bot.on('event' () => {
if(stop) return;
//logic
})
#

@vale garden

vale garden
#

alr let me see

opal plank
#

something simple like this would be automatic

#

though it would stop and never restart

#

if you want a trigger, like a command, just adjust a variable

vale garden
#

oh yea

#

nice

#

thnx

opal plank
misty sigil
#

say I wanna play a 24/7 stream from a url — how would I do it using FFMPEG?

opal plank
#

im legit about to go on github cause a second pandemic i shit you not, ive never seen such a shit library and api merged together to create this one monstrosity that we call Twitch

#

thats it

#

no trace

#

no log

#

no info

#

just hey, i error, have fun

#

and then just stops

drifting wedge
#

And how are you loading that cog
@slender thistle ext load

misty sigil
#

the ffmpeg stream stops eventually

drifting wedge
#

exts=['music', 'meme']

slender thistle
#

Show full file for the meme file

#

code for the meme file

drifting wedge
#

entire file?
@slender thistle

slender thistle
#

Mhm

drifting wedge
#
import discord
import praw
from discord.ext import commands



class meme(commands.Cog):
    def __init__(self, client):
        self.client = client

@commands.command()
async def meme(self,ctx, memetype='Memes', other='Memes'):
    reddit = praw.Reddit(client_id='butt',
                         client_secret='pp',
                         user_agent='ur mom')
    """Posts a meme from a subreddit of your choice."""
    memetype = memetype.lower()
    if memetype == 'memes':
        memes_submissions = reddit.subreddit('Memes').hot()
    elif memetype == 'dank':
        memes_submissions = reddit.subreddit('dankmemes').hot()
    elif memetype == 'deepfried':
        memes_submissions = reddit.subreddit('deepfriedmemes').hot()
    elif memetype == 'medical':
        memes_submissions = reddit.subreddit('medicalschool').hot()
    elif memetype == 'anime':
        memes_submissions = reddit.subreddit('animememes').hot()
    elif memetype == 'history':
        memes_submissions = reddit.subreddit('historymemes').hot()
    elif memetype == 'nuked':
        memes_submissions = reddit.subreddit('nukedmemes').hot()
    elif memetype == 'surreal':
        memes_submissions = reddit.subreddit('surrealmemes').hot()
    elif memetype == 'other':
        memes_submissions = reddit.subreddit(other).hot()
    elif memetype == 'mean':
        memes_submissions = reddit.subreddit('MeanJokes').hot()
        post_to_pick = random.randint(1, 100)
    for i in range(0, post_to_pick):
        submission = next(x for x in memes_submissions if not x.stickied)
    await ctx.send(submission.url)

def setup(client):
    client.add_cog(meme(client))```
weak rain
#

sending code

#

my VSC crashed

#
const fetch = require("node-fetch");


 module.exports = {
  name: "phub",
  category: "image",
  description: "PornHub Quote",
  run: async (bot, message, args) => {

    let user = await message.mentions.members.first()
    let text = args.slice(1).join(" ")

    if(user){
        text = args.slice(1).join(" ");
    } else {
        user = message.author;
    }

    if(!text){
        return message.channel.send("**Enter Text!**");
    }

    let m = await message.channel.send("**Please Wait...**");
    try {
        let res = await fetch(encodeURI(`https://nekobot.xyz/api/imagegen?type=phcomment&username=${user.username}&image=${user.displayAvatarURL({ format: "png", size: 512 })}&text=${text}`));
        let json = await res.json();
        let attachment = new Discord.MessageAttachment(json.message, "phcomment.png");
        message.channel.send(attachment);
        m.delete({ timeout: 5000 });
    } catch(e){
        m.edit("Error, Try Again! Mention Someone");
    }
}
};
#

if i dont mention if works fine

opal plank
#

i give up

weak rain
opal plank
#

OOOOOOOOOOOOOOOOOOOOOOOOOOOH SHIT

#

i found it

opal plank
#

jesus christ the lib cant handle this much traffic

weak rain
opal plank
#

oh god

#

hastebin

earnest phoenix
#

oh shorry

opal plank
#

@earnest phoenix

earnest phoenix
#

I'm making a bot to give information about covid 19, everything is fine but I don't know why when I search for a country with spaces I get "undefined" instead of the data ... My code: https://hastebin.com/atufipifax.http

opal plank
thick gull
#

$ space {}

opal plank
#

lets start there

thick gull
#

on multiple

#

the request too

opal plank
#

also that domain...

#

corona.lmao.ninja

earnest phoenix
#

yeah yeah, im using ${country} for states, country, and continents

opal plank
#

nono

#

u didnt get what we meant

#

theres a SPACE there

earnest phoenix
#

hmm

#

ah sht

thick gull
#

you have to replace the space in the stuff the user puts in

opal plank
#

there SHOULDNT BE

thick gull
#

yeah there shouldnt be a space eitehr

#

but

#

"united states" >> "united+states"

#

depending on how it handles those

opal plank
#

^^

thick gull
#

also country = args[1]

#

so if its split by spaces

opal plank
#

what if someone wants united states?

#

args 1 is only united

thick gull
#

args[1] = united args[2] = states

opal plank
#

yes, but u defidning country as args[1]

thick gull
#

yeah

earnest phoenix
#

same

opal plank
#

show updated code

earnest phoenix
#

ok

opal plank
earnest phoenix
opal plank
#

this will always return undefined

#

parse

#

remove space

#

JSON.parse () => Json.parse()

thick gull
#

is that a seperate message listener for every single command 😩

opal plank
#

i sure hope not

thick gull
#

memory usage must be painful there

opal plank
#

that indentation giving me nightmares too

earnest phoenix
thick gull
#

the json is undefined

opal plank
#

await it

thick gull
#

the server doesnt have it

opal plank
thick gull
#

i think

#

im not sure kekw

opal plank
#

actually nevermind

#

he doing callback

#

console.log(data)

earnest phoenix
#

so what can i do?¿

opal plank
#

you can try what i said

#

¯_(ツ)_/¯

delicate shore
earnest phoenix
#

ah ok

#

xd

thick gull
#

replace spaces with %20 btw

sweet kestrel
#

help

#

2020-09-03T15:59:47.551884+00:00 app[worker.1]: mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (111 Connection refused)

thick gull
#

the website is dying rn

sweet kestrel
#

heroku error

thick gull
#

you cant use storage on heroku

opal plank
sweet kestrel
#

💦

#

wait

#

what?

#

I can't?

thick gull
#

no

opal plank
#

its not a proper vps

thick gull
#

heroku doesnt let you save anything

misty sigil
#

vps*

earnest phoenix
delicate shore
#

Yes

thick gull
#

you need a remote database

sweet kestrel
#

is there any free hosting?

thick gull
#

matthew

sweet kestrel
#

with database

misty sigil
#

no

thick gull
#

do the vps thing

delicate shore
#

State doesn't exist

sweet kestrel
#

matthew?

#

what is that

opal plank
#

@earnest phoenix then theres your error

misty sigil
#

@earnest phoenix is that a message listener every command?

opal plank
#

¯_(ツ)_/¯

thick gull
sweet kestrel
#

lmao

thick gull
#

any """""""""""free""""""""""" hosting is either:

  1. not intended to be used as hosting for bots
  2. not actually suitable for hosting for bots
  3. not actually free
  4. will get your token stolen
  5. all of the above
#

got it

sweet kestrel
#

oh

misty sigil
#

any """""""""""free""""""""""" hosting is either:

  1. not intended to be used as hosting for bots
  2. not actually suitable for hosting for bots
  3. not actually free
  4. will get your token stolen
  5. all of the above
#

SHIT

thick gull
#

ha ha

opal plank
#

can we add 6) Shit

#

?

sweet kestrel
#

lol

thick gull
#

okay hear me out: start a hosting service but add ads to their bot

sweet kestrel
#

wait, but i want my database

earnest phoenix
sweet kestrel
#

is there a way?

thick gull
#

if your gonna keep using heroku use a remote database, it MIGHT work

opal plank
#

everytime someone adds the bot it sends a massive wall with an ad to your vps

thick gull
#

im not sure

earnest phoenix
#

how can i replace spaces with %20

sweet kestrel
#

remote database?

opal plank
sweet kestrel
#

nani

thick gull
#

@earnest phoenix does it do it automatically?

opal plank
#

yeah

#

databases dont need to be local

earnest phoenix
#

@earnest phoenix does it do it automatically?
@thick gull what

thick gull
#

cause if its /blah blah it will just be /blah

delicate shore
#

how can i replace spaces with %20
@earnest phoenix join args with that

thick gull
#

right?

#

iirc

misty sigil
#

how can i replace spaces with %20
@earnest phoenix encodeURIComponent

opal plank
#

same way you connecting to 'localhost' you can connect to, guess what, an 'ip'