#discord-bots

1 messages · Page 265 of 1

slate swan
#

!e print("\nl")

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 
002 | l
topaz gust
#

Wait

#

!e print hi

unkempt canyonBOT
#

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

001 |   File "/home/main.py", line 1
002 |     print hi
003 |     ^^^^^^^^
004 | SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
topaz gust
#

Ohh

#

Wait I made an opsie

#

!e print(Hi)

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print(Hi)
004 |           ^^
005 | NameError: name 'Hi' is not defined
slate swan
#

#bot-commands

topaz gust
#

!e print "Hi"

unkempt canyonBOT
#

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

001 |   File "/home/main.py", line 1
002 |     print "Hi"
003 |     ^^^^^^^^^^
004 | SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
sick birch
#

@topaz gust please experiment with the bot in #bot-commands

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

hi
slate swan
#

#bot-commands is for playing with bots

#

dont spam here

torn solar
#

is there a way to sync command tree not on_ready

slate swan
#

yes you can

torn solar
#

how

slate swan
#

Just call .sync somewhere else

torn solar
#

person im working for said "dont do it on rebbot"

slate swan
#

Like in command or in setup hook

torn solar
#

so a command to sync the commands

#

like a prefix command?

slate swan
#

Can be

torn solar
#

idk he said something like "please dont tell me you sync on reboot"

#

which is what i normally do

#

so idk what else he wants me to do

fallen imp
#

Tks u

hushed galleon
# torn solar so idk what else he wants me to do

in general you should avoid making unnecessary API calls and afaik the main concern with syncing on startup is hitting the rate limit
(not the 200 maximum commands per day since existing commands dont count towards that, but the dynamic rate limit which appears to be 2/30s at the moment)

#

plus if you use dpy's extension system for hot-reloading, having a command to re-sync after changing your slash commands is probably a bit more convenient than entirely restarting your bot

if you happen to be using the jishaku cog, that comes with a sync command too

slate swan
#
from nextcord.ext import commands
import nextcord
import asyncio

class CreateTicket(nextcord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @nextcord.ui.button(
        label="Create Ticket", style=nextcord.ui.ButtonStyle.blurple, custom_id="create_ticket:blurple")
    async def create_ticket(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
        await interaction.response.send_message("Ticket being created. . .", empheral=True)


class Bot(commands.Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.persistent_views_added = False

    async def on_ready(self):
        if not self.persistent_views_added:
            self.add_view(CreateTicket())
            self.persistent_views_added = True
            print("Persistent views added")
        print("Bot is ready | Logged in as {self.user}")   


bot = Bot(command_prefix=',', intents=nextcord.Intents.all())

@bot.command()
@commands.has_permissions(manage_roles=True)
async def setup_tickets(ctx: commands.Context):
    embed = nextcord.Embed(title="Create a ticket!", description="Click the 'Create Ticket' button to below to create a ticket.  Staff will be with you soon.")
    await ctx.send(embed=embed, view=CreateTicket())

bot.run('')```
#

Anyone help?

vocal snow
#

!d nextcord.ButtonStyle

unkempt canyonBOT
#

class nextcord.ButtonStyle```
Represents the style of the button component.

New in version 2.0.
ornate sapphire
#

anyone know how to make a bot follow announcements and send them on your server?

slate swan
#

I changed to style=nextcord.ui.ButtonStyle.primary and it doesnt work

ornate sapphire
vocal snow
ornate sapphire
slate swan
slate swan
ornate sapphire
vocal snow
#

Having both libraries can cause conflicts

slate swan
vocal snow
#

Can you run pip show discord.py and confirm

slate swan
#

which i need to uninstall both just got mixed up

#

you uninstalled python itself 😨

slate swan
#

It works now I will be here if anything comes up

ornate sapphire
slate swan
#

Mayhaps

ornate sapphire
#

idk what that is

slate swan
#

Perchance, possibly 🥸

#

But that's why the help channels exist, so you don't have to rely on one specific person to help you 🦆 so ask away

slate swan
#

maybe + perhaps lol

ornate sapphire
#

well than can you tell me?

slate swan
#

Tell you what

slate swan
#

That's way too vague of a question

ornate sapphire
#

you know how some servers have a bot send youtube announcements on their server?

slate swan
#

yes

ornate sapphire
#

I want that

#

my bot to send announcements to my server

naive briar
#

What announcements

ornate sapphire
#

video game

slate swan
#

To automatically announce when a YouTube channel uploads? You'll need some sort of YouTube api wrapper or to write one yourself then

ornate sapphire
#

I want the api wrapper

#

but how do I do it?

slate swan
#

try looking for one on Google and start with their documentation then, I've never done this before so I wouldn't be able to recommend anything specific

mossy pilot
#
@bot.event
async def on_member_update(before, after):
    if after.bot:
        return

    if before.activities == after.activities:
        return

    # Define required_activity
    userHasActivity = False
    for activity in after.activities:
        if isinstance(activity, discord.CustomActivity) and str(activity) == '/bloodthirsty':
            userHasActivity = True

    role_id = 1126319070682292284
    role = discord.utils.get(after.guild.roles, id=role_id)

    if userHasActivity:
        await after.add_roles(role)
    else:
        await after.remove_roles(role)
        print("person repping")``` if someone has /bloodthirsty bot gives user role
mossy pilot
#

no, the bot isnt giving the person the role and it has max perms

slate swan
#

should show a error

mossy pilot
#
2023-07-06 01:25:32 INFO     discord.client logging in using static token
 * Serving Flask app ''
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:8080
 * Running on http://172.31.196.3:8080
Press CTRL+C to quit
172.31.196.1 - - [06/Jul/2023 01:25:32] "OPTIONS * HTTP/1.1" 404 -
172.31.196.1 - - [06/Jul/2023 01:25:32] "GET / HTTP/1.1" 200 -
172.31.196.1 - - [06/Jul/2023 01:25:33] "GET / HTTP/1.1" 200 -
2023-07-06 01:25:33 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 5a4f3dbda0d69f19f5ae22f2d1f4387f).
Everything's all ready to go~```
#

thats what i get

#

it says everything is working fine

slate swan
mossy pilot
#

do you know anyone that could help me?

slate swan
sick birch
mossy pilot
# sick birch Can you show us your intents?
import discord
from discord.ext import commands
from keep_alive import keep_alive
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=',' ,intents=intents)
client = discord.Client
client = discord.Client(intents=discord.Intents.default())
intents = discord.Intents.default()
intents.message_content = True```
sick birch
#

Why do you have both a bot and a client pithink

#

Also you have like, 3 intents objects

mossy pilot
sick birch
#

Either the bot or the client

#

There is usually no good reason for having both at once

mossy pilot
#

okay i removed the client

sick birch
#

What's your code look like now?

mossy pilot
#
import discord
from discord.ext import commands
from keep_alive import keep_alive
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=',' ,intents=intents)
intents = discord.Intents.default()
intents.message_content = True```
#
import discord
from discord.ext import commands
from keep_alive import keep_alive
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=',' ,intents=intents)
intents = discord.Intents.default()
intents.message_content = True

@bot.event
async def on_ready():
    print("Everything's all ready to go~")





@bot.event
async def on_member_update(before, after):
    if after.bot:
        return

    if before.activities == after.activities:
        return

    # Define required_activity
    userHasActivity = False
    for activity in after.activities:
        if isinstance(activity, discord.CustomActivity) and str(activity) == '/bloodthirsty':
            userHasActivity = True

    role_id = 1126319070682292284
    role = discord.utils.get(after.guild.roles, id=role_id)

    if userHasActivity:
        await after.add_roles(role)
    else:
        await after.remove_roles(role)
        print("person repping")````
winter token
#

what attribute/function is used to change the nickname of the user?

mossy pilot
#

its supposed to give a user a role if they have /bloodthirsty in their status

slate swan
#

!d discord.Member.edit iirc

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., bypass_verification=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
slate swan
#

There's a nick kwarg

winter token
#

ty

mossy pilot
#

oh

#

nvm

sick birch
mossy pilot
sick birch
#

Just a print statement in the function that's not inside any conditionals or control flow

slate swan
#

put some print statements throughout to see if each line executed as intended

mossy pilot
#

does this change if im using replit?

sick birch
#

maybe, maybe not. replit is just kinda bad and unreliable

slate swan
mossy pilot
sick birch
#

You should probably be debugging that instead

slate swan
#

maybe worth its own help post then, I've not heard anything good about replit

naive briar
#

Anything good about replit

slate swan
#

🥴

slate swan
ornate sapphire
#

im making reaction button role on / command and everything I did theirs no error. But when it runs the command doesnt show up

#
class SelfRoles(discord.ui.View):
  def __init__(self):
    super().__init__(timeout=None)

@discord.ui.button(label="fortnite", style=discord.ButtonStyle.blurple)
async def blue_color(self, interaction: discord.Interaction, Button: discord.ui.Button):
  blue_role = discord.utils.get(interaction.guild.roles, name=fortnite)

@commands.command(name="reactionroles")
async def self_role(interaction: discord.Interaction):
  await interaction.response.send_message(content="Choose your favorite games", vie=SelfRoles())

  await interaction.user.ad_roles(1126332842591400027)```
naive briar
#

Your button isn't in the view class

slate swan
#

and what catlover said

slate swan
naive briar
#

That's not helpful

slate swan
naive briar
#

It didn't work doesn't explain your problem

ornate sapphire
#

but when it comes to doing the /reactionrole

#

tthe slash command doesn come up

ornate sapphire
ornate sapphire
#

instead of slash command cuz those dont work for me

slate swan
naive briar
#

I don't know about you, but commands.command isn't for creating slash commands

#

It's for prefix commands

ornate sapphire
#

been trying for so long

slate swan
ornate sapphire
#

stuooop

#

im new

slate swan
#

not making fun of you xD

#

so do you want your button to a slash command or a normal command

ornate sapphire
#

normal command

#

or slash

#

witchever is easier

slate swan
#

for me command

slate swan
#

code

ornate sapphire
ornate sapphire
#
class SelfRoles(discord.ui.View):
  def __init__(self):
    super().__init__(timeout=None)

@discord.ui.button(label="fortnite", style=discord.ButtonStyle.blurple)
async def blurple_color(self, interaction: discord.Interaction, Button: discord.ui.Button):
  blurple_role = discord.utils.get(interaction.guild.roles, name=fortnite)

@commands.command(name="reactionroles")
async def self_role(interaction: discord.Interaction):
  await interaction.response.send_message(content="Choose your favorite games", view=SelfRoles())

  await interaction.user.add_roles(1126332842591400027)```
#

everything runs fine

#

but I cant do the command

slate swan
#

and nothing happens, right?

turbid condor
ornate sapphire
slate swan
#

also cogs might not be loaded

sick birch
ornate sapphire
#

IDK WHA THAT MEANS

ornate sapphire
# turbid condor Can you show your main.py code
import discord
import os
import random
from discord.ext import commands

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

client = discord.Client(command_prefix="!", intents=intents)

@client.event
async def on_ready():
    print(f'We have logged in as {client.user}')


@client.event
async def on_ready():
    activity = discord.Game(name=f"Call of Duty Black Ops III", type=2)
    await client.change_presence(status=discord.Status.online, 
                                 activity=activity)
    
class SelfRoles(discord.ui.View):
  def __init__(self):
    super().__init__(timeout=None)

@discord.ui.button(label="fortnite", style=discord.ButtonStyle.blurple)
async def blurple_color(self, interaction: discord.Interaction, Button: discord.ui.Button):
  blurple_role = discord.utils.get(interaction.guild.roles, name=fortnite)

@commands.command(name="reactionroles")
async def self_role(interaction: discord.Interaction):
  await interaction.response.send_message(content="Choose your favorite games", view=SelfRoles())

  await interaction.user.add_roles(1126332842591400027)


client.run(why)```
sick birch
#

Have you learned about indents and how it works in Python yet?

sick birch
#

Your blurple_color is indented improperly, so it's outside of the SelfRoles class

#

Buttons need to be inside the view class (SelfRoles in your case) for discord.py to pick it up

#

Also you're not in a cog so @commands.command(...) isn't going to work

ornate sapphire
#

so how do I fix all that

slate swan
sick birch
#

By indenting the button function so it's within the class

turbid condor
#

Yeah and wouldn't @commands.command() be @bot.command() since this is not a cog

sick birch
#

Yup

ornate sapphire
#
@commands.command(name="reactionroles")
async def self_role(interaction: discord.Interaction):
    await interaction.response.send_message(content="Choose your favorite games", 
    view=SelfRoles())```
#

is this the right indent?

#

oh wait wrong one

ornate sapphire
#
@discord.ui.button(label="fortnite", style=discord.ButtonStyle.blurple)
async def blurple_color(self, interaction: discord.Interaction, Button: discord.ui.Button):
    blurple_role = discord.utils.get(interaction.guild.roles, name=fortnite)```
#

thiiiiiis is definititely right

#

right?

sick birch
#

Hard to tell without context

#

The indentation of the function only matters within the context of the class

turbid condor
#

Ok where are you giving the role to the users?

ornate sapphire
turbid condor
#

As far as i can see you are only getting the role

slate swan
sick birch
slate swan
#

by pressing tab

ornate sapphire
sick birch
#

Your button function (blurple_color) is still unindented, and, therefore, not inside the view class (SelfRoles)

slate swan
sick birch
ornate sapphire
#

like this?

slate swan
#

do same for @client.command

sick birch
#

No, don't do that

slate swan
#

??

turbid condor
#

Nope

#

That will remain outside

sick birch
#

Indentation on line 38 is inconsistent as well

ornate sapphire
sick birch
#

Can you paste your whole code now?

turbid condor
#

Oh an button might not work as you want it to

ornate sapphire
sick birch
#

What's the fortnite variable? You didn't define it anywhere

ornate sapphire
#

thats the name

#

not a variable

sick birch
#

It's a variable

#

That's why it's got the red squiggly under it

turbid condor
#

Then make it a string

ornate sapphire
slate swan
turbid condor
sick birch
#

no that's definetely an error color (red/orange)

#

You're referencing a variable that does not exist

ornate sapphire
#

then how do I fix that

#

cuz I thought it was just the name

turbid condor
#

Make it a string zzz

ornate sapphire
#

fixed it lol

sick birch
#

Okay, but your callback doesn't actually do anything

#

It just finds the role called "fortnite" and then gets garbage collected immediately after

turbid condor
#

You are only getting the role but not giving it

ornate sapphire
#

the awai line under that givse t

sick birch
#

No that line runs when the user runs the command

#

Not when they press on the button

turbid condor
#

That will give the role on command use not button press

ornate sapphire
#

😁

turbid condor
ornate sapphire
#

oh

turbid condor
#

Instead move it inside the button

sick birch
#

Green runs on button press and blue runs on command

turbid condor
#

And instead of role id put blurple_role there

ornate sapphire
#

like dis?

sick birch
#

Sort of but add_roles doesn't accept a plain ID

#

It accepts a discord.Role object (which you already have)

ornate sapphire
#

ofc it doesnt

turbid condor
#

But you still aren't using it

ornate sapphire
#

?

turbid condor
#

Remove the id inside add_role and use the blurple_role variable

sick birch
#

You're basically saying, "find a role named "fortnite", then ignore that role object. Instead, add this other role with ID instead"

turbid condor
#

Yup

ornate sapphire
#

yay

turbid condor
#

Now try running your bot

ornate sapphire
#

but how do I run the command in my server

#

!reactionroles?

turbid condor
#

Try using help command

#

It will show up there

ornate sapphire
turbid condor
#

Can u send an ss of the help command output

ornate sapphire
#

found something it just came up

#

wasnt their before I swar

turbid condor
#

Can u tell what is on line 36

ornate sapphire
turbid condor
#

There we go

#

For prefix commands we use ctx

ornate sapphire
#

oh

turbid condor
#

Not interaction

ornate sapphire
#

I did ctx.response.send_message() and it said ctx was undefined

turbid condor
#

Make it something like this

async def ping(ctx):
    await ctx.send('Your_message_here',view=....)
ornate sapphire
#

?

#

but where do I put that stuff

turbid condor
ornate sapphire
#

but all my ()s are filled in

#

theirs no place to put the ctx

turbid condor
#

Remove the interaction

slate swan
ornate sapphire
#

oh

turbid condor
#

You don't need those that's what throwing the error

ornate sapphire
#

ctx is undefined

turbid condor
#

You checked my example?

ornate sapphire
#

led?

#

oh ya

#

OH WAIT

slate swan
turbid condor
#

Then u should know why

ornate sapphire
#

like this

turbid condor
#

Yeah

ornate sapphire
#

now can I run it?

turbid condor
#

Yup

#

Try it and see

slate swan
#

should work

ornate sapphire
#

IT WORKED

#

accept when I clicked the button it said interaction faled

#

I think thats why

#

do I change this to

blurple_role = discord.utils.get(role_id)```
#

???

slate swan
#

See if it gives an error

ornate sapphire
#

do I gotta do blurple_role = discord.utils.get(int(role_id))

#

???

naive briar
#

Where did you get this

#

That's not how you use discord.utils.get

naive briar
ornate sapphire
#

?????

naive briar
#

What's confusing about it

turbid condor
#

The bot didn't find any role called fortnite in the guild u used the command

ornate sapphire
#

do capitals matter?

naive briar
#

Yes?

turbid condor
#

Yes

naive briar
#

Why wouldn't it

ornate sapphire
#

so...

turbid condor
#

So u switched it to id?

ornate sapphire
#

you told me too

turbid condor
#

I never did

ornate sapphire
#

so I switch it back to name?

turbid condor
#

Yeah

ornate sapphire
#

so interaction.user.add_roles(name="Fortnite")

turbid condor
#

Use the exact name of the role you have in the guild

ornate sapphire
#

do I need to say name= or no?

turbid condor
#

Just make it like it was befor

ornate sapphire
#

like this?

turbid condor
#

Like this

ornate sapphire
#

then can I run it again?

turbid condor
#

Yeah if you have the role name correct

ornate sapphire
#

interaction still failed...

naive briar
#

That didn't explain why

turbid condor
#

The error? And your code?

ornate sapphire
#

breh thats the role name

#

I have the name right

ornate sapphire
#

just no role for me

turbid condor
#

Then try defering the interaction

naive briar
#

That wouldn't help

ornate sapphire
#

OH WAIT

naive briar
ornate sapphire
#

it did give me the code

turbid condor
ornate sapphire
#

just when I click it it says interaciton failed... but it gave me the role

turbid condor
#

Yeah need to defer it then

ornate sapphire
#

how

naive briar
#

They just didn't respond to the interaction

#

Nothing to do with defer

turbid condor
naive briar
#

Because they called the add_roles?

turbid condor
#

Yeah and defer will stop that interaction failed?

ornate sapphire
#

it worked... all I need to do is fix the response when you click it

naive briar
#

No

#

If they still don't respond to it, nothing will change

turbid condor
#

Then can send an ephemeral message?

#

@ornate sapphire try sending an ephemeral message after the add role

#

Check and see if that works

ornate sapphire
#

wahts ephemeral?

turbid condor
#

It's an arg if set to true then only the user will see the message

slate swan
#

false=everyone sees

ornate sapphire
#

I added a bunch more and this is what I got

slate swan
#

. . .

naive briar
#

Sigh

ornate sapphire
#

whereeeeee

naive briar
#

Read the error

turbid condor
naive briar
#

And read what you sent

#

It shouldn't be too hard to find

ornate sapphire
#

i says "reactionroles" is not found

#

but it says REACTIONROLES

turbid condor
#

See it again

slate swan
#

nop

naive briar
#

No, it's reacionroles

ornate sapphire
#

ohhhhhhhhh

naive briar
#

People really can't recall what they sent

ornate sapphire
#

ya it worked now

slate swan
ornate sapphire
#

accept I was supposed to get 4 buttons

#

only got 1

naive briar
#

Because you kept overriding previous buttons in the view

ornate sapphire
#

how do I NOT override it

slate swan
#

you're using the same code for each button

ornate sapphire
#

ya... but different names

#

and roles

turbid condor
#

The function name to be precise

naive briar
#

All these buttons have the same function names, so they override eachother

ornate sapphire
naive briar
#

Learn Python first

slate swan
#

if functions are the same it will only load the first

ornate sapphire
turbid condor
slate swan
#

last i mean

naive briar
#

!e

class A:
    def a(self):
        print(0)

    def a(self):
        print(1)

A().a()
unkempt canyonBOT
#

@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.

1
ornate sapphire
#

it finally worked

#

although it says interaciton failed... but it worked

naive briar
#

You didn't respond to the interaction

turbid condor
#

Yeah just try sending an ephemeral response after someone clicks the button

ornate sapphire
naive briar
#

Describe what

#

That was already answered

slate swan
ornate sapphire
#

it was?

slate swan
ornate sapphire
slate swan
naive briar
#

It was literally just 10 minutes ago

#

Lmao

ornate sapphire
turbid condor
#
await interaction.response.send_message('your_message', ephemeral=True)```
turbid condor
slate swan
#

just add an comma then ephemeral

#

as nobody showed

ornate sapphire
#

like this????

turbid condor
#

Yeah

#

But you can make the message look good if u told what role you gave in the message

turbid condor
#

Tho the interaction failed should be solved now

ornate sapphire
#

it was beautiful

#

I luv you guys sooooooo much

turbid condor
#

Nah am straight XD

slate swan
naive briar
#

What is mention supposed to be

turbid condor
#

Nope role.mention where role is a variable

ornate sapphire
slate swan
turbid condor
#

But you can use role.name instead of actually mention

slate swan
ornate sapphire
#

oh

naive briar
#

That didn't answer the question

slate swan
turbid condor
naive briar
#

What object is mention supposed to be

naive briar
ornate sapphire
turbid condor
#

Long ago

slate swan
naive briar
#

What is it then

slate swan
naive briar
#

discord.Role object doesn't have an attribute called role

slate swan
naive briar
#

Already know

slate swan
#

ohh

ornate sapphire
turbid condor
#

Mind scrolling up a bit

#

And you may find your answer

slate swan
ornate sapphire
#

im stupid if you haven realized by now

turbid condor
#

Just a question why are u bothering with the role.mention?

#

When none will get pinged

#

Instead you can put the role name in your message directly

ornate sapphire
#

thought it was easy but dont care

#

Im fine with what I got

#

you guys helped me enough

slate swan
#

if you aren't using cogs

turbid condor
ornate sapphire
ornate sapphire
slate swan
ornate sapphire
ornate sapphire
#

sorry XD

slate swan
ornate sapphire
ornate sapphire
#

and now its not working

slate swan
#

you can read the website error log

ornate sapphire
#

the indenting n stuff

#

no errors, but when I do the !reactionrole command

slate swan
ornate sapphire
#

nothing happens

slate swan
#

website errors

ornate sapphire
#

oh no cuz the oher commands work

slate swan
#

cant help when you dont show anything and your not explaning really anything

ornate sapphire
#

no errors... but it wont do the command

slate swan
#

what hosting webstire you using

ornate sapphire
#

Daki

slate swan
turbid condor
#

Is the on_ready event firing when you start the bot?

ornate sapphire
#

but its how to host it

turbid condor
#

And one more thing u changed the command name to addrole then how would it work with reactionroles

ornate sapphire
#

lol not THAT dumb

turbid condor
#

And I don't see your on_ready event firing

#

There is no message here saying we have logged in

ornate sapphire
#

oh ya its not

#

idk why

slate swan
#

any errors

ornate sapphire
#

no

turbid condor
#

It just means the bot isn't ready tho it should not take long for it to get ready

slate swan
#

also that too

ornate sapphire
#

after days

turbid condor
#

Yeah then it might be a hoster problem try switching to someplace else

ornate sapphire
#

nothing else is free

turbid condor
#

Try discloud it has a free tier

ornate sapphire
slate swan
sick birch
#

Old machines also work

#

I have a raspberry pi hosting all my discord bot projects

slate swan
slate swan
#

Remove User error

crude geyser
#

Hello, I'd like to create a bot that connects to a voice chat room with a command for speech-to-text and text-to-speech, where speeches will be posted in a text chat room. Which libraries do you recommend to use in Python?

slate swan
naive briar
#

Your message variable from the list comprehension is unused

slate swan
#

messages.contest typo

slate swan
#
async def help(ctx: commands.Context):
    embed = nextcord.Embed(title="Currect Commands", description="setup_ticket (sets up tickets) \n setup_role (Allows a role to see all tickets)")```
**Why doesn't this work I got no error**
naive briar
#

What doesn't work exactly

slate swan
naive briar
#

I see no ctx.send in that code

slate swan
#

oh ... i forgot to put that part e

shut river
#

The Code:

The Error: Traceback (most recent call last):
File "/Users/mac/Desktop/GrowBet/main.py", line 59, in <module>
@bot.is_owner()
^^^^^^^^^^^^^^
TypeError: BotBase.is_owner() missing 1 required positional argument: 'user'

vocal snow
#

Bot.is_owner is not a decorator

winter token
shut river
#

@bot.is_owner(ctx.author)?

#

but ctx wouldnt be defined

winter token
vocal snow
#

It's not a decorator

shut river
#

what is the decorator

turbid condor
shut river
#

checking rn but i couldnt find

vocal snow
#

Use the search bsr

turbid condor
#

u sure u searched is_owner?

vocal snow
#

Search for is_owner

winter token
#

any1?

shut river
#
@bot.check_any(commands.is_owner)
``` ?
#

should i change check_any to check_once?

slate swan
#

I dont get why this is an error

vocal snow
shut river
shut river
vocal snow
turbid condor
vocal snow
slate swan
vocal snow
#

Well you need to define the bot variable before you use it

winter token
#

ANYONE GONNA HELP OR NO

turbid condor
slate swan
#

🤦‍♂️

slate swan
turbid condor
#

yeas

slate swan
winter token
#

??????????

slate swan
#

if possible

winter token
turbid condor
slate swan
slate swan
turbid condor
# slate swan

you might need to put the for loop inside a setup_hook

slate swan
turbid condor
#

and i suggest using setup_hook for connecting to the db

winter token
#

ok ig chatgpt is more helpful than this channel

naive briar
turbid condor
#

Instead of doing async setup in on_ready, or using a task which may lead to events being called before that task runs, you can overwrite Client/Bot.setup_hook.

For example:-

class MyBot(commands.Bot):
    async def setup_hook(self):
        print("Bot is starting")
        await self.load_extension("my.extension")```


https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.setup_hook
winter token
#

didnt know

slate swan
#

im confused

naive briar
turbid condor
#

since on_ready can fire many times

slate swan
# turbid condor Instead of doing async setup in on_ready, or using a task which may lead to even...
        if not self.persistent_views_added:
            self.add_view(CreateTicket(self))
            self.add_view(TicketSettings())
            self.persistent_views_added = True
            print("Persistent views added")
            self.db = await aiosqlite.connect("tickets.db")
            async with self.db.cursor() as cursor:
                await cursor.execute(f"CREATE TABLE IF NOT EXISTS roles (role INTERGER, guild INTERGER)")
            print("Database ready")
        print(f"{self.user} is ready!")
        print(f"Bot is ready | Logged in as {self.user}")  ```
This?
turbid condor
#

update the persistent view in a wait_until_ready event

turbid condor
slate swan
#

man what

#

you told me on_ready wasnt good so i replaced with setup_hook

turbid condor
#

yeah u did right

#

u need to connect to db and load extensions in setup_hook

#

as for updating your persistent view do that in wait_until_ready

slate swan
#

but idk how to add all of that into my code

turbid condor
#

like

async def setup_hook(self):
   #connect to the db and your for loop to load extensions here

async def on_ready(self):
    await wait_until_ready()
    # Your code for updating the view
slate swan
# turbid condor like ```py async def setup_hook(self): #connect to the db and your for loop ...
    self.db = await aiosqlite.connect("tickets.db")
    async with self.db.cursor() as cursor:
        await cursor.execute(f"CREATE TABLE IF NOT EXISTS roles (role INTERGER, guild INTERGER)")
        print("Database ready")
        
async def on_ready(self):
    await wait_until_ready()
    if not self.persistent_views_added:
        self.add_view(CreateTicket(self))
        self.add_view(TicketSettings())
        self.persistent_views_added = True
        print("Persistent views added")  
        print(f"{self.user} is ready!")
        print(f"Bot is ready | Logged in as {self.user}")  
turbid condor
slate swan
#

😭

turbid condor
#

isn't that a for loop?

slate swan
turbid condor
#

wait u using nextcord

slate swan
#

yup

turbid condor
#

let me check its docs for a bit

slate swan
#

oh I should have told you, sorry

turbid condor
#

there is wait_until_ready method

slate swan
turbid condor
slate swan
turbid condor
# slate swan

it seems there as an issue with your cogstickets file

slate swan
#

I dont see any errors here

turbid condor
#

there we have it

#

in latest versions u need to async every function

#
async def setup(bot):
    await bot.add_cog(Tickets(bot))```
#

like this

slate swan
#

thats strange

slate swan
#

use disnake much better

slate swan
slate swan
#

oh alright

turbid condor
#

i see

#

try removing cogs from your bot.load_extensions

slate swan
#

anyone use disnake library?

turbid condor
#

yeah in for loop

slate swan
#

alr

slate swan
#

idk if thats what you meant

turbid condor
#

not the line

slate swan
#

anyone know how to make modmail thing

slate swan
crude geyser
#

Hello, I'd like to create a bot that connects to a voice chat room with a command for speech-to-text and text-to-speech, where speeches will be posted in a text chat room. Which libraries do you recommend to use in Python?

slate swan
turbid condor
#

no

#

that's not the for loop

slate swan
slate swan
slate swan
turbid condor
# slate swan this?

in this picture there is a bot.load_extension(f"cogs{fn[:-3]}") in your for loop remove the word cogs from in it

#

idk how u assuming that i'm saying remove from load command when i have been clearly saying for loop

slate swan
turbid condor
#

thats checking for a file called cogstickets when there is only tickets there

naive briar
#

No, why would you need to remove it

#

Just fix it

slate swan
#

uhm

turbid condor
#

yeah works too

turbid condor
#

but you will need to import that first

slate swan
#

not cogstickets

naive briar
#

Then tell it to

slate swan
#

i will look on docs

naive briar
#

If your extension filename (fn) is from the cogs folder, you need to tell it to load them from there, like cogs.{fn}

#

It works just like Python import statements

slate swan
#

and already thought i had that in main.py

naive briar
#

Had what

slate swan
naive briar
#

And? You're telling it to load the extensions (that is from the cogs directory) from the current directory, not the cogs directory

slate swan
naive briar
#

No

slate swan
naive briar
#

Because you're telling it to

slate swan
naive briar
#

What don't you understand

slate swan
naive briar
#

Just think it as this

bot.load_extension("ext") # <-- it will try to load an 'ext' extension from the current directory

bot.load_extension("extensions.ext") # <-- it will try to load an 'ext' extension from the 'extensions' directory (or folder)
slate swan
naive briar
#

If you have them in the current directory, then probably

slate swan
#

ill try and fix later i have no idea how to fix this

naive briar
#

Just change it to bot.load_extension(f"cogs.{fn[:-3]}")?

#

I already explained how it works

#

And I'm running out of patience 🫠

slate swan
naive briar
#

Read the error

#

You should be subclassing commands.Cog, not commands.Cogs, which doesn't even exist

slate swan
#

bro

naive briar
#

What? No

#

I think I'm clear enough

slate swan
#
import nextcord

class Tickets(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def ping(self, ctx):
        await ctx.reply("Pong!")


async def setup(bot):
    await bot.add_cog(Tickets(bot))```
naive briar
#

nextcord's loading extensions and cogs stuff aren't async, like discord.py's

slate swan
naive briar
#

So, just remove async stuff (async def setup to def setup, await bot.add_cog to bot.add_cog)

naive briar
slate swan
#
import nextcord

class Tickets(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def ping(self, ctx):
        await ctx.reply("Pong!")


def setup(bot):
    bot.add_cog(Tickets(bot))``` 
I did this i ran bot went online but nothing came out of terminal
#

and the cog works just nothing came out of terminal

naive briar
#

Right, nextcord don't have setup_hook stuff

slate swan
naive briar
#

Yeah

slate swan
#
    await self.wait_until_ready()
    if not self.persistent_views_added:
        self.add_view(CreateTicket(self))
        self.add_view(TicketSettings())
        self.persistent_views_added = True
        self.db = await aiosqlite.connect("tickets.db")
        async with self.db.cursor() as cursor:
            await cursor.execute(f"CREATE TABLE IF NOT EXISTS roles (role INTERGER, guild INTERGER)")
            print("Database ready")
            print("Persistent views added")  
            print(f"{self.user} is ready!")
            print(f"Bot is ready | Logged in as {self.user}")  ```
naive briar
#

Show full code

#

!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.pythondiscord.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.

naive briar
#

Nor does it is decorated as an event

slate swan
# naive briar Your `on_ready` function isn't in your bot subclass
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.persistent_views_added = False
        async def on_ready(self):
            await self.wait_until_ready()
            if not self.persistent_views_added:
                self.add_view(CreateTicket(self))
            self.add_view(TicketSettings())
            self.persistent_views_added = True
            self.db = await aiosqlite.connect("tickets.db")
            async with self.db.cursor() as cursor:
                await cursor.execute(f"CREATE TABLE IF NOT EXISTS roles (role INTERGER, guild INTERGER)")
                print("Database ready")
                print("Persistent views added")  
                print(f"{self.user} is ready!")
                print(f"Bot is ready | Logged in as {self.user}")  ```
naive briar
#

No, move it down an indent, so it is considered to be in the class

slate swan
#
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.persistent_views_added = False
    async def on_ready(self):
        if not self.persistent_views_added:
            self.add_view(CreateTicket(self))
            self.add_view(TicketSettings())
            self.persistent_views_added = True
            self.db = await aiosqlite.connect("tickets.db")
            async with self.db.cursor() as cursor:
                await cursor.execute(f"CREATE TABLE IF NOT EXISTS roles (role INTERGER, guild INTERGER)")
                print("Database ready")
            print("Persistent views added")
        print(f"Bot is ready | Logged in as {self.user}") ```
slate swan
naive briar
#

Got what

slate swan
naive briar
#

It's not defined?

slate swan
naive briar
#

Those aren't in any cogs

#

Since they're not defined in one

#

First, make a cog for them or move them to one

slate swan
#

bro that is in a cog

naive briar
#

Where?

slate swan
naive briar
#

That's a Python file

#

There are many differences between extension and cog

slate swan
#

k ill try and fix later gonna go to bed

#

Right when nextcord expert came up

#

🗿

slate swan
#

The problem is most likely that you dont have self in commands inside cog

#

But didnt read full conversation

#

Or are they in Cog class i dont see them indented

slate swan
#

Do you have it in class

#

Cause looks like its not

slate swan
#

You need to move the commands to the Tickets class

slate swan
#

You created a Cog and didnt put any commands in it

#

You put them in global scope

naive briar
#

This is why basic Python is important

slate swan
#
class Tickets(commands.Cog):
    ...
    @commands.command()
    async def comm(self, ctx):
        ...```
slate swan
lethal drift
#

What's the correct "send" method for channels?

#
channel = bot.fetch_channel(ID)
channel. #method here
#

Nvm, it was giving wrong methods since I didn't await the coroutine

slate swan
#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

x != y Checks if two channels are not equal.

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
slate swan
#

is it a good idea to use different databases for stuff? say postgres for currency and all that more of interactive stuff like afk and all and idk mongo for moderation to store all the servers and their configs? or should i just use postgres for everything

#

no totally not a good idea

#

use one database for everything

#

thats why you can create tables to store multiple data

#

or collection in mongo

slate swan
#

more software more problems

hasty coral
#

I have a command that im using to bump servers that has my bot in them. If a user runs ?bump it sends a description of their server to a channel in my support server. The command ran fine until i tried to add a cooldown to the command. I keep getting the following error /home/container/bot.py:63: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited

    def __init__(self, bot):
        self.bump_cooldown = {}
    #Bump command
    @bot.command()
    async def bump(self, ctx):
        user = ctx.author
        if user.id in self.bump_cooldown and self.bump_cooldown[user.id] > 0:
                embed = discord.Embed(title="Bump Sserver", description="You can only bump your server once every 2 hours.", color=discord.Color.red())
                await discord.message.send(embed=embed)```
#

. ```else:
self.bump_cooldown[user.id] = 7200
chickbot_channel_id = 1126199929908494377
chickbot_server_id = 884813207888347228
chickbot_server = bot.get_guild(chickbot_server_id)
# Fetch the server information
guild = ctx.guild
server_name = guild.name
server_description = guild.description
server_members = len(guild.members)
server_invite = await guild.text_channels[0].create_invite()
channel_count = len(guild.text_channels) + len(guild.voice_channels)

        # Fetch the target channel in the other server
        target_channel = bot.get_channel(chickbot_channel_id)

        # Send the server information and invite link to the target channel
        await target_channel.send(f"Server Bumped :Bump:")
        embed = discord.Embed(title="Bumped Server Information", color=discord.Color.gold())
        embed.add_field(name="Server Name", value=f"{server_name}", inline=False)
        embed.add_field(name="Description", value=f"{server_description}", inline=False)
        embed.add_field(name="Member Count", value=f"{server_members}", inline=True)
        embed.add_field(name="Channel Count", value=f"{channel_count}", inline=True)
        embed.add_field(name="Invite Link", value=f"{server_invite}", inline=False)
        embed.set_footer(text=f"Successfully bumped by {ctx.author.name}")
        await target_channel.send(embed=embed)
        await discord.message.send(f"Server Bumped Successfully by {ctx.author.mention} :Bump:")

bot.add_cog(Bump(bot))```

hasty coral
potent spear
hasty coral
#

i know the discord.message.send needs to be ctx.send if thats what you mean

potent spear
#

add_cog is an async function => a coroutine

#

hence the coroutine 'BotBase.add_cog' was never awaited

hasty coral
#

so how do i fix it? async await bot.add_cog(Bump(bot))?

unkempt canyonBOT
#

examples/basic_voice.py line 147

await bot.add_cog(Music(bot))```
potent spear
#

click the link

hasty coral
# potent spear click the link

this whole bit of code? but replace the cog with my cog?

    async with bot:
        await bot.add_cog(Music(bot))
        await bot.start('token')```
potent spear
#

correct

#

you still have to run the main function though

#

best use case of cogs is using separate files for them though

#

to keep it all organized

hasty coral
#

will this not stop my other bot running code from working?

@bot.event
async def on_ready():
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers"))
    print(f"Bot is ready. Connected to {len(bot.guilds)} servers.")

bot.run('token')```
#

or can i put the presence code inside of main?

potent spear
#

commands.Bot has a kwarg with activity

#

so you don't need to change presence in the on_ready event, it's a common mistake

#

if you just set the activity in the bot's constructor, it'll set the presence when online

hasty coral
#

or how do i change it with the constructor

potent spear
#

bot = commands.Bot(<whatever_you_had_here>, activity = discord.Activity(...) )

#

see what I mean?

hasty coral
#

so will this work?
bot = commands.Bot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers") intents=intents)

potent spear
#

it will

hasty coral
#

gotcha

potent spear
#

also, your name makes no sense

#

at least, the first part

hasty coral
#

name?

potent spear
#

name of the activity

#
command_prefix = '?'
bot = commands.Bot(command_prefix=command_prefix, activity=discord.Activity(type=discord.ActivityType.listening, name=f"{command_prefix}help ‣ {len(bot.guilds)} servers") intents=intents)```
#

this makes more sense right? mind the {command_prefix} before help

hasty coral
#

i tried that, it just sets the status to prefixhelp ‣ 10 servers

#

doesn't put the symbol

potent spear
#

you didn't try it correctly in your case then

#

because I defined command_prefix above the bot

#

also, make sure your message_intents are enabled, or the bot won't respond to commands (as it won't be able to read the message content)

#

!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. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, 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

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

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

hasty coral
#

right, because i have it set using the bot = commands.Bot(command_prefix='?')

and then the prefix command that changes the prefix uses bot.command_prefix = new_prefix

potent spear
#

right...

hasty coral
#

and message intents is enabled already, my other commands work

potent spear
#

👍

#

maybe {self.command_prefix}help would work, at least, if the command_prefix is set first before the activity

#

in that case, you wont need to create a separate variable first

hasty coral
#

so.......

    async with bot:
        command_prefix = '?'
        bot = commands.Bot(command_prefix=command_prefix, activity=discord.Activity(type=discord.ActivityType.listening, name=f"{command_prefix}help ‣ {len(bot.guilds)} servers") intents=intents)
        await bot.add_cog(Bump(bot))
        await bot.start('token')```
potent spear
#

nope

#

bot needs to be defined first, before you can use async with bot

hasty coral
#

so....

    async with bot:
        command_prefix = '?'
        bot = commands.Bot(command_prefix=command_prefix, activity=discord.Activity(type=discord.ActivityType.listening, name=f"{command_prefix}help ‣ {len(bot.guilds)} servers") intents=intents)
        await bot.add_cog(Bump(bot))
        await bot.start('token')````
potent spear
#

nope

thin raft
potent spear
#

async with is a context manager

#

look up what context managers are

slate swan
#

why not use setup hook

thin raft
#

but

potent spear
slate swan
#

okay then

hasty coral
#

im so confused lol, the bot ran perfectly before i tried adding a cooldown 😂

slate swan
#

and what is the issue now?

potent spear
#

he's not adding his cog correctly

hasty coral
#

the code wont add the cog

#

ill explain it now @slate swan

potent spear
#

showed you exactly how to do that, but I guess somehow that's not clear 🤔

hasty coral
#

bot.add_cog(Bump(bot)) wont run

potent spear
#

just add that function on the bottom, run that function with asyncio like in the link, and you're all set

hasty coral
#

i get the error /home/container/bot.py:63: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited

slate swan
#

.add_cog was never awaited

hasty coral
unkempt canyonBOT
#

examples/basic_voice.py line 147

await bot.add_cog(Music(bot))```
naive briar
#

It is just as clear as it could possibly be

slate swan
#

do you see any difference between this:

  • bot.add_cog(Bump(bot))
    and this
  • await bot.add_cog(Music(bot))
hasty coral
#

and the function is more complex than just await bot.add_cog(Bump(bot))

slate swan
#

not talking about the class name

slate swan
hasty coral
#

lemme copy it quickly

#

they said i needed to add this whole thing

    async with bot:
        await bot.add_cog(Music(bot))
        await bot.start('token')


asyncio.run(main())```
naive briar
#

Why

hasty coral
#

but my token and bot define code are already functioning outside of that

slate swan
#

why you cant just do await bot.add_cog(Bump(bot) ?

#

i still dont get it

hasty coral
#

thats why i was confused

#

because they said no you need the main function

naive briar
#

It can be any async function

slate swan
#

well in this case you actually need it since you cant do await outside async function

potent spear
hasty coral
#

so all i have to do is put await infront of my add_cog function?

slate swan
#

or put it in setup_hook

#
bot = ...

async def setup_hook():
    # do stuff

bot.setup_hook = setup_hook

bot.run(...)
hasty coral
#

right, lemme right out the code like that and you tell me if it'll work or not

#

async def setup_hook():
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers"))
    print(f"Bot is ready. Connected to {len(bot.guilds)} servers.")
    await bot.add_cog(Bump(bot))

bot.setup_hook = setup_hook

bot.run(token)```

@slate swan will this work?
#

intents are already defined btw

slate swan
#

should be but why change presence in setup_hook if you can start the bot with activity already

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
slate swan
#

pass activity here

hasty coral
slate swan
#

it works but its unnecessary api call

#

you should avoid doing that

hasty coral
slate swan
#

?

fickle crown
#
embed.timestamp = datetime.datetime.utcnow()```


discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Embed.__init__() got an unexpected keyword argument 'Timestamp'


What has changed in Discord PY time?
slate swan
#

as it tells you Embed constructor does not take Timestamp argument

#

its passed by attribute

#

!d discord.Embed.timestamp

unkempt canyonBOT
#

The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.

slate swan
#
@bot.check
async def allChecks(ctx):
    if await bot.isBlacklisted(ctx.author.id): raise blacklistError()

    if bot.checkMaintenance(): 
        if ctx.command.parent == "dev" and ctx.command.name == "maintenance": return True
        raise maintenanceError()

    return True

``` why doesnt this check for the command parent and name (this is py-cord not d.py)
hasty coral
unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
hasty coral
#

it doesnt work.

bot = commands.Bot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers") intents=intents)

naive briar
#

Really pithink

potent spear
#

you're not showing us the actual issue

naive briar
#

!e

a = str(a)
unkempt canyonBOT
#

@naive briar :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     a = str(a)
004 |             ^
005 | NameError: name 'a' is not defined
hasty coral
# potent spear probably some other stuff, like for example you have bot defined twice or whatev...

erm no....

from discord.ext import commands, tasks
from datetime import datetime, timedelta
import json

intents = discord.Intents.all()

bot = commands.Bot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers") intents=intents)

async def setup_hook():
    print(f"Bot is ready. Connected to {len(bot.guilds)} servers.")
    await bot.add_cog(Bump(bot))

bot.setup_hook = setup_hook
slate swan
#

!d nextcord.Embed

unkempt canyonBOT
#

class nextcord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.11)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then `None` is returned.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.11)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.11)") for you...
potent spear
#

the setup hook doesn't work like that my friend

#

check how setup_hook works through the examples

#

you have to extend your bot class in order to be able to use that

hasty coral
#

i was missing a comma, i solved that, but no its telling me bot isnt defined

#

bot = commands.Bot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers"), intents=intents)

slate swan
hasty coral
#

better view of the code

from discord.ext import commands, tasks
from datetime import datetime, timedelta
import json

intents = discord.Intents.all()

bot = commands.Bot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers"), intents=intents)

async def setup_hook():
    print(f"Bot is ready. Connected to {len(bot.guilds)} servers.")
    await bot.add_cog(Bump(bot))

bot.setup_hook = setup_hook```
hasty coral
slate swan
hasty coral
#

now that ive added the setup_hook it no longer works

slate swan
potent spear
#

mhm, not clean though

slate swan
hasty coral
#

right. you guys obviously know how to do it. Please do me a favour and adjust this so that it works. i will read through it and understand what i did wrong after

from discord.ext import commands, tasks
from datetime import datetime, timedelta
import json

intents = discord.Intents.all()

bot = commands.Bot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers"), intents=intents)

async def setup_hook():
    print(f"Bot is ready. Connected to {len(bot.guilds)} servers.")
    await bot.add_cog(Bump(bot))

bot.setup_hook = setup_hook```
slate swan
#

🤫

potent spear
#
intents = discord.Intents.all()
class MyBot(commands.Bot):
  async def setup_hook(self):
    print(f"Bot is ready. Connected to {len(self.guilds)} servers.")
    await bot.load_extension("Bump")
bot = MyBot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(self.guilds)} servers"), intents=intents)

bot.run("poop")

hold up

#

you're never loading the extension

#

bruh

#

in your bump cog, you should add

#
async def setup(bot):
   await bot.add_cog(Bump(bot))```
slate swan
#

you can just add cogs like done before cant you

#

no need to use setup functions

hasty coral
potent spear
#

no setup function in your class

#

put it outside

slate swan
#

setup function is supposed to be in global scope

#

!d discord.ext.commands.Bot.load_extension

#

ok bot thanks

potent spear
#

load_extension will look for a Bump.py file & will call the setup function by itself

slate swan
#

for hte docs

hasty coral
#
    await bot.add_cog(Bump(bot))
class Bump(commands.Cog):
    def __init__(self, bot):
        self.bump_cooldown = {}```
slate swan
#

!d discord.ext.commands.Bot.load_extension

hasty coral
#

?

slate swan
#

!d discord.ext.commands.Bot.load_extension

#

!ping

#

ok

naive briar
#

Great

slate swan
#

someone else type it

naive briar
#

!e

slate swan
potent spear
#

but yeah, you're all said if done what was asked

slate swan
hasty coral
#

its telling me im using an inconsistent amount of indents.....!?

    async def setup_hook(self):
        print(f"Bot is ready. Connected to {len(bot.guilds)} servers.")
        bot = MyBot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers"), intents=intents)```
slate swan
#

!indent

#

oh forgot

potent spear
#

that's because you're copy pasting

#

that's what you get

slate swan
#

!d

unkempt canyonBOT
hasty coral
#

error: bot is not defined

    async def setup_hook(self):
        print(f"Bot is ready. Connected to {len(bot.guilds)} servers.")
        bot = MyBot(command_prefix='?', activity=discord.Activity(type=discord.ActivityType.listening, name=f"?help ‣ {len(bot.guilds)} servers"), intents=intents)

bot.run("token")```
slate swan
#

you dont have bot now

#

you have self since you are insice bot class

hasty coral
#

so self.run(token)

potent spear
#

no

slate swan
potent spear
#

it's in the print

slate swan
#

thats why i didnt suggest creating a subclass

potent spear
#

connected to len(self.guilds)

#

same for activity

#

len(self.guilds)

hasty coral
#

the error appeared for bot.run not the bot presence

slate swan
#

maybe the subclassing guide is done so far

#

let me check ill link you if it does

slate swan
fickle crown
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
userAvatar = member.avatar_url
AttributeError: 'Member' object has no attribute 'avatar_url'

????

slate swan
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s handle (e.g. `name` or `name#discriminator`).
slate swan
#

check what attributes it has

fickle crown
#
@ commands.has_role(XXXXX)
async def png(ctx, *, member: discord.Member = None):  # set the member object to None
    channel = ctx.channel
    await channel.purge(limit=1)
    if not member:  # if member is no mentioned
        member = ctx.message.author  # set member as the author
    userAvatar = member.avatar_url
    await ctx.send(userAvatar)```
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url' 
 userAvatar = member.avatar_url
AttributeError: 'Member' object has no attribute 'avatar_url'
potent spear
#

the issue here is you're either looking for old tutorials, or you're copy pasting outdated code
because you can't have this problem if you looked at the docs

fickle crown
#

Discord changed (_)

slate swan
#

i wanted you to go read the docs so you can solve such problems by yourself next time and you will save time

young dagger
#

Oh you mean that I should use this instead?

start_time = time.perf_counter()
end_time = time.perf_counter()```
sharp whale
#

how do we send a gif in a embed

turbid condor
young dagger
#

Thanks

slate swan
#
def match_search_places(place, coins = 0, item = "Nothing"):
    match place:
        case '...':
            if random.random() < 0.5:
                if random.random() > 0.5:
                    return f"..."
                else:
                    return f"..."
            else:
                return f"..."
        case 'Canal':
            if random.random() < 0.5:
                if random.random() > 0.5:``` is there a more efficient way of doing this deciding if u get an item or a coin, or just dont get anything
lethal drift
#

How do I created a select options? with tree commands?

sick birch
#

Not sure I'm following

lethal drift
slate swan
#

yeah thats python

lethal drift
# sick birch Sorry?

I was lookin for a way to make a preset selection for one of the slash command arguments

#

I'm used to pycord so I'm not sure how to do it in d.py

slate swan
#

why not just stick to pycord then