#discord-bots

1 messages · Page 452 of 1

valid niche
#

or wait i see you already shared above

#

my bad

manic wing
#

idk, most people try and check if any msg.content in word for idk like word filters

valid niche
#

if you fetchone it only returns the row, if you fetchall it returns a tuple of all the rows selected, you need to make a for loop to iterate and then compare that

slate swan
novel cargo
#

@fading mica

winged mist
#

anyone know why im getting this error message?

cloud bison
winged mist
valid niche
winged mist
#

Fixed it, thanks though

slate swan
#

bro me learning

waxen granite
#

how can i dump 2 channel ids in a json?

#
embedchannels = {"epicList": [embedchannel]}
        with open("./botFiles/embedChannels.json", "w") as f:
            json.dump(embedchannels, f) ```
#

this only dumps 1 id

vagrant brook
#

Put 2 ids in embedchannel?

hoary gust
#

@waxen granite r u using json as a db?

waxen granite
#

yes

hoary gust
#

@waxen granite ah don't use it as a db

waxen granite
slate swan
#

How i can remove row in aiosqlite

waxen granite
vagrant brook
hoary gust
#

@slate swan use, DELETE

waxen granite
#

okay

hoary gust
#

@waxen granite json is not a db

vagrant brook
#

Well, it works

hoary gust
#

Though it is not preferred

slate swan
hoary gust
#

@slate swan wait lemme show u a example

slate swan
waxen granite
#

@vagrant brookprint only 1

vagrant brook
#

Can I see your full command

hoary gust
#
await cursor.execute(("DELETE FROM table_name WHERE your_args = ?"), (your_value,))
vagrant brook
#

You're only reading in 1 channel

#

How do you expect to be able to input 2

waxen granite
#

ye that

#

:3

slate swan
#

ok

#

thx

hoary gust
#

Oops there is a mistake

vagrant brook
waxen granite
#

hm

vagrant brook
#

!d discord.ext.commands.Greedy

unkempt canyonBOT
#

ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
waxen granite
#

btw i forgot but what does * depict?

hoary gust
#

!e
await cursor.execute(("DELETE FROM table_name WHERE your_args = ?"), (your_value,))

unkempt canyonBOT
#

@hoary gust :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 | SyntaxError: 'await' outside function
hoary gust
#

!e
cursor.execute(("DELETE FROM table_name WHERE your_args = ?"), (your_value,))

unkempt canyonBOT
#

@hoary gust :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'cursor' is not defined
hoary gust
#

Lol

#

I haven't defined cursor

#

Lol

vagrant brook
#

Well, in discord.py specifically, it tells the bot to take everything left into the argument behind the *

hoary gust
#

But that will work

waxen granite
vagrant brook
#

Try it and see

waxen granite
#

greedy is not defined

vagrant brook
#

You have to import it from discord.ext.commands

waxen granite
#

or should i ust use commands.Greedy?

#

just

spring flax
vagrant brook
#

remember, it returns a list so you can't call .id on it

waxen granite
#

ye it gave that error xd

#

how can i get the id?

vagrant brook
#

You have a list of TextChannel objects

#

Just loop over it and insert the IDs into a list ¯_(ツ)_/¯

slate swan
#

It's for simple evaluations

pale turtle
#

If I want to send an Attachment how can I? I tried .save but anyone know how to save it to the current dir?

slate swan
#

You need to send or save?

pale turtle
#

To send

#

From message.attachments[0]

slate swan
#

Ah means resend from a message

#

!d discord.Attachment.to_file

unkempt canyonBOT
#

await to_file(*, use_cached=False, spoiler=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Converts the attachment into a [`File`](https://discordpy.readthedocs.io/en/stable/api.html#discord.File "discord.File") suitable for sending via [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send").

New in version 1.3.
pale turtle
#

Oh I forgot it exists

#

Thanks

waxen granite
#

like for embedchan in channel:
what next?

lofty heron
#

hi, idk why the game status thing doesn't work but console doesn't return any errors

import json
import os
import platform
import random
import sys
from discordTogether import DiscordTogether
import discord
from discord.ext import commands, tasks
from discord.ext.commands import Bot

client = commands.Bot(command_prefix="tost!")
togetherControl = DiscordTogether(client)

bot = Bot(command_prefix=["tost!"], intents=discord.Intents.default())

# Setup the game status task of the bot (hopefully)
@tasks.loop(minutes=1.0)
async def status_task():
    statuses = ["with kittens", "with fire"]
    await bot.change_presence(activity=discord.Game(random.choice(statuses)))
reef shell
#

you need to start the task function

lofty heron
#

no it's just in the main file

lofty heron
reef shell
#

use status_task.start() inside on_ready event

lofty heron
#

oke tenks

#

so @event.on_ready?

reef shell
#

@bot.event
async def on_ready():
change_status.start()
print(f'logged in as {bot.user}')

#

like this

lofty heron
#

oke tenks

#

hmm brackets on end of bot.event?

#

hmm oke

reef shell
lofty heron
#

thanks :D

lofty heron
slate swan
#

function?? 👀

#

You forget to add a function

waxen granite
#

add ()

slate swan
#
@status_task.before_loop
async def whatever():
    await blah()
lofty heron
#

oh true

#

lol i was getting missing arg errors

waxen granite
#

who isnt xd

lofty heron
#

me extra noob laughers

maiden fable
#

No u ain't. That's me cat_headbang

#

?

waxen granite
#

ask them to help us then xd

slate swan
#

Are just learning the basics will be enough to make py.bots?

#

bc i'm still learning python

lofty heron
#

lol

maiden fable
slate swan
#

Yeah

#

i'm learning py so I could make bots and web dev

waxen granite
#

how to get the channel id from a list of textchannel objects?

slate swan
#

@tawdry perch
In the code you help me. I can do the opposite of that?
Like !deleteblword <name of bl word>

maiden fable
# slate swan Yeah

Well, it really depends tbh. I never learnt any Python before getting into bot making (I didn't even know how to call a function or what's the use of function)

#

But it's recommended you learn OOP and stuff

#

classes, objects and stuff

waxen granite
#

well try copying and understanding some commands, in a month you will be good to make some commands yourself

lofty heron
#

kek i fixed some stuff this should be good right?

@bot.event
async def on_ready():
    change_status.start()
    print(f'logged in as {bot.user}')

@tasks.loop(minutes=1.0)
async def status_task():
    statuses = ["with kittens", "with fire", "krunker (not sponsored)"]
    await bot.change_presence(activity=discord.Game(random.choice(statuses)))

@status_task.before_loop
async def mrow():
    await bot.wait_until_ready()
waxen granite
#

py is just coding in english

lofty heron
slate swan
lofty heron
#

lol

reef shell
#

use this attribute

spring flax
#

.id

slate swan
#

You can send docs or something?

spring flax
spring flax
reef shell
slate swan
spring flax
#

oh

waxen granite
spring flax
#

sure

execute("DELETE FROM table_name WHERE put_your_conditions", (put_your_values))

@slate swan

slate swan
#

oh

waxen granite
#

oh

reef shell
#

would be better

vagrant brook
slate swan
reef shell
#

then do whatever you want to do

slate swan
slate swan
spring flax
#

delete the whole record?

slate swan
slate swan
spring flax
slate swan
#

ok.

#

any1 knows how I can forward messages from my one channel to another? they changed the api I think

#

if i upload this it wont work right

slate swan
slate swan
surreal creek
#

can anyone tell how to check who is getting mentioned in a message ?

surreal creek
#

pls help me....

#

can anyone tell how to check who is getting mentioned in a message ?

slate swan
vagrant brook
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

surreal creek
#

k thnx

surreal creek
vagrant brook
#

What is your if statement

surreal creek
#
@bot.event
async def on_message(message):
  if message.mentions:
    print('mention detected')
    if f'@T3raStack#1234' in message.content:
      await message.channel.send('The User is AFK')
vagrant brook
#

Oh

#

Hmm, discord mention format is not like that

surreal creek
#

so how do I do it ?

vagrant brook
#

It's actually <@ID>

surreal creek
#

wait a sec

vagrant brook
#

You can just check if the member is inside message.mentions

#

Since message.mentions already returns a list of members mentioned

surreal creek
#

wht do u mean ?

#

i did not understand

#

how do it check ?

#
@bot.event
async def on_message(message):
  if message.mentions:
    print('mention detected')
    if f'@757279814360104980' in message.mention:
      await message.channel.send('The User is AFK')
#

like this @vagrant brook ?

hasty iron
#

you can just use User.mentioned_in

#

!d discord.User.mentioned_in

unkempt canyonBOT
vagrant brook
#

ig that's better

surreal creek
#

lemme try

surreal creek
hasty iron
#

User is the class

#

you need an instance of it

#

!d discord.Client.get_user

unkempt canyonBOT
hasty iron
#

put your id there, it returns a User object

surreal creek
#

oh thnx 🙂

willow vine
#

whats the difference between bot.say vs channel.send

maiden fable
#

bot.say doesn't work anymore

#

channel.send is what u need now

willow vine
#

oh okay

#

thanks a lot

maiden fable
#

(:

pale turtle
#

Anyone know how to make an api request on start-up once?

vagrant brook
#

on_ready event?

maiden fable
maiden fable
pale turtle
vagrant brook
#

I mean you can add a counter

pale turtle
maiden fable
#

That's the best bet

pale turtle
#

I'll just do that

surreal creek
hasty iron
#

i dont think it blocks

pale turtle
#

It does block I think

surreal creek
pale turtle
#

I just did something like:

already_loaded = False
if already_loaded:
  return```
hasty iron
vagrant brook
#

Should be your bot instance, not the class itself

surreal creek
hasty iron
#

clearly didn't

surreal creek
#

wdym

shy schooner
#
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\Giang\AppData\Local\Programs\Python\Python38-32\lib\site-pac

i got this error on the first line:

import discord
vagrant brook
shy schooner
#

ok

heavy folio
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

shy schooner
surreal creek
hasty iron
#

whatever you named your Bot/Client instance

surreal creek
surreal creek
# hasty iron whatever you named your Bot/Client instance

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
Traceback (most recent call last):
File "main.py", line 12, in <module>
bot = commands.Bot(command_prefix='dc ',intents=True)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 98, in init
super().init(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1107, in init
super().init(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 248, in init
self._connection = self._get_state(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 265, in _get_state
Traceback (most recent call last):
File "main.py", line 12, in <module>
bot = commands.Bot(command_prefix='dc ',intents=True)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 98, in init
super().init(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1107, in init
super().init(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 248, in init
self._connection = self._get_state(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 265, in _get_state
Traceback (most recent call last):
File "main.py", line 12, in <module>
bot = commands.Bot(command_prefix='dc ',intents=True)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 98, in init
super().init(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1107, in init
super().init(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 248, in init
self._connection = self._get_state(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 265, in _get_state
return ConnectionState(dispatch=self.dispatch, handlers=self._handlers,
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/state.py", line 152, in init
raise TypeError('intents parameter must be Intent not %r' % type(intents))
TypeError: intents parameter must be Intent not <class 'bool'>

wht is this error ?
first time encountering this

hasty iron
#

you have to pass in an instance of discord.Intents into the intents kwarg not a bool

slate swan
#

do you guys know some free bot hosting service that i can use while testing my bot? the ones that i can upload files to it to run the bot

hasty iron
#

there are no free hosting services

hasty iron
#

thats not a hosting service

slate swan
#

ive used repl.it previously but it fucks up the indentation once i paste the code in

surreal creek
#

yea

slate swan
#

wait, can you upload files there?

#

i think so

#

maybe ill use it

#

and then use another one when my bots done

surreal creek
hasty iron
#

what

surreal creek
#

?

#

what should i do ?

hasty iron
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

surreal creek
#

oh wait

#

i got it

#

but

wht is this ???

File "main.py", line 321, in on_message
if User.mentioned_in(message):
AttributeError: 'NoneType' object has no attribute 'mentioned_in'

#

in my code :

User = bot.get_user(757279814360104980)

User.mentioned_in(message)

#

@hasty iron

hasty iron
#

User is None

#

id is wrong

surreal creek
#

it is correct!

#

lemme paste it again

#

it is None
but why ?!?

#

nvm gtg

valid niche
#

fetch_user will look it up using an API call

#

!d discord.Client.fetch_user

unkempt canyonBOT
#

await fetch_user(user_id)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") based on their ID. This can only be used by bot accounts. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.get_user "discord.Client.get_user") instead.
valid niche
#

oh and for the user cache you need the members intent so if you don't have that the users cache will always be empty and get_user always returns None

willow vine
#

hey

#

how do i get a members username with tag

#

like tacos#4169 as a string

hasty iron
#

!d discord.Guild.get_member_named

unkempt canyonBOT
#

get_member_named(name)```
Returns the first member found that matches the name provided.

The name can have an optional discriminator argument, e.g. “Jake#0001” or “Jake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.

If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.

If no member is found, `None` is returned.
willow vine
#

that is getting the entire member

#

i have the member, i just want his entire username

#

i think member.name + member.discriminator does the work

slate swan
#

me added 3 commands and all work dont make me meme

slate swan
willow vine
#

member

slate swan
#

lol

willow vine
#

typo

slate swan
#

Xd

valid perch
willow vine
maiden fable
willow vine
slate swan
cloud dawn
#
for i in reversed(range(0, 9999999999999)):
    print(i)
    await asyncio.sleep(1)
shrewd kraken
#

how do i get guild from id

deft arch
#

what

#

you mean guild id from guild?

shrewd kraken
#

no guild from guild id

cloud dawn
shrewd kraken
#

ok

slate swan
#

new to coding

#

it not work

valid perch
#

Get rid of self, it's not in a class

#

And 'it not work' isn't very helpful..

slate swan
#

sorry

#

why is await ctx.message.delete() in a try block

#

lmao

slate swan
#

it's never gonna fail, except when your bot doesn't have permissions

#

and why is there a ctx argument in send()

#

it should be only message

#

yes

serene lynx
# slate swan
@client.command()
async def say(ctx, *, args):
  await ctx.send(f'{args}')```
slate swan
slate swan
#

i have command already

#

f sfring be like

#

f

#

lolsee wht abt try

#

remove those brackets

#

Indentation rooMonkaS

slate swan
#

around args

#

in the send()

slate swan
#

got it

slate swan
boreal ravine
#

why is there a try execpts in a say command?

slate swan
#

Ditttt forcing people to use their f-string obsession

boreal ravine
#

Mind my grammar.

boreal ravine
#

^

hasty iron
#

its already a string

slate swan
#

@slate swan

boreal ravine
#

why

slate swan
#

huh

boreal ravine
#

do u have

#

that error

slate swan
#

restart your bot

slate swan
#

so two times 1 error

#

1 correct command

slate swan
#

Just make a separate bot

#

for testing

#

or run it on your PC and disable heroku while testing

lofty heron
#

hi, can somebody explain me what a cog is? tenks

slate swan
#

sorting code in different files so it's more readable

boreal ravine
#

or organizing your code like bookmarks

slate swan
boreal ravine
#

String @slate swan

slate swan
#

Please revise your python basics before using dpy

boreal ravine
#

strings

slate swan
boreal ravine
#

Quotation marks

slate swan
#

str

#

and also ""

#

"Warn"

#

ik

#

jeese me so stupid

#

@slate swan

spring flax
#

yeah, !resources should help

boreal ravine
#

also just do case_insensitive=True where you defined client

slate swan
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
slate swan
#

something else cool to add is command_prefix = commands.when_mentioned_or("$") Dogesmile

#

command_prefix = commands.when_mentioned_or("hello","Hello","HELLO")

boreal ravine
slate swan
slate swan
lofty heron
#

jesus me internet

slate swan
#

wat

#

damn wat

#

did I answer your question before you asking

#

or wha

slate swan
#

wait

#

that's the same as case_insensitive

slate swan
#

it looks cool

boreal ravine
slate swan
#

!d discord.ext.commands.Bot.case_insensitive

unkempt canyonBOT
#

Whether the commands should be case insensitive. Defaults to False. This attribute does not carry over to groups. You must set it to every group if you require group commands to be case insensitive as well.

slate swan
#

Yes

slate swan
slate swan
boreal ravine
#

Or just dont use it?

slate swan
#

whaii

boreal ravine
#

I said I think

heavy folio
#

how do i make all of my bot's commands only work in servers and not in dms

slate swan
#

i dk

heavy folio
#

?

heavy folio
#

also status does not work in dms

valid patio
#

can anyone tell how to make this better ?


        await message.channel.send('@everyone')```
heavy folio
#

i wanna get the member's status

slate swan
heavy folio
#

its working in servers, just not in dms

slate swan
heavy folio
boreal ravine
#

what

valid patio
#

can anyone tell how to make this better ?


        await message.channel.send('@everyone')```
#

some on told me this is not the right way

slate swan
#

yes use

heavy folio
#

its an event

slate swan
heavy folio
#

hes not trying to make a command??

#

bro hes not trying to make a command

slate swan
heavy folio
#

@valid patio what are u trying to make

valid patio
slate swan
boreal ravine
heavy folio
#

tbh im having problems with events too my bot is just sending it twice

heavy folio
valid patio
#

can anyone help me ?

boreal ravine
heavy folio
#

i can use it in the server but cant in dms

boreal ravine
#

@heavy folio Use what

heavy folio
#

look

#

1 sec

#

in server

#

in dms it'll just cause an error

slate swan
slate swan
heavy folio
slate swan
#

mines shit

slate swan
#

@boreal ravine

slate swan
#

u did different for each and every member

surreal sierra
#

How would I be able to make the bot count a specific word in the chat, and all times that word have been said already?

slate swan
heavy folio
surreal sierra
#

lmao

slate swan
slate swan
valid patio
#

can anyone tell how do i make the reply repeat 100 times ?


        await message.channel.send('@everyone')```
valid patio
#

i want to troll my friends

heavy folio
#

u'll get ratelimited

heavy folio
valid patio
#

😦

heavy folio
#

ur bot cant spam if it does it gets ratelimited by discord

slate swan
heavy folio
#

its api abuse

heavy folio
slate swan
slate swan
heavy folio
slate swan
#

This is a help channel notlikeblob

#

And a learning server

heavy folio
#
@client.event
async def on_message(message):
  await client.process_commands(message)
  if message.author == client.user:
    return
  elif "haha" in message.content or "HAHA" in message.content:
    await message.channel.send("HAHAHHAHAHAHAHHAHAHFKJNRFRKJRNJWRNJKRNJRWJWRWJKWRNKJ")
    return
  elif message.content == "wot" or message.content == "what" or message.content == "shenme" or "?" in message.content:
    await message.channel.send("wot?")
    return
```so i have this
valid patio
#

ok i want to know how to make the message repeat

heavy folio
#

but not for the "wot"

heavy folio
slate swan
slate swan
#

!d discord.Client.user

unkempt canyonBOT
slate swan
#

Ah got it

#

Actually no

stone palm
#
    await user.add_roles(role, reason=reason)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 777, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'int' object has no attribute 'id'
```huh
slate swan
#

Try to match id like message.author.id == client.user.id. I guess just comparing author and user compares the instances also

heavy folio
#

me?

slate swan
#

yes

pale turtle
unkempt canyonBOT
#

discord/user.py lines 99 to 100

def __eq__(self, other: Any) -> bool:
    return isinstance(other, _UserTag) and other.id == self.id```
slate swan
#

it also checks instance, but both inherits from same class, so should not matter

pale turtle
#

Yeah

round quarry
#

Can I directly shut down the bot with some command in the console?

reef shell
#

Unhandled exception in internal background task 'change_status'. 2021-09-06T12:08:09.796783+00:00 app[worker.1]: Traceback (most recent call last): 2021-09-06T12:08:09.796830+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop 2021-09-06T12:08:09.796830+00:00 app[worker.1]: await self.coro(*args, **kwargs) 2021-09-06T12:08:09.796834+00:00 app[worker.1]: File "/app/emojitv1.py", line 68, in change_status 2021-09-06T12:08:09.796835+00:00 app[worker.1]: await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"ethelp || ping: {round(bot.latency*1000)} ms")) 2021-09-06T12:08:09.796853+00:00 app[worker.1]: OverflowError: cannot convert float infinity to integer

#

any idea why this error happened?

#

this is the first time i saw this kind of error

slate swan
#

channel?

slate swan
reef shell
slate swan
reef shell
#

message.channel.send/ message.reply

#

use this

slate swan
#

k

reef shell
#

oh wait

slate swan
#

Also it's the discord.message module not the message instance

reef shell
#

you made another mistake

slate swan
slate swan
round quarry
slate swan
#

Why th 4 pings notlikeblob

slate swan
#
async def change_status():
   await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching,name=(choice(status))))
slate swan
slate swan
reef shell
#
@tasks.loop(seconds=10)
async def change_status():
    ran = random.randint(1, 3)
    if ran == 1:
        await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"ethelp || Vote me "))
    if ran == 2:
        await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"ethelp || ping: {round(bot.latency*1000)} ms"))
    if ran == 3:
        await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name="ethelp || Version 1.0"))```
round quarry
slate swan
#

did your bot get infinity ping?

reef shell
#

nvm i got a possible reason behind this error, the bot didn't get ack back

slate swan
reef shell
#

i gtg now bye

heavy folio
#

how do i make all commands server only?

slate swan
#

@slate swan Why are you pinging me on every message dude

round quarry
heavy folio
#

meaning it ignores users in dms

visual island
slate swan
slate swan
reef shell
visual island
heavy folio
reef shell
#

i don't know about that

visual island
#

!d discord.ext.commands.Bot.check

unkempt canyonBOT
#

check(func)```
A decorator that adds a global check to the bot.

A global check is similar to a [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.

Note

This function can either be a regular function or a coroutine.

Similar to a command [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check"), this takes a single parameter of type [`Context`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").

Example...
visual island
#

this

heavy folio
#

ty

#

man the bot is still sending twice

slate swan
pale turtle
#

Yay I am almost finished making modmail I started like 4 hours ago

visual island
slate swan
slate swan
#

dynamic_cooldown does not accept ctx but message

heavy folio
#
@client.event
async def on_message(message):
  await client.process_commands(message)
  if message.author.id == client.user.id:
    return
  elif "haha" in message.content or "HAHA" in message.content:
    await message.channel.send("HAHAHHAHAHAHAHHAHAHFKJNRFRKJRNJWRNJKRNJRWJWRWJKWRNKJ")
    return
  elif message.content == "wot" or message.content == "what" or message.content == "shenme" or message.content == "shen me" or "?" in message.content:
    await message.channel.send("wot?")
    return
```uhh the "HAHA" is still sending twice :|
visual island
#

hmm

slate swan
#

Try to comment out process_commands line and try again

#

2.0

visual island
#

oh

heavy folio
#

get ready to get ratelimited

slate swan
#

Keep pinging me sadcatthumbsup Make a selfbot to just ping me, okay?

slate swan
#

it spams

heavy folio
#

look at the number of times it spammed

slate swan
#

@slate swan bruh

slate swan
#

You did it wrong

heavy folio
slate swan
#

Doing it allows you to mention the bot and use command without using any prefix

slate swan
slate swan
#

Okay

#

Did you fix it

slate swan
slate swan
#

Like no vanity url like bruh

slate swan
#

You know discord is planning to reduce no. of boosts required for levels?

slate swan
visual island
#

189 boost currently

slate swan
slate swan
#

Not sure, but it's active in one of my server

#

It has around 28 boosts and vanity works fine

boreal ravine
#

lvl 1 = 2
lvl 2 = 5
lvl 3 = 15
lvl 4 = 30

visual island
#

it's too low smh

slate swan
#

Imagine getting 30 second unskippable ad while switching servers notlikeblob

visual island
#

maybe like:

1: 2
2: 10
3: 50
4: 250
5: 1000
6. 10000
Idk

boreal ravine
#

hm

slate swan
#

👀

boreal ravine
#

lmao 6 😂

visual island
#

lol

boreal ravine
#

If you think about it discord gave around $1,000,000 worth of nitro to discord users

slate swan
#
INSERT INTO nitro (id, duration) VALUES (764462046032560128, "3-month");
visual island
#
INSERT INTO nitro (id, duration, boosts) VALUES (650447110402998302, "3-year", 5000); 
```better
slate swan
#

Boost a server 5000 times and become owner as perks

valid niche
#

that's like so annoying to deal with

slate swan
#

We noob at sql Discord's extra advanced database

visual island
#

lol

round quarry
#

when executing the command:

@bot.command()
async def youtube(ctx, *, search):
    query_string = parse.urlencode({'search_query': search})
    html_content = request.urlopen('http://www.youtube.com/results?' + query_string)
    search_results = re.findall('href=\"\\/watch\\?v=(.{11})', html_content.read().decode())
    # print(search_results)
    await ctx.send( 'https://www.youtube.com/watch?v=' + search_results[0])

Me marca este error: await ctx.send( 'https://www.youtube.com/watch?v=' + search_results[0])
IndexError: list index out of range

Does anyone know what happens? shipit

slate swan
#

search_results is an empty list

round quarry
#

o, thanks

slate swan
#

guys if i want to upload it on github then wht should be its name prefixes.json only?

lament mesa
slate swan
#

yes but i think if its a music bot then probably leave it cause u saw wht happened to Groovy

slate swan
slate swan
hasty iron
#

github doesnt do anything to your files

slate swan
#

i should name it

lament mesa
#

Its a place to deploy your code.

hasty iron
#

why does it matter

#

its not like github will run your code

slate swan
#

i host it on heroku

hasty iron
#

oh

lament mesa
slate swan
slate swan
hasty iron
#

i never used heroku with gh

slate swan
#

Use relative path

#

./prefixes.json or somethin like that

#

heroku/any host won't have the root directory name same as your pc, so using relative path is always good

cloud dawn
#

Can't think about a reason why you would use an absolute path

slate swan
hasty iron
#

guess

slate swan
slate swan
hasty iron
#

i dont make bots anymore

slate swan
#

Discord API is boring now rooBulli I'll find something else to work now

#

Also that repo is kinda unstable

#

so archived

lament mesa
#

Relatable.

cloud dawn
#

py bots are dying rn anyways.

dense swallow
#

Yes but I'm working on a fork

#

No

#

I just published it to pypi today

slate swan
#

TypeError: 'in <string>' requires string as left operand, not tuple

valid perch
#

There do be a lot of forks

dense swallow
#

Yeah

#

Team work ig

valid perch
#

I found it too much, too many forks n stuff. So just gonna move lol

dense swallow
#

To another language?

valid perch
#

to hikari

dense swallow
#

Oh

#

I was also planning to move to d.js

slate swan
#

@tawdry perch i still have the same problem D:

#

do i need import DiscordUtils?

valid perch
#

I dont have the patience for another language, besides my packages do be py haha

slate swan
#

@tawdry perch

slate swan
#

oof. Ok

#
Traceback (most recent call last):
  File "main.py", line 38, in <module>
    client = commands.Bot(command_prefix='!')
AttributeError: module 'discord.ext.commands' has no attribute 'Bot'
boreal ravine
#

@slate swan code?

slate swan
bold dawn
#

I’m getting some error if anyone can help. Below is the code. ```@bot.event
async def on_command_error(ctx, error):
channel = ctx.message.channel.send
if isinstance(error, commands.MissingRequiredArgument):
await send_cmd_help(ctx)
elif isinstance(error, commands.BadArgument):
await send_cmd_help(ctx)
elif isinstance(error, commands.CommandInvokeError):
output.error("Exception in command '{}', {}".format(ctx.command.qualified_name, error.original))
oneliner = "Error in command '{}' - {}: {}\nIf this issue persists, Please report it in the support server.".format(
ctx.command.qualified_name, type(error.original).name, str(error.original))
await ctx.send(channel, oneliner)

And this is the error 

in on_command_error
    await ctx.send(channel, oneliner)
TypeError: send() takes from 1 to 2 positional arguments but 3 were given
slate swan
#

send only takes content as positional arg

manic wing
bold dawn
manic wing
#

¯_(ツ)_/¯

bold dawn
#

Lol. I’ll figure it out

manic wing
#

how do you fetch a webhook

#

do you put the full link? https:// etc

bold dawn
#

On my code that I’m trying to solve?

manic wing
#

no

bold dawn
#

Ahhh my bad

manic wing
#
In webhook_id: Value "etKD7gAZGYhmYj-Gx-Ld20jk-tbHroKAvcK-APHBzYFp" is not snowflake.

#

what do i enter

#

for bot.fetch_webhook

valid galleon
#

so ive been wondering about this from a few days- should i move my current bot to JS, or just continue with d.py? i tried js on a seperate bot, and its pretty hard for me to figure out, and i like d.py more, but it doesnt have features like buttons and slash commands afaik

manic wing
hasty iron
valid galleon
#

but just asking, is it necessary to move rn?

slate swan
#
import discord
from discord.ext import commands

class Errors():
    async def errors(self, error, ctx):
        if isinstance(error, commands.CommandOnCooldown):
            em = discord.Embed(title="Failed to run the command!", description="```py\nThis command is on cooldown. Please try again after {round(error.retry_after, 1)} seconds.```")
        elif isinstance(error, commands.MissingPermissions):
            em = discord.Embed(title="Failed to run the command!", description="```py\nYou dont have permission to run this command```")
        elif isinstance(error, commands.MissingRequiredArgument):
            em = discord.Embed(title="Failed to run the command!", description=f"```py\{error.param} argument is requierd```")
        elif isinstance(error, commands.CommandNotFound):
            em = discord.Embed(title="Failed to run the command!", description=f"```py\Command not found!```")
        else:
            em = discord.Embed(title="Failed to run the command!", description=f"Oh no! Something went wrong while running the command!")
            
        await ctx.send(embed=em)
            

I have this class
And im importing it like from utils.errors import *
But it doesnt work..
Any solution?

#
@client.command()
@commands.is_nsfw()
async def nsfw(ctx):
    embed = discord.Embed(title="I got some NSFW for you")
    async with aiohttp.ClientSession() as cs:
        async with cs.get('https://www.reddit.com/r/nsfw/new.json?sort=hot') as r:
           res = await r.json()
           embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
           await ctx.send(embed=embed)``` can anyone help me make this say "i cant send nsfw in general channels " if the channel has no nsfw perms ?
hasty iron
valid galleon
#

to verify it needs to be in 100 servers, correct?

slate swan
#

@hasty ironcan y help me

valid galleon
manic wing
#

guys

#

why does my webhook raise this error

webhook = await self.bot.fetch_webhook('id')
  File "/home/caeden/.local/lib/python3.9/site-packages/discord/client.py", line 1493, in fetch_webhook
    data = await self.http.get_webhook(webhook_id)
  File "/home/caeden/.local/lib/python3.9/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

#

@hasty iron i beggeth of thy

#

how do you add perms to a webhook

valid galleon
#

how can i make a command which shows all the guilds that the bot is in?

wanton pebble
#

can i check a member has a role mid code? so not with the decorator

valid galleon
#

and can it be restricted to only certain accounts? im not referring to roles, or perms, just accounts

valid galleon
wanton pebble
slate swan
#

just do {len(bot.guilds)}

wanton pebble
slate swan
#

what are u using sqlite3

spring flax
spring flax
#

@everyone role

manic wing
slate swan
#

@wanton pebble it does but it will take it much longer

valid galleon
visual island
spring flax
#

what permission does the webhook need?

wanton pebble
hasty iron
manic wing
#

literally where

hasty iron
#

no clue, never used webhooks

manic wing
spring flax
# manic wing where

Like I said, the permission that the bot is missing, probably needs to be given to the @everyone role.

valid galleon
#

what are webhooks used for anyway?

#

also, can someone help me wih the guilds command? how would the code be structured?

manic wing
valid galleon
#

@manic wing what are webhooks used for?

#

just wanna know

manic wing
#

how do i use it though

spring flax
manic wing
#

im trying to send a message to it

slate swan
#

!d discord.AsyncWebhookAdapter

valid galleon
#

pls help me with the guilds command

#

i just wanna put it in quickly

slate swan
#

!d discord.Webhook.from_url

unkempt canyonBOT
#

classmethod from_url(url, *, adapter)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Webhook "discord.Webhook") from a webhook URL.
slate swan
#

use this

manic wing
#

i did

 async with ClientSession() as session:  
            webhook = discord.Webhook.from_url('https://discord.com/api/webhooks/blahblah', adapter=discord.AsyncWebhookAdapter(session))

but it says ```py

File "/home/caeden/.local/lib/python3.9/site-packages/discord/webhook.py", line 221, in request
async with self.session.request(verb, url, headers=headers, data=data) as r:
File "/home/caeden/.local/lib/python3.9/site-packages/aiohttp/client.py", line 1117, in aenter
self._resp = await self._coro
File "/home/caeden/.local/lib/python3.9/site-packages/aiohttp/client.py", line 381, in _request
raise RuntimeError("Session is closed")
RuntimeError: Session is closed

spring flax
#

uh

#

i thought it was explained there lol

slate swan
manic wing
manic wing
manic wing
# slate swan Any more code after it?
@commands.Cog.listener('on_message')
    async def send_to_channel(self, msg):
        if msg.channel.id != idkwhyblanked:
            return
        
        async with ClientSession() as session:  
            webhook = discord.Webhook.from_url('https://discord.com/api/webhooks/uh', adapter=discord.AsyncWebhookAdapter(session))

        embeds = msg.embeds
        files = msg.attachments
        file_list = []

        if embeds:
            await webhook.send(msg.content, username=msg.author.name, avatar_url=msg.author.avatar_url, embeds=embeds, allowed_mentions=discord.AllowedMentions(roles=False, users=False, everyone=False))

        if files:
            for attachment in files:
                await attachment.save(f'./dicts/{attachment}')
                file_list.append(discord.File(f"./dicts/{attachment}"))

            await webhook.send(msg.content, username=msg.author.name, avatar_url=msg.author.avatar_url, files=files, allowed_mentions=discord.AllowedMentions(roles=False, users=False, everyone=False))

        await webhook.send(msg.content, username=msg.author.name, avatar_url=msg.author.avatar_url, allowed_mentions=discord.AllowedMentions(roles=False, users=False, everyone=False))
slate swan
#

Yeah your session got closed as you exited context

manic wing
#

how do i keep it open?

slate swan
#

either do this all in async with ... line, or make session like ```py
session = ClientSession()
do stuff...
session.close()

lament mesa
#

!d discord.Client.fetch_webhook will make stuff more easier

unkempt canyonBOT
#

await fetch_webhook(webhook_id)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`Webhook`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Webhook "discord.Webhook") with the specified ID.
manic wing
slate swan
#

Your bot don't have manage_webhooks ig

manic wing
#

my bot isnt in the server...

slate swan
#

👀

manic wing
#

it doesnt need to be in the server for a webhook

slate swan
#

I think fetch should not work if you don't share any server

#

since webhooks also has a token

#

but you're getting it with only id

manic wing
slate swan
#

means you need more perms to fetch it

manic wing
#

ok

#

it worked

#

cheers

slate swan
#
@client.command()
@commands.is_nsfw()
async def nsfw(ctx):
    embed = discord.Embed(title="I got some NSFW for you")
    async with aiohttp.ClientSession() as cs:
        async with cs.get('https://www.reddit.com/r/nsfw/new.json?sort=hot') as r:
           res = await r.json()
           embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
           await ctx.send(embed=embed)```
 can anyone help me make this say "i cant send nsfw in general channels " if the channel has no nsfw perms ?
slate swan
#

oh what

valid galleon
#

pls help how do i make the bot list all the guilds that its in

slate swan
#

@slate swanwhat

#

!d discord.TextChannel.is_nsfw here @slate swan

unkempt canyonBOT
#

is_nsfw()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): Checks if the channel is NSFW.
slate swan
#

is that what you wanted?

valid galleon
slate swan
#

@spring flax don't use ()

valid galleon
#

which refer to the nsfw thing

slate swan
#

it doesn't work with them

slate swan
unkempt canyonBOT
slate swan
#

bot.guilds

hoary gust
#

Guys is it preferred to use MySQL for bot

slate swan
#

The database good for you depends on how you use it and how big your bot is

dapper cobalt
hoary gust
#

Will it be able to store so much data of around 100 users in sec and make 300-400 reads per second

#

@dapper cobalt I have tried mongo and it's slow

#

Not suitable for a bot

lament mesa
#

Seriously, slow?!

hasty iron
#

what kind of bots needs 400 reads per second

hoary gust
#

@hasty iron on msg event

#

Take it as 100

#

400 is too much

slate swan
#

MongoDB isn't slow..

lament mesa
hoary gust
#

@slate swan Well I got this in my case and found that SQL are faster than mongo

slate swan
#

Hmm..

lament mesa
#

A google search says 1,045 inserts per second

hoary gust
#

@lament mesa for what?

lament mesa
#

mongo

hoary gust
#

Reads are slow

#

In comparison to MySQL

dapper cobalt
hoary gust
#

@dapper cobalt well probably

#

But SQL are still faster than it

rancid mirage
#
#include <iostream>

using std::cout;

int main()
{
    std::cout << "Gay";
}```
hoary gust
#

And I need recommendations for SQL

slate swan
#

Uh that isn't python lmao

rancid mirage
#

yes

hoary gust
#

Looks like c

rancid mirage
#

its c++

hoary gust
#

Ah

slate swan
#

okay, but this channel is for discord bot development using python

hoary gust
#

Guys what SQL db is preferred for a bot

slate swan
#

just go to #c-extensions @rancid mirage and consider checking the pins

rancid mirage
#

what

#

no

#

dont need it

slate swan
#

uh okay..

hoary gust
rancid mirage
#

lmao python basics are so ez

slate swan
#

Postgresql

rancid mirage
#

i learned all the basics in 3 hours

slate swan
#

okay.. good for you?

rancid mirage
#

while in c++ it took me some days

hoary gust
static patio
#

oh

rancid mirage
static patio
#

then replace it with what?

spring flax
slate swan
unkempt canyonBOT
#

Decorators

A decorator is a function that modifies another function.

Consider the following example of a timer decorator:

>>> import time
>>> def timer(f):
...     def inner(*args, **kwargs):
...         start = time.time()
...         result = f(*args, **kwargs)
...         print('Time elapsed:', time.time() - start)
...         return result
...     return inner
...
>>> @timer
... def slow(delay=1):
...     time.sleep(delay)
...     return 'Finished!'
...
>>> print(slow())
Time elapsed: 1.0011568069458008
Finished!
>>> print(slow(3))
Time elapsed: 3.000307321548462
Finished!

More information:
Corey Schafer's video on decorators
Real python article

slate swan
#

just use @bot.command()

#

as the decorator

hoary gust
#

I need around 50-100 reads per second so it preferred to use PostgreSQL@spring flax

static patio
#

ohh

#

okay thanks

slate swan
#

@static patio actually it'll be @client.command() in your case

#

since you defined commands.Bot as client

static patio
#

it is an event and not a command

slate swan
valid galleon
#

so i tried to make the guilds function, and i get this error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_field() missing 1 required positional argument: 'self'
this is my code:

    @commands.command()
    @commands.has_permissions(administrator = True)
    async def guilds(self, ctx):
        embed = discord.Embed.add_field(name="Server Count", value=len(self.client.guilds), inline=True)```
slate swan
valid galleon
wary ravine
#

what do i put for create_category parameters if i dont want anyone to be able to access the channels inside it

slate swan
#

find the role you want allowed, and set it so that role has read_messages and send_messages or whatever you want

rancid mirage
#

guys what does it mean @commands.command()

#

the "@"

slate swan
slate swan
rancid mirage
#

k

wary ravine
slate swan
boreal ravine
#

did you do that..?

slate swan
unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
slate swan
#

kind of like this

#

just category instead of text channels

wary ravine
#

ty

boreal ravine
maiden fable
#

Lol

covert igloo
#

Hey if I wanted to send a message when a command is used to a channel, how would I go about doing it

#

Log channel

stiff nexus
#

so if this message intends come can i still use my bot (not verified) normally how i use now????

valid patio
#

how can i make a public inv link for my bot

#

?

round quarry
#

How can I make a list in an embed? for instance:
~ Server: [server name]
~ Owner: [owner's name]
Etc... I explain?

valid patio
maiden fable
unkempt canyonBOT
maiden fable
#

!d discord.Guild.owner

unkempt canyonBOT
valid patio
maiden fable
#

!d discord.Guild.member_count

unkempt canyonBOT
#

member_count```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") to be specified.
maiden fable
valid patio
#

ok

#

thanks

blazing beacon
#

i realized you can mix js and py together

hasty iron
#

why would you want to

blazing beacon
#

html front end basic js on the front end

#

full python on the back end

maiden fable
#

Indeed

lament mesa
#

But it compiles to js....

hasty loom
#

how can i get a list of all user IDs who reacted with ⬇️

waxen granite
#

Hwo do i put channel permissions in a if before and after statement?

waxen granite
#

I am trying to get permission updates in on_guild_channel_update

wary ravine
#

what permissions would the bot need to execute this command:

    @commands.command(name = "refresh", description = "refreshes the member and boost counts")
    @commands.is_owner()
    async def refresh(self, ctx):
        guild = ctx.guild
        members = guild.get_channel(884459371046768660)
        boosts = guild.get_channel(749371688822767666)
        
        await members.edit(name = f"Members: {guild.member_count}")
        await boosts.edit(name = f"Boosts: {guild.premium_subscription_count}")
        
        await ctx.send("updated stats")
hasty loom
wary ravine
#

just manage channels?

waxen granite
#

So i gues it has to be done like if before.managemessageperm != After.managemessageperm: Await channel.send()

#

I dont know what this if statement be

spring flax
#

why? Error?

waxen granite
#

Or is there a different way to do it?

#

@hasty loom

hasty loom
#

hm so you want to just get info for when a channel is updated?

#

why use an if statement for that, cant u just use an event?

wary ravine
#

is Forbidden thrown when the command invoker doesnt have permissions or the bot doesnt have permissons

blazing beacon
lament mesa
#

idm?

blazing beacon
#

i dont mind

lament mesa
#

oh ok, I'll keep that in mind mhm

slate swan
#

I have an error handler but only the error: CommandNotFound respones

valid galleon
#

how do i get the guild names? i had my code first print out the server names, and when it worked, i changed it into an embed. but now, it doesnt work. it just sends 4 seperate embeds, which have the number of letters in the name of the server. how do i make it send the server names, and also send everything in 1 message? this is my code:

    @commands.command()
    @commands.has_permissions(administrator = True)
    async def guilds(self, ctx):
        async for guild in self.client.fetch_guilds(limit=150):
            embed = discord.Embed().add_field(name="Server Names", value=len(guild.name), inline=True)
            await ctx.send(embed=embed)```
valid galleon
#

will it work if i change the len thing

hasty iron
#

why are fetching guilds

valid galleon
#

so ik whats causing it to send numbers

hasty iron
#

just iterate through self.client.guilds

#

and its pretty obvious whats causing it to send numbers

#

you have len

#

also the limit of fields is 25, so it wouldn't work with 150

dapper cobalt
valid galleon
#

but now it still send seperate messages

dapper cobalt
#

Because you are creating an embed for each guild.

valid galleon
#

so shud i remove the add_field?

dapper cobalt
#
    @commands.command()
    @commands.has_permissions(administrator = True)
    async def guilds(self, ctx):
        names = []
        for guild in self.client.guilds:
          names.append(guild.name)
        embed = discord.Embed(description="\n".join(names))
        await ctx.send(embed=embed)
hasty iron
#

client.guilds doesnt return an async iterator

dapper cobalt
reef trail
#
hs_class = str(usr.public_flags.all()).replace('[<UserFlags.', '').replace(
    '>]', '').replace('_', ' ').replace(':', '').replace('>', '').title()
hs_class = ''.join([i for i in hs_class if not i.isdigit()])
hs_final = hs_class.replace(",", "").replace(
    " <Userflags.Early", "").replace("Supporter", "")

es_brilliance = str(usr.public_flags.all()).replace('[<UserFlags.', '').replace('hypesquad_brilliance', '').replace(
    '[', '').replace(':', '').replace('>,', '').replace('<', '').replace('UserFlags.', '').replace('>]', '').replace('_', ' ').title()
es_brilliance = ''.join([i for i in es_brilliance if not i.isdigit()])

def houseCheck():
    if hs_final.strip() == 'Hypesquad Balance':
        return f"{emojis.hs_balance}"
    elif hs_final.strip() == 'Hypesquad Brilliance':
        return f"{emojis.hs_brilliance}"
    elif hs_final.strip() == 'Hypsquad Bravery':
        return f"{emojis.hs_bravery}"
    else:
        return ''

def earlySupporter():
    if es_brilliance.strip() == 'Early Supporter':
        return f"{emojis.early_supporter}"
    else:
        return ''

def boosterCheck():
    if user.premium_since != None:
        return f"{emojis.nitro_booster}"
    else:
        return ''```
 someone please show me a better way of checking user badges, these are for boosting and hype squad
bravery doesnt even work for some reason so this needs to be improved
valid galleon
#

tysm, it works now!

hasty loom
#

how can i get discord.Reaction object of all the reactions of this message?

channel = ctx.guild.get_channel(884430255681589279)
msg = await channel.fetch_message(884469364814925824)
dapper cobalt
unkempt canyonBOT
#

class discord.PublicUserFlags```
Wraps up the Discord User Public flags.

`x == y` Checks if two PublicUserFlags are equal.

`x != y` Checks if two PublicUserFlags are not equal.

`hash(x)` Return the flag’s hash.

`iter(x)` Returns an iterator of `(name, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 1.4.
reef trail
#

:>

dapper cobalt
unkempt canyonBOT
dapper cobalt
#

!d discord.PublicUserFlags

unkempt canyonBOT
#

class discord.PublicUserFlags```
Wraps up the Discord User Public flags.

`x == y` Checks if two PublicUserFlags are equal.

`x != y` Checks if two PublicUserFlags are not equal.

`hash(x)` Return the flag’s hash.

`iter(x)` Returns an iterator of `(name, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 1.4.
hasty loom
reef trail
#

ah okay

dapper cobalt
unkempt canyonBOT
reef trail
unkempt canyonBOT
#

Cogs/guild.py line 512

async def user(self, ctx, user: Union[discord.Member, discord.User] = None):```
wary ravine
#

I'm getting a Forbidden error for this code:

...
    async def refresh(self, ctx):
        guild = ctx.guild
        members = guild.get_channel(884459371046768660)
        boosts = guild.get_channel(749371688822767666)
        
        await members.edit(name = f"Members: {guild.member_count}")
        await boosts.edit(name = f"Boosts: {guild.premium_subscription_count}")
        
        await ctx.send("updated stats")
dapper cobalt
wary ravine
#

forbidden is thrown if the user doesnt have permissions anyway, which i do

reef trail
#

Forbidden is thrown when the action cant be completed

waxen granite
wary ravine
reef trail
#

"Exception that’s thrown for when status code 403 occurs.

Subclass of HTTPException"