#discord-bots

1 messages · Page 97 of 1

slate swan
#

thats the point.. i dont know how to start like
@bot.commands()
async def reaction_roles(ctx):

#

like how

faint sapphire
#

u forgot one of the intents

#

message intents

sick birch
whole hull
#

is that okay

slate swan
#

thanks

sick birch
faint sapphire
whole hull
sick birch
#

awesome

#

it works?

brazen raft
#

How are you trying to run the command

whole hull
brazen raft
#

It should be run with !hi

sick birch
#

oh, i see. not printing the command

whole hull
#

YH

whole hull
sick birch
#

are you actually calling the command from discord?

whole hull
sick birch
#

oh, great

whole hull
#

tyyy

faint sapphire
#

is it ight if i use the free tier of oracle?
otherwise the cheapest version of vultr/digital ocean

i plan on running 2 bots on whichever vps I use
both bots would prob be used in ab 100 servers each

brazen raft
#

Bot commands are run with the command_prefix prefix

#

It's like this for all bot commands

whole hull
#

alright

slate swan
unkempt canyonBOT
#

examples/reaction_roles.py line 29

role_id = self.emoji_to_role[payload.emoji]```
slate swan
faint sapphire
#

i dont use prefixes lol

brazen raft
#

Enlighten me

faint sapphire
#

🔦

slate swan
cloud dawn
#

It's all so clear now

slate swan
#

crisp.

grim oar
#

Ashley

cold sonnet
#

Nova

cloud dawn
#

Dani

slate swan
#

Panda

#
class CreateTicket(discord.ui.View):
  def __init__(self):
      super().__init__(timeout=None)
  
  @discord.ui.button(
    label="Create Ticket", style=discord.ButtonStyle.green, custom_id="create_ticket:green"
  )
  async def create_ticket(self,  interaction: discord.Interaction, button: discord.ui.Button):
      overwrites = {
        interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
        interaction.guild.me: discord.PermissionOverwrite(read_messages=True),
        interaction.guild.get_role(1010395040385876029): discord.PermissionOverwrite(read_messages=True)
      }
      channel = await interaction.guild.create_text_channel(f"{interaction.user.name}-ticket",
      overwrites=overwrites)
      msg = await interaction.response.send_message(f"**__Ticket Created Successfully__** {channel.mention}", ephemeral=True)
      embed = discord.Embed(title="Ticket Created", description=f"{interaction.user.mention} Created A Ticket! \n Click The Button Below To Close The Ticket.")
      await channel.send(f"{interaction.user.mention} <@&1010395040385876029>", embed=embed, view=TicketSettings())

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


  @discord.ui.button(
    label="Close Ticket", style=discord.ButtonStyle.red, custom_id="ticket_settings:red"
  )
  async def close_ticket(self,  interaction: discord.Interaction, button: discord.ui.Button):
    if interaction.permissions.manage_messages == False:
     return await interaction.response.send_message(content="**You Can't Close The Ticket! Only Staff Can!**", ephemeral=True)
    await interaction.response.send_message(content="Ticket Is Being Closed..")
    await interaction.channel.delete()
    await interaction.user.send(f"Ticket Closed Successfully! By {interaction.user.mention}")

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.add_view(TicketSettings())
          self.persistent_views_added = True
          print("Persisitent views added")


@bot.command()
@commands.has_permissions(manage_channels=True)
async def setup_tickets(ctx: commands.Context):
    embed = discord.Embed(title="Create A Ticket!", description="Click The Create Ticket Button Below To Create A Ticket")
    await ctx.send(embed=embed, view=CreateTicket())```
cold sonnet
#

😭😭😭

slate swan
#

if a member opens a ticket

#

it doesnt show him the ticxket

cold sonnet
#

but it does make the ticket?

slate swan
#

yes

#

but the member who opens it cant see it which is weird

rotund creek
#

bruh does anybody here have a dashboard for their bot

cold sonnet
#

set interaction.response.author's read_messages permission to True

slate swan
#

i will try

cold sonnet
#

interaction.response.author: discord.PermissionOverwrite(blabla)

slate swan
#

interaction.guild.author: discord.PermissionOverwrite(read_messages=True),

cold sonnet
#

note that anybody can create a ticket that way

#

using that button

#

multiple times

slate swan
#

ill try thank you

sick birch
rotund creek
#

what features did it have

slate swan
#

@cold sonnet

cold sonnet
#

then it's user

sick birch
cold sonnet
#

not author

slate swan
#

oh okay

cold sonnet
#

I'm used to disnake for some reason

rotund creek
slate swan
#

maybe member or smt?

cold sonnet
#

what

#

wait

slate swan
#

okay

cold sonnet
#

there's interaction.user

slate swan
#

interaction.user: discord.PermissionOverwrite(read_messages=True),

cold sonnet
#

I think they changed InteractionResponse

slate swan
#

ill try

slate swan
#

Thank u sm

cold sonnet
#

good

cloud dawn
tough lance
#

Hi, when I try to edit an embed containing the image, it gets duplicated as shown in the screenshot. I'm setting image in the embed through file kwarg

emb = discord.Embed(
        description=f"{inter.author.mention} is dropping a set of 3 cards!",
        color=0x2F3136)
emb.set_image(file=discord.File(buff, filename="image.png"))

and

m.embeds[0].set_footer(text="This drop has expired")
await self.inter.edit_original_message(view=self, embed=m.embeds[0])
#

disnake ofc

cloud dawn
#

If you were to remove the set_image?

#
m.embeds[0].set_footer(text="This drop has expired")
m.embeds[0].set_image(file=None)
await self.inter.edit_original_message(view=self, embed=m.embeds[0])
tough lance
#

already tried that

#
Traceback (most recent call last):
  File "/home/runner/Bot/views.py", line 45, in on_timeout
    m.embeds[0].set_image(file=None)
  File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/embeds.py", line 462, in set_image
    raise TypeError("Neither a url nor a file have been provided")
TypeError: Neither a url nor a file have been provided
tough lance
#

also tried that

cloud dawn
#

I guess just remove the attachments.

faint sapphire
#

does the region i choose for my oracle server matter?
ik i should pick whats closer to most bot users
but just wondering

tough lance
cloud dawn
cloud dawn
faint sapphire
#

interesting, ill look up where discord servers are thanks

shrewd apex
#

technical research pithink

cloud dawn
cloud dawn
faint sapphire
#

no cap

#

french government warned there ight be blackouts

#

even tho we are the ones using nuclear the most

cloud dawn
faint sapphire
#

oracle is free

slate swan
#

it isn't

#

just a free year

cloud dawn
faint sapphire
#

theres free unlimited tier, they say unlimited

cloud dawn
#

Never heard of it.

faint sapphire
#

and theres an offer for 1 pound for a provider in the uk (1 year)

cloud dawn
#

I don't recommend cheaping out on a VPS, 10 bucks a month is fairly reasonable if you look at the specs + electricity cost.

shrewd apex
#

meanwhile me playing on my pc pithink

cloud dawn
#

My pc draws 230 watt on idle.

faint sapphire
cloud dawn
faint sapphire
#

im planning on using a vps for 2 bots, (serving 100 servers each)

shrewd apex
faint sapphire
#

i have one

shrewd apex
#

run it of ur power bank kek

faint sapphire
#

but since i use the wifi from a neighbour, i cant
i tried using bros trend usb antenna, but doesnt work X0 (the installation driver)

shrewd apex
#

huh?

faint sapphire
#

its kinda a mess to install the driver

shrewd apex
#

so sus wifi from neighbour and whats usb antenna got to do with hosting bot

cloud dawn
faint sapphire
#

powerbank??

shrewd apex
#

rpi was how much voltage 5-12v cap right?

#

and 1-1.5amp i think

cloud dawn
feral frost
#

guys how do i see if a button is clicked ?

#

like from the label of the button

shrewd apex
#

2 c types also

#

how much it cost 👀

cloud dawn
feral frost
shrewd apex
cloud dawn
cloud dawn
shrewd apex
#

ooh noice

#

usd? $

cloud dawn
#

Euro

shrewd apex
#

damn that 8.5k in inr

cloud dawn
#

I assume that is a lot

shrewd apex
shrewd apex
#

for 8.5k

feral frost
cloud dawn
#

But I recently got the steam deck and my phone do be ded sometimes so I wanted something that lasts long, it's also an aluminum chassis.

cloud dawn
shrewd apex
#

noice noice 😄

feral frost
shrewd apex
#

er it not about the pricing its about indian/asian mindset when shopping pBlush

shrewd apex
feral frost
#

and how do i use it in an if thing

shrewd apex
#

just use if statement to check with custom ids

feral frost
#

what code do i use ?

shrewd apex
#

u can get the custom id using interaction.data["custom_id"]

feral frost
#

ok

shrewd apex
feral frost
#

because some ppl make a big deal if i ask for code

shrewd apex
#

fair enough

feral frost
shrewd apex
#

i am too sleepy to even care

#

inside the callback

feral frost
cloud dawn
#

Dw Asher is a known spoon feeder

shrewd apex
#

the interaction is the first param

#

huh really 👀?

feral frost
#
        await interaction.data["custom_id"]```
#

like this

shrewd apex
#

u don't need to await it

cloud dawn
shrewd apex
#

interaction.data is a dict

feral frost
#

do i have to == it ?

shrewd apex
#

yeah

feral frost
#

ok

#

and if it ?

shrewd apex
#

set a custom id then use if == add code below

feral frost
#

ok

shrewd apex
#

!d discord.ui.Button if u are wondering how to set custom id

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
feral frost
#

ye i knew it but thanku 🙂

shrewd apex
#

👍

feral frost
#

it works thanku very much

shrewd apex
#

👍

vivid gate
#

ok

#

so i have a question

#

im writing a bartender discord bot

#

when i say c!menu the bot gives me the menu
and for example when i say c!water the bot gives me a pic of water

#

but i want to make the bot delete menu after i said c!water

#

is it possible ?

honest shoal
vivid gate
honest shoal
vivid gate
#

owww

#

cool but i dont know how can i use it XD

light jungle
#

Hello everyone, I have a question who has an example of how to use "wait_for" how to make such a bot that will display a message and wait for the user to respond to it (through the "reply" function). And if a person responds to this message just like that (without the "reply" button), then the bot will ignore him

honest shoal
light jungle
shut tendon
#

Hi guys! I don't know why this is not unbanning

honest shoal
honest shoal
honest shoal
shut tendon
#

I checked everything with prints and it should work properly

#

But idk

honest shoal
#

what do those underlines say?

shut tendon
#

weak warnings

vivid gate
shut tendon
#

such as spaces blabla

slate swan
#

how do i make a command that deletes channels as in the code under the async def stuff

honest shoal
honest shoal
vivid gate
#

am i so stupid

shut tendon
unkempt canyonBOT
#
Out of the question.

No documentation found for the requested symbol.

honest shoal
#

!d discord.abc.GuildChannel.delete

unkempt canyonBOT
#

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

Deletes the channel.

You must have [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") to do this.
light jungle
#

Hello everyone, I have a question who has an example of how to use "wait_for" how to make such a bot that will display a message and wait for the user to respond to it (through the "reply" function). And if a person responds to this message just like that (without the "reply" button), then the bot will ignore him

slate swan
honest shoal
vivid gate
#

XD

honest shoal
#

this is not even python

slate swan
vivid gate
#

lets not talk about it

slate swan
#

@honest shoal got a fix?

honest shoal
vivid gate
honest shoal
honest shoal
#

I use disnake

vivid gate
#

ow ok

honest shoal
light jungle
#

What is this?

vivid gate
#

maybe i ask once more ?

#

if anyone knows

honest shoal
vivid gate
#

so i have a question
im writing a bartender discord bot
when i say c!menu the bot gives me the menu
and for example when i say c!water the bot gives me a pic of water
but i want to make the bot delete menu after i said c!water
is it possible ?

light jungle
honest shoal
#

you cannot reply a member

light jungle
honest shoal
light jungle
#

fork: nextcord

honest shoal
#

are you using slash command?

light jungle
#

Yes

honest shoal
#

reply is not used in them

shut tendon
#

But the code should work anyway

light jungle
#

oh. Okey

honest shoal
#

it's response.send_message() in dpy and disnake idk about nextcord

#

try it

honest shoal
light jungle
#

That's why I'm asking, I want to make a bot that will wait for a response to a message (through the "reply" item). I know what to do through wait_for but I don't understand how. Does anyone have any ideas?

shut tendon
# honest shoal

I used that before with ban commands and it completely works

#

@bot.command() and @commands.command are the same

light jungle
honest shoal
light jungle
#

Okay, not the point, how can you use wait_for to request a response through the "wait_for" function

honest shoal
#

I am not sure (don't remember), I guess it takes a check

light jungle
#

"check" is something like a check that checks if the person answered or not?

primal token
astral ether
#

hello then I have a problem, to make my bot in discord.py, my functions below :

@client.command()
async def rules(ctx):
    embed1 = discord.Embed(colour=None, color=0xe74c3c, title='**Réglement du Cinéma** :movie_camera:', type='rich', description='test')
    view=Menu()
    await ctx.send(embed=embed1, view=view)

displays rules and a button, below, I would like that when the user clicks on accept the bot adds a role to him, but I can't, because I don't know how to give my class the id of the user
the class :

class Menu(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value=None

    @discord.ui.button(label="Accepter le réglement", style=discord.ButtonStyle.green)
    async def menu1(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_message("hello you cliked me !",ephemeral=True)
slate swan
#

Hello I want my bot to say that i entered a bigger number than 10
It is possible
Here a example

/play mines:11
Sorry,but our maxim mines is 10
shut tendon
#

I might change everything and that's it

primal token
astral ether
#

anyone help me please ?

astral ether
#
    @discord.ui.button(label="Accepter le réglement", style=discord.ButtonStyle.green)
    async def menu1(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_message(interaction.author.id,ephemeral=True)
light jungle
#

who has a code example when a person replied to a bot message (using the "reply" function) and the bot answered him this message. And vice versa, if the person did not answer, then the bot can conditionally ignore him

honest shoal
# astral ether

it exits in disnake, I didn't expect a different thing in dpy

slate swan
#

why isnt this command deleting channels

#

if anyone knows let me know please

glad cradle
#

!d nextcord.ext.commands.Bot.command

unkempt canyonBOT
#

@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.command "nextcord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.GroupMixin.add_command "nextcord.ext.commands.GroupMixin.add_command").
slate swan
glad cradle
#

the name of the command should be indicated with a kwarg
@bot.command(name="delete")

glad cradle
glad cradle
slate swan
# glad cradle you've defined `authorID` as `self.ctx` so you should use it since you don't hav...
max_values=1 options=[<SelectOption label='Komi Anime Computer Wallpapers' value='Komi Anime Computer Wallpapers' description=None emoji=<PartialEmoji animated=False name='🚲' id=None> default=False>, <SelectOption label='Shouko Komi Wallpapers' value='Shouko Komi Wallpapers' description=None emoji=<PartialEmoji animated=False name='�'' id=None> default=False>, <SelectOption label='Komichi Akebi Wallpapers' value='Komichi Akebi Wallpapers' description=None emoji=<PartialEmoji animated=False name='🏰' id=None> default=False>, <SelectOption label="Komi Can't Communicate Desktop Wallpapers" value="Komi Can't Communicate Desktop Wallpapers" description=None emoji=<PartialEmoji animated=False name='🚄' id=None> default=False>, <SelectOption label="Komi Can't Communicate Cute Wallpapers" value="Komi Can't Communicate Cute Wallpapers" description=None emoji=<PartialEmoji animated=False name='🎇' id=None> default=False>] disabled=False>
Traceback (most recent call last):
  File "C:\Users\Ravi\AppData\Roaming\Python\Python310\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "e:\Programming\Rishit\Python\Projects\Pinterest-Bot\main.py", line 60, in callback
    await interaction.response.edit_message(embed=self.embed,view=self.view)
  File "C:\Users\Ravi\AppData\Roaming\Python\Python310\site-packages\discord\interactions.py", line 812, in edit_message
    await adapter.create_interaction_response(
  File "C:\Users\Ravi\AppData\Roaming\Python\Python310\site-packages\discord\webhook\async_.py", line 219, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
``` changed the code to what you said, but this error pops up, confused again
astral ether
#

Could someone help me to just print the id of the user who clicks the button? i use discord.py

    @discord.ui.button(label="Accepter le réglement", style=discord.ButtonStyle.green)
    async def menu1(self, interaction: discord.Interaction, button: discord.ui.Button):
        print(interaction.client)
slate swan
#

interaction.user.id

astral ether
glad cradle
#

non-deferred interaction lasts for 3 seconds

#

if you defer them they last for 15 min

old token
#

I saw this on the dpy docs, ```py

            async def on_timeout(self):
                for child in self.children:
                    child.disabled = True
                await self.response.edit(view=self)
            ```

but I don't actually know how what self.response is? How do I get the interaction?

slate swan
#

i know i can send a followup message but not sure how to edit

#

the previous

glad cradle
#

you're using d.py right?

grand willow
#

can someone tell me why this doesnt work

slate swan
#

yes

native smelt
old token
slate swan
#

bot = commands.Bot(command_prefix='!', somewhat like this

grand willow
grand willow
glad cradle
#

@slate swan it's edit_original_response

old token
glad cradle
#

sorry I confused it with disnake

grand willow
glad cradle
#

if you're using discordpy it's

from discord.ext import commands

bot = commands.Bot(...)

or

from discord.ext.commands import Bot

bot = Bot(...)
grand willow
glad cradle
#

then you should use the first example

#

how you import things doesn't matter

#

you just have to know classes, check docs for this e.g discord.ext.commands.Bot if you do from discord.ext import commands it's obvious that you have to do commands.Bot

primal token
#

its just importing namespaces to define them in the global scope

slate swan
glad cradle
slate swan
#

yes

#

my internet is good

glad cradle
#

it could be your network latency

slate swan
#

hmm

#

could be

#

Thanks

weary flume
#
@client.event
async def on_message(message, ctx):
    if message.content.count("\n") > 2:
        await ctx.send("hi")
#

is there a problem with this?

old token
#

ye

#

on_mesage doesn't have Context

#

only message

weary flume
#

im confused

slate swan
#

@glad cradle this?

weary flume
#

nvm

glad cradle
primal token
glad cradle
#

!d nextcord.TextChannel.delete

unkempt canyonBOT
#

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

Deletes the channel.

You must have [`manage_channels`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Permissions.manage_channels "nextcord.Permissions.manage_channels") permission to use this.
slate swan
#

@brazen raft

#

mad confusing

glad cradle
glad cradle
# slate swan mad confusing

to put it simple it's

@bot.command(name="delete")
async def wipe(ctx, channel: nextcord.TextChannel):
    await channel.delete()
brazen raft
# slate swan <@350619697231691776>

Make sure with an alt account. If it's visible from another account, it means ephermal=True just won't hide messages with embeds for other users.

glad cradle
glad cradle
#

watch your screenshot

slate swan
glad cradle
slate swan
#

oh

glad cradle
#

a very common blocking call among newbies is time.sleep()

slate swan
glad cradle
glad cradle
#

😩😩

slate swan
# glad cradle blocking calls

the only problem i have rn is that if i switch the category, the download button doesn't shows up, https://paste.pythondiscord.com/hivahurala is my code, i think could be because i am removing the download from view, but i can't think of a another way to replace, the download button with the new link, it gets replaced when i click the button, can you help please? Thanks!

glad cradle
slate swan
#

it legit wont work android_sob_sobbing_cry_crying

glad cradle
#

why you're passing an int to channel ?

#

channel is a TextChannel object

#

it doesn't make sense what you're doing

slate swan
glad cradle
#

it could only be done by someone who doesn't know Python OOP

slate swan
#

LOL

slate swan
#

Thanks

glad cradle
#

you're using many blocking calls

primal token
unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

glad cradle
#

open is a blocking call

slate swan
#

i see

glad cradle
#

you should use aiofiles to open and read files

#

!pypi aiofiles

unkempt canyonBOT
slate swan
glad cradle
#

Read is a coroutine

brazen raft
#

You need to install, import and actually use it. Or you can read it line by line and await asyncio.sleep(0) at the end of each line reading assuming you are already in an asynchronous context

slate swan
#

ah.

glad cradle
#

that's the basic example of aiofiles

async with aiofiles.open('filename', mode='r') as f:
    contents = await f.read()
print(contents)
>>> 'My file contents'
#

really simple to use

slate swan
#

yes, made all of them like that

glad cradle
slate swan
#

yep, it is, i'll try to format it better after everything works fine

glad cradle
#

you're redefining already existing buttons

slate swan
#

just wanted to fix the download button problem for now and sleep,

glad cradle
#

you have a view but you're not using it so much

slate swan
#

i think i am using it for every button response?

glad cradle
glad cradle
slate swan
#

so i basically, make a download button, add it to the view , then remove it from view after sending the message, doing same for buttons

slate swan
#

i haven't done much OOP till now

slate swan
glad cradle
slate swan
#

121 , 123

slate swan
glad cradle
slate swan
#

yeah, sort of, ig, but not sure how i can get the download button inside the callback

glad cradle
#

btw it has a really bad design you should really look into the examples

faint sapphire
#

damn bro i thought it was possible to make an alt with oracle, but they ask so much info

indigo pilot
#

Anyone know why im getting this error

#
[2022-09-30 16:41:14] [ERROR   ] discord.ui.view: Ignoring exception in view <Queue timeout=None children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Deny' emoji=None row=None>
Traceback (most recent call last):
  File "C:\Users\kaelm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\kaelm\PycharmProjects\1019664108519432267\cogs\gatekeeper\core.py", line 70, in queue_deny_button
    await interaction.response.send_modal(DenyPunishType(author=author))
  File "C:\Users\kaelm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 895, in send_modal
    params = interaction_response_params(InteractionResponseType.modal.value, modal.to_dict())
AttributeError: 'DenyPunishType' object has no attribute 'to_dict'```
slate swan
#

how do i upgrade to pip 22.2.2

vale wing
slate swan
#

thank youu!

vale wing
#

You alr have it installed

slate swan
#

oh

vale wing
indigo pilot
#

DenyPunishType gets edited in a message then

#

each option just sends a diff modal

#

ive got that

#

its response.send_modal

vale wing
#

!d discord.InteractionResponse.send_modal

unkempt canyonBOT
#

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

Responds to this interaction by sending a modal.
indigo pilot
#

ik

#
class DenyPunishType(discord.ui.View):
    def __init__(self, author):
        super().__init__(timeout=60)
        self.author = author

    options = [
        discord.SelectOption(label="Ban", description="Ban the user with your denial reason.", emoji='🔨'),
        discord.SelectOption(label="Kick", description="Kick the user with your denial reason.", emoji="🤜"),
        discord.SelectOption(label="Message", description="Send the user a Direct Message with your denial reason.", emoji="💬")
    ]
    @discord.ui.select(placeholder="Select punishment type.", options=options ,min_values=1, max_values=1, custom_id="denyPunishTypeSelect")
    async def queue_deny_punishtype_select(self, interaction: discord.Interaction, select: discord.ui.Select):
        if self.author != interaction.user.id:
            await interaction.response.send_message(content="w⚠️ERROR: You cannot use this menu, it is active under another gatekeeper!", ephemeral=True)

        queueChannelVar = interaction.guild.get_channel(queueChannel)
        dict = await interaction.client.database.verification.find_one({"_id": interaction.message.id})
        msg = dict['_id']
        msg = await queueChannelVar.fetch_message(msg)
        member = await interaction.guild.get_member(dict['user'])

        if self.values[0] == "Ban":
            await interaction.response.send_modal(DenyPunishBan(msg=msg))
        elif self.values[0] == "Kick":
            await interaction.response.send_modal(DenyPunishKick(msg=msg))
        else:
            await interaction.response.send_modal(DenyPunishMessage(msg=msg))

    #@on timeout```
vale wing
#

The object you parse as modal argument of send_modal must inherit from discord.ui.Modal

#

Your class inherits from View

indigo pilot
#

wdym

vale wing
#

What are you trying to achieve with that code

indigo pilot
#

Button: Deny

On click, edit message to view=DenyPunishType

#

Then depending on the option selected in DenyPunishType, open a modal

vale wing
#

I don't completely know how modals should be implemented in dpy but definitely not like this

#

You gotta inherit your custom modal class from discord.ui.Modal class

indigo pilot
#

To send it?

vale wing
#

Tbh this looks more convenient than disnake's implementation

sick birch
#

There were like NO resources AT ALL

#

Figuring out how it worked with the horrible docs was a hell of a time

slate swan
#

i want to do a reaction role

#

how do i continue

vale wing
slate swan
#

`class Verify(discord.ui.View):
def init(self):
super().init()
self.value = None

@discord.ui.button(label="Verify Yourself", style=discord.ButtonStyle.green, emoji="![NC_BlueV](https://cdn.discordapp.com/emojis/1025513526065909880.webp?size=128 "NC_BlueV")")
async def verify(self, interaction: discord.Interaction, button: discord.ui.Button):`
vale wing
#

The implementation of that thing or the example

indigo pilot
#

This is the first time I’m using a view class then @ select

vale wing
#

It's purely your class issue

indigo pilot
#

Instead of a view then adding it frkm the view

#

So its a issue with that select menu view shit

slate swan
#

how do i make it a reaction riole

indigo pilot
#

I don’t know how tho as it sends the view fine

vale wing
#

If you want to send a modal, you use send_modal, if you want to send a view, you use send_message(view=your_view)

indigo pilot
#

await interaction.user.add_roles()

indigo pilot
vale wing
#

What you are doing is sending instance of discord.ui.View via send_modal

indigo pilot
#

A forum to be exact

vale wing
#

And what is the code of DenyPunishKick?

indigo pilot
#

It’s the same code tho as all my other working models

#

Other then passing msg arg in

#

I hate this slowmode

vale wing
hasty bison
#
async def test(ctx: commands.Context, text: [str] = None) -> None:
    if ctx.channel.id == 1025516828774105211:
        embed = discord.Embed(title="**FiveM**", description="**__connect __** ",
                              colour=0x053305).set_thumbnail(url='')
        await ctx.send(embed=embed)
    else:
        await ctx.send(ctx.message.author.mention+' **Commands can only be send in **#commandstest')```
#

i dont know why but i have no output

drifting arrow
#

I'm using discordpy, how do I add an emoji to a button?

indigo pilot
drifting arrow
#

oh

#

it's a separate thing lol

#

@discord.ui.button(label=":X:", style=discord.ButtonStyle.red) i was doing this xD

indigo pilot
#

Label is the name

#

Hover it

#

It gives u all the args

#

:p

drifting arrow
#

;D

drifting arrow
# indigo pilot :p

@discord.ui.button(label="Yes", style=discord.ButtonStyle.green, emoji=":ballot_box_with_check:") ;-;

#

doesnt work for some reason

drifting arrow
drifting arrow
#

And do you have the decorator?
@commands.command()?

drifting arrow
sick birch
dull terrace
#

anyone here attempted getting google adsense on their website to do rewarded inventory ads for your bots?

indigo pilot
#

Whats the best way to do this https://freemoneyhub.pizza/C39qqKcB

        reason = self.reason.value


        embed = discord.Embed(title=f"{messages['verification']['denialDMPunishmentTypeMessage']['title']}", description=f"{messages['verification']['denialDMPunishmentTypeMessage']['description']}", colour=Colour.from_str(mainColor))

thought since its a f string just using {} in my config as vars it would convert to fstring but it dosnt

dull terrace
sick birch
indigo pilot
#

as i want to use a bunch of diff things, guild name, user id, user mention, etc

night crater
#

Having a page just with a random video ad with nothing else will probably have a bad time trying to get reviewed

dull terrace
#

Yeah that's where I'm struggling, read through policies and it's technically fine under rewarded inventory section

#

But the review process idk

#

Hmm top.gg kinda gets away with putting a video and before users pressing an upvote button though right

night crater
night crater
#

which prevents against some unsafe execution

indigo pilot
#

.format(guildName = interaction.guild.name, userMention = member.mention, memberCount = interaction.guild.member_count, userName = member.name

I typed out my vars, i cba to do the rest

#

instead of listing them out for every embed

#

what can i store them in so i can just do .format(var)

night crater
#

otherwise people can potentially do a bunch of additional code execution which is bad

#

and that way, you don't need to actually type them all out. Just pass a dict

indigo pilot
#
.format(dict)```
#

that wont work

#

unless you mean something else

night crater
#
# A Simple Python template example
from string import Template
 
# Create a template that has placeholder for value of x
t = Template('x is $x')
 
# Substitute value of x in above template
print (t.safe_substitute({'x' : 1}))
indigo pilot
#

ah

#

idk how that would work for embeds

#

im just gonna stick to format since i got it typed out, nothing really can go wron

night crater
#

minus the ability for users to just happily inject additional things in 😅

indigo pilot
#

its not public its a config

#

this is for a commission, private bot

night crater
#

ah, in that case it's fine

#

I thought it was a thing that any owner could set

indigo pilot
indigo pilot
night crater
#

**dict

#

will make it so it passes them as .format(foo=123, bar=234) if my dict is {"foo": 123, "bar": 234}

indigo pilot
#

ohh

#

thought it would of passed it in as "" stull

#

ty

night crater
#

missing a } at the end it seems

indigo pilot
#

there is one

night crater
#

you have

foo = {"key": "value", x = 21234} which you cant do

indigo pilot
#

its jsust below

indigo pilot
#

its just erroing that section, let me finish tho fixing it

night crater
#

it definitely is

#

it's erroring like that because it thinks that should be the end as the next part gets parsed diffrently

#

if you look it's highlighting both lines

plucky forge
#

i try to install discord components and i don't know why it send this error.

indigo pilot
#
[2022-09-30 19:40:23] [ERROR   ] discord.ui.modal: Ignoring exception in modal <DenyPunishMessage timeout=None children=1>:
Traceback (most recent call last):
  File "C:\Users\kaelm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 186, in _scheduled_task
    await self.on_submit(interaction)
  File "C:\Users\kaelm\PycharmProjects\1019664108519432267\cogs\gatekeeper\core.py", line 192, in on_submit
    embed = discord.Embed(title=messages['verification']['denialDMPunishmentTypeMessage']['title'].format(messagePlaceholders), description=messages['verification']['denialDMPunishmentTypeMessage']['description'].format(messagePlaceholders), colour=Colour.from_str(mainColor))
KeyError: 'guildName'
wispy spade
plucky forge
#

it explanes that before i can execute this command and now not

sick birch
#

Ask here. You'd have a higher chance of getting help & better for other people with the same question or similar

rare jewel
#

hey guys so im trying to make my bot send a message whenever it joins a new server but its not working and idk why. im also trying to make it send to the system channel of the guild but its giving me this error

@component.with_listener(hikari.GuildJoinEvent)
async def on_guild_join(event: hikari.GuildJoinEvent):
    guild = event.get_guild()
    member = event.guild.get_my_member()

    for _, ch in guild.get_channel(guild.system_channel_id):
        if toolbox.calculate_permissions(member, ch) & hikari.Permissions.SEND_MESSAGES:
            await event.app.rest.create_message(
                ch,
                embed=hikari.Embed(
                    title="Beep Boop!",
                    description="""Thank you for inviting me! Type `/` to see what I can do!
                    
All configuration is done through `/settings`. If you need any help or support, feel free to contact the [**developer**](https://discord.com/users/690631795473121280).""",
                    color=0x3E77EE,
                ).set_thumbnail(member.avatar_url or member.default_avatar_url),
            )
        break

its in hikari-tanjun and i looked at the docs for it but it doesn't make much sense to me https://www.hikari-py.dev/hikari/guilds.html#hikari.guilds.GatewayGuild.system_channel_id

slate swan
#

why do i keep getting this?

shrewd apex
#

in dpy its discord.ext.commands.Bot

slate swan
meager chasm
# slate swan pycord

If ur just starting with bot i would recommend using dpy or hikari or something instead of pycord

#

Otherwise make sure u uninstall dpy (pip uninstall discord.py) and then install pycord

#

Also uninstall any other discord api libs

primal token
#

!dashmpip

unkempt canyonBOT
#
Install packages with `python -m pip`

When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.

Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.

Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.

feral lichen
meager chasm
meager chasm
#

My future unborn child can write better code

primal token
meager chasm
primal token
#

Time spent doing the command shouldnt be an issue or a point in this discussion

meager chasm
#

Why not

#

It is more convenient

primal token
#

By not wasting less than a second? What do you want to do with less of a second?

meager chasm
#

Time is money

wary shadow
#

Are you making money arguing over this trivial thing?

primal token
#

I'm broke

meager chasm
wary shadow
meager chasm
#

But if you have only 1 python interpreter

#

What are da benefits of invoking with python command

wary shadow
#

Good habit and best practice.

meager chasm
#

Dat is fair

primal token
#

Bad habits are hard to stop/break and perfect practice makes perfect

slate swan
feral lichen
meager chasm
#

Sure but it's code sucks ass

#

But as long as it's working for you 👍

thorny frost
#

i need help

#

this code makes my bot only message people in their dms when they use the code

naive briar
thorny frost
#

and secondly what is that?

naive briar
#

I

naive briar
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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

thorny frost
#

new problem

#

no responding in the first place

naive briar
#

What can it be

thorny frost
#

idk

#

difference between ctx.send and ctx.reply?

#

@naive briar problem fixed

#

had to change the position of code

#

but it still only replies in dms not in channels help!

naive briar
thorny frost
#

from nextcord.ext import commands

bot = commands.Bot(command_prefix = '.')

@bot.command(name="hi")
async def SendMessage(ctx):
await ctx.reply('Hello!')

@bot.event
async def on_ready():
print(f'\n\n{bot.user.name} - {bot.user.id} is on air')
if name == 'main':
bot.run("hidden")

thorny frost
#

@naive briar help pls

#

someone pls help me

#

bot = commands.Bot(command_prefix = '.')

@bot.command(name="hi")
async def SendMessage(ctx):
    await ctx.reply('Hello!')

@bot.event
async def on_ready():
    print(f'\n\n{bot.user.name} - {bot.user.id} is on air')
if __name__ == '__main__':
    bot.run("hidden")```
#

this code makes the bot only reply to commands in dms

naive briar
#

Idk about nextcord

thorny frost
naive briar
#

Why is that?

thorny frost
#

idk

#

gave me a error that the module is not downloded or doesnt exist

#

idk because is shifted from replit to visual studio community

naive briar
glass stag
#

^^^

thorny frost
slate swan
#

how would i make the bot turn on?

vivid gate
#

so i have a question
im writing a bartender discord bot
when i say c!menu the bot gives me the menu
and for example when i say c!water the bot gives me a pic of water
but i want to make the bot delete menu after i said c!water
is it possible ?

slate swan
honest shoal
honest shoal
slate swan
lament mesa
honest shoal
#

I was sarcastic, didn't expect ppl would take it seriously

slate swan
#

that wasn't funny

lament mesa
#

yeah.

slate swan
#

ew

#

why creating an embed every time

honest shoal
#

💀

vivid gate
#

what wrong ?

slate swan
#

everything

vivid gate
#

ok nevermind

#

it seems like im not coding again ever ...

slate swan
#
@bot.event
async def on_ready():
    Channel = bot.get_channel(664843752342552577)
    Text= "**__שלום לכל משתמשי השרת__** \n בכדי לאמת את עצמכם יש ללחוץ על הריאקשן למטה:) תהנו!"
    Moji = await Channel.send(Text)
    await Moji.add_reaction('![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")')
@bot.event
async def on_reaction_add(reaction, user):
    Channel = bot.get_channel(664843752342552577)
    if reaction.message.channel.id != Channel.id:
        return
    if reaction.emoji == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")":
      Role = discord.utils.get(user.server.roles, id="1009471176264917012")
      await user.add_roles(Role) ```
honest shoal
slate swan
#

it is sending the message w a reaction but its not giving me the role

slate swan
slate swan
#

Ohh

#

ill try

slate swan
#

above the discord.utils.get line

#

smh

#

i dont rlly understand

#
if str(reaction.emoji) == "<a:7VBlue>:":
  ...```
shrewd apex
#

ashley so smort pBlush

slate swan
slate swan
#

what do you understand

slate swan
shrewd apex
#

no no i am in library bit busy

#

u continue 🗿

slate swan
#

@bot.event async def on_ready(): Channel = bot.get_channel(664843752342552577) Text= "**__שלום לכל משתמשי השרת__** \n בכדי לאמת את עצמכם יש ללחוץ על הריאקשן למטה:) תהנו!" Moji = await Channel.send(Text) await Moji.add_reaction('![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")') @bot.event async def on_reaction_add(reaction, user): if str(reaction.emoji) == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")": Channel = bot.get_channel(664843752342552577) if reaction.message.channel.id != Channel.id: return if reaction.emoji == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")": Role = discord.utils.get(user.server.roles, id="1009471176264917012") await user.add_roles(Role)

#

its not working

#

OH WAIT

#

I UNDERSTOOD I THINK LET ME TRY

#

Traceback (most recent call last):
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 299, in on_reaction_add
Role = discord.utils.get(user.server.roles, name="Member")
AttributeError: 'Member' object has no attribute 'server'
2022-10-01 10:07:31 ERROR discord.client Ignoring exception in on_reaction_add
Traceback (most recent call last):
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 299, in on_reaction_add
Role = discord.utils.get(user.server.roles, name="Member")
AttributeError: 'Member' object has no attribute 'server'

shrewd apex
#

what do u think is the answer

shrewd apex
slate swan
shrewd apex
#

hold the phone upside down 😉

slate swan
#

@bot.event async def on_ready(): Channel = bot.get_channel(664843752342552577) Text= "**__שלום לכל משתמשי השרת__** \n בכדי לאמת את עצמכם יש ללחוץ על הריאקשן למטה:) תהנו!" Moji = await Channel.send(Text) await Moji.add_reaction('![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")') @bot.event async def on_reaction_add(reaction, user): Channel = bot.get_channel(664843752342552577) if reaction.message.channel.id != Channel.id: return if str(reaction.emoji) == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")": Role = discord.utils.get(user.server.roles, name="Member") await user.add_roles(Role)

slate swan
#
@commands.Cog.listener()
    async def on_member_join(self,member):
        print("A Member has just joined: {}".format(member))
        print(servername)
        print(guildid)
        print(channel)
        print("Member is in the correct server")
        channel = channel
        print("Channel is: {}".format(channel))
        embed = discord.Embed()
        print("Embed Created")``` this function is not printing more than 3 things (even the member is in the correct server message is not getting printed)
slate swan
slate swan
slate swan
shrewd apex
#

rip

slate swan
#

they're defined

#

i've defined them out of the function

#

@slate swan working! but now every time i run it its sending do you know how to do that only if i do like !verifymsg it will send?

shrewd apex
#

here u go ma'am

slate swan
slate swan
slate swan
# slate swan just move whatever you have related to it inside on_ready to a command

@bot.event async def verify(): Channel = bot.get_channel(664843752342552577) Text= "**__שלום לכל משתמשי השרת__** \n בכדי לאמת את עצמכם יש ללחוץ על הריאקשן למטה:) תהנו!" Moji = await Channel.send(Text) await Moji.add_reaction('![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")') @bot.event async def on_reaction_add(reaction, user): Channel = bot.get_channel(664843752342552577) if reaction.message.channel.id != Channel.id: return if str(reaction.emoji) == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")": Role = discord.utils.get(user.guild.roles, name="Member") await user.add_roles(Role)

slate swan
#

Traceback (most recent call last):
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 181, in on_command_error
raise error
discord.ext.commands.errors.CommandNotFound: Command "verify" is not found

shrewd apex
#

half correct

slate swan
#

oh okay

slate swan
shrewd apex
#

mutable items in a tuple is still mutable in this it will raise an error and add the values as well

slate swan
#

the other half is?

#

PS C:\Users\PC\Desktop\Gal Cohen Bot> py main.py
Traceback (most recent call last):
File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 288, in <module>
async def verify():
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 1475, in decorator
result = command(name=name, cls=cls, *args, **kwargs)(func)
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 1748, in decorator
return cls(func, name=name, **attrs)
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 361, in init
self.callback = func
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 470, in callback
self.params: Dict[str, Parameter] = get_signature_parameters(function, globalns)
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 128, in get_signature_parameters
raise TypeError(f'Command signature requires at least {required_params - 1} parameter(s)')
TypeError: Command signature requires at least 0 parameter(s

shrewd apex
slate swan
#

just checked

shrewd apex
#

yep

slate swan
#
Traceback (most recent call last):
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 288, in <module>
    async def verify():
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 1475, in decorator
    result = command(name=name, cls=cls, *args, **kwargs)(func)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 1748, in decorator
    return cls(func, name=name, **attrs)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 361, in __init__
    self.callback = func
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 470, in callback
    self.params: Dict[str, Parameter] = get_signature_parameters(function, globalns)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 128, in get_signature_parameters
    raise TypeError(f'Command signature requires at least {required_params - 1} parameter(s)')
TypeError: Command signature requires at least 0 parameter(s```
#

when i try to run the bot

#

@bot.command()
async def verify():
    Channel = bot.get_channel(664843752342552577)
    Text= "**__שלום לכל משתמשי השרת__** \n בכדי לאמת את עצמכם יש ללחוץ על הריאקשן למטה:) תהנו!"
    Moji = await Channel.send(Text)
    await Moji.add_reaction('![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")')
@bot.event
async def on_reaction_add(reaction, user):
    Channel = bot.get_channel(664843752342552577)
    if reaction.message.channel.id != Channel.id:
        return
    if str(reaction.emoji) == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")":
      Role = discord.utils.get(user.guild.roles, name="Member")
      await user.add_roles(Role)

#

wait

#

tried to add ctx lets check

#

yep ctx was the prob its working tyswmmmm!

#

now ill try sending this but an embed

vale wing
#

Naming conventions go brr

vale wing
slate swan
# vale wing Instead of comparing str representation of emoji, do this ```py if isinstance(re...
@bot.command()
async def verify(ctx):
    Channel = bot.get_channel(664843752342552577)
    Text= "![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree") Gal Cohen Verify ![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree") \n\n __**שלום לכל משתמשי השרת**__ \n __**כדי להיות ממברים רשמיים בשרת יש ללחוץ על הריאקשן למטה - ![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")**__"
    Moji = await Channel.send(Text)
    await Moji.add_reaction('![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")')
@bot.event
async def on_reaction_add(reaction, user):
    Channel = bot.get_channel(664843752342552577)
    if reaction.message.channel.id != Channel.id:
        return
    if str(reaction.emoji) == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")":
      Role = discord.utils.get(user.guild.roles, name="Member")
      await user.add_roles(Role)```
#

can someone help me with making this to an embed

naive briar
#

Can you be more specific?

slate swan
#

Its sending as a message

naive briar
slate swan
#

And i want it to send as an embed

naive briar
#

!d discord.Embed - Just set it as the description of an embed, and send it using embed kwarg

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...
shrewd apex
#

edit the view

#

view has a clear option use that and add new items

slate swan
# naive briar !d discord.Embed - Just set it as the description of an embed, and send it using...

@bot.command() async def verify(ctx): Channel = bot.get_channel(664843752342552577) em = discord.Embed(title="![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree") Gal Cohen Verify ![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree")", type='rich', description=" __**שלום לכל משתמשי השרת**__ \n __**כדי להיות ממברים רשמיים בשרת יש ללחוץ על הריאקשן למטה - ![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")**__", timestamp=None) Moji = await Channel.send(em) await Moji.add_reaction('![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")') @bot.event async def on_reaction_add(reaction, user): Channel = bot.get_channel(664843752342552577) if reaction.message.channel.id != Channel.id: return if str(reaction.emoji) == "![7VBlue](https://cdn.discordapp.com/emojis/1009470901982609511.webp?size=128 "7VBlue")": Role = discord.utils.get(user.guild.roles, name="Member") await user.add_roles(Role)

naive briar
unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
slate swan
#

i dont understand

#

class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)

@bot.command()
async def verify(ctx):
Channel = bot.get_channel(664843752342552577)
em = discord.Embed(title="palmtree Gal Cohen Verify palmtree", type='rich', description=" שלום לכל משתמשי השרת \n כדי להיות ממברים רשמיים בשרת יש ללחוץ על הריאקשן למטה - 7VBlue", timestamp=None)
Moji = await Channel.send(em)
await Moji.add_reaction('7VBlue')
@bot.event
async def on_reaction_add(reaction, user):
Channel = bot.get_channel(664843752342552577)
if reaction.message.channel.id != Channel.id:
return
if str(reaction.emoji) == "7VBlue":
Role = discord.utils.get(user.guild.roles, name="Member")
await user.add_roles(Role)

naive briar
#

So uh

#

This is arg

await ctx.send(em)

This is kwarg or keyword arg

await ctx.send(embed=em)
slate swan
#

oh

naive briar
#

So, send the embed using the kwarg

slate swan
#

ill try

#

WORK

#

WORKS

#

TYSMM

untold iron
#

Hey there i have a piece of code that creates a private hidden channel and invites the author in it only and prevents any other members entering

#

However this code is a simple command to enter a user name, how can i use overwrites to invite the user i write?

#

So its just the author and the user invited in the private hidden channel

#

Not sure what the overwrite command is

#

@client.command()
async def inviteuser(ctx, *, mention=None):
    mentioned_user = mention
    if mention == None:
        await ctx.send(f'{ctx.author.mention}, please mention the user')
    
   
    overwrites = {
        
    }


    await ctx.send(mentioned_user)
robust fulcrum
#
embed = Embed(title=inter.user,description=f"{self.emo.get("healing potion")}**healing potion**: {counter_items[0]}")

Guys why i am getting invalid syntax in it?

slate swan
#

you can't use double quotes inside that f string

robust fulcrum
#

Oh 😳 sorry

untold iron
#

Is it possible to overwrite a specific user into a channel?

#

overwrites{
ctx.(add user):discord.permissionOverwrite(read_messages=True)

naive briar
untold iron
#

yes but

#

How do i overwrite the permission for a specific user not the author of the command

#

I want to invite a user that i write the tag of

#

Not sure how though

slate swan
#
@bot.command()
async def verify(ctx):
    Channel = bot.get_channel(664843752342552577)
    em = discord.Embed(title="![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree") Gal Cohen Verify ![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree")", type='rich', description=" __**שלום לכל משתמשי השרת**__ \n __**כדי להיות ממברים רשמיים בשרת יש ללחוץ על הריאקשן למטה - ![galcohen](https://cdn.discordapp.com/emojis/513115174044172309.webp?size=128 "galcohen")**__", color=0x9497d8 ,timestamp=None)
    em.set_footer(text="Gal Cohen System", icon_url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
    em.set_thumbnail(url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
    Moji = await ctx.send(embed=em)
    await Moji.add_reaction('![galcohen](https://cdn.discordapp.com/emojis/513115174044172309.webp?size=128 "galcohen")')
@bot.event
async def on_reaction_add(reaction, user):
    Channel = bot.get_channel(664843752342552577)
    if reaction.message.channel.id != Channel.id:
        return
    if str(reaction.emoji) == "![galcohen](https://cdn.discordapp.com/emojis/513115174044172309.webp?size=128 "galcohen")":
      Role = discord.utils.get(user.guild.roles, name="Member")
      await user.add_roles(Role)```
can someone help me with changing the reaction into a button
vale wing
#

@slate swan just asking what is your python knowledge level

slate swan
#

i know a like a little but i do know how to make a button

#

just dont know how to make it adding a role when u tap on it

vale wing
#

Cause buttons involve classes creation and people who don't know OOP get scared just of class keyword

slate swan
#

i know classes

vale wing
#

Well if you know OOP your knowledge is intermediate, not little lol

naive briar
vale wing
slate swan
#

thankss

untold iron
untold iron
#

Im a little confused because ctx.author: discord.PermissionOverwrite(view_channel=True),

#

This is to invite the user that initates the command no?

#

Gives them permission to read the channel

#

But how can i make it so e.g.
!inviteuser (userhere) - userhere is the one invited to the channel (userhere being a user that by default is blocked from reading messges

vale wing
#

read_messages=True*

untold iron
#

This is my code to create teh actual channel

#

But now i want the person who created the channel to be able to invite another user

vale wing
untold iron
untold iron
#

Thank you so much, it also worked via username and tag

#

I appreciate it alot it was a problem that bugged me, so i know that i needed to bring in the discord member into the function

serene lynx
#

is this a bug? I've used 'none' in the parameters, but why does raised appear?

#
@commands.command()
    async def purge(self, ctx, limit: int, filter: Union[discord.Member, str] = None):
        if filter:```
#
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: filter is a required argument that is missing.```
brazen raft
#

Try wrapping Union[discord.Member, str] with Optional[...]

#

It's from the same module by the way

slate swan
#

but can an argument be typehinted with a Member and str Union though?

brazen raft
#

If it fails to convert the argument into a member, ye

#

str is "as is"

#

If you wanted filter to be the author of the command if not supplied, you can do

filter: discord.Member = commands.Author
serene lynx
serene lynx
#

Excuse me, I want to ask, what is meant by delete message days?

vocal snow
slate swan
#
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 301, in verify
    Moji = await ctx.send(embed=em, view=verify)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\context.py", line 841, in send
    return await super().send(
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\abc.py", line 1511, in send
    raise TypeError(f'view parameter must be View not {view.__class__!r}')
TypeError: view parameter must be View not <class 'discord.ext.commands.core.Command'>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 183, in on_command_error
    raise error
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: view parameter must be View not <class 'discord.ext.commands.core.Command'>
#
class VerifySystem(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

@bot.command()
async def verify(ctx):
    Channel = bot.get_channel(664843752342552577)
    em = discord.Embed(title="![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree") Gal Cohen Verify ![palmtree](https://cdn.discordapp.com/emojis/1010539024206803027.webp?size=128 "palmtree")", type='rich', description=" __**שלום לכל משתמשי השרת**__ \n __**כדי להיות ממברים רשמיים בשרת יש ללחוץ על הריאקשן למטה - ![galcohen](https://cdn.discordapp.com/emojis/513115174044172309.webp?size=128 "galcohen")**__", color=0x9497d8 ,timestamp=None)
    em.set_footer(text="Gal Cohen System", icon_url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
    em.set_thumbnail(url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
    Moji = await ctx.send(embed=em, view=verify)
    await Moji.add_reaction('![galcohen](https://cdn.discordapp.com/emojis/513115174044172309.webp?size=128 "galcohen")')
    @discord.ui.button(label="Verify", style=discord.ButtonStyle.green, custom_id="verify_system:green")
    async def verify_system(reaction, user):
        Role = discord.utils.get("Member")
        await Interaction.response.send_message(content="You Have Been Verified!")
        await user.add_roles(Role)```
mental hollow
#

Everything I use this and run my server, it just goes offline (with no error).. anyone know why?

async def main():
    async with Bot() as bot:
        await bot.start(os.getenv('TOKEN'), reconnect = True)
pulsar solstice
#

I am making a command to ban certain words from a server

#
@bot.command(aliases = ["banword"])
async def wordbanner(ctx, word):
    handle = await aiofiles.open(f'{ctx.guild.id}.txt', mode='x')
    if word not in handle:
        async with aiofiles.open(f'{ctx.guild.id}.txt', mode='w') as handle:
            await handle.write(word)
            await ctx.reply(f"||{word}|| has been banned.", delete_after = 5)
            await ctx.delete()
            handle.close
    else:
        await ctx.reply("That word is already banned from this server.", delete_after=5)
        await ctx.delete()
#

I am storing the words in a txt file using aiofiles.

#

I am getting this error:

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'AsyncTextIOWrapper' is not iterable    ```
naive briar
#

Can you send the whole error message

pulsar solstice
#
2022-10-01 03:44:45 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 52a73692ac329a8938e274645a420d7b).
I am Online
2022-10-01 03:45:07 ERROR    discord.ext.commands.bot Ignoring exception in command profanitywordadd
Traceback (most recent call last):
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Public Bot\main.py", line 226, in profanitywordadd
    if word not in handle:
TypeError: argument of type 'AsyncTextIOWrapper' is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'AsyncTextIOWrapper' is not iterable```
#

here it is

slate swan
#

you need to read the file and then use in on the returned str

pulsar solstice
#

it's data = await handle.read() right?

slate swan
#

i think yes

pulsar solstice
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileExistsError: [Errno 17] File exists: '990868386584076388.txt' ```
pulsar solstice
naive briar
#

You're using x mode, so yeah, probably every time you run the command and the file already exists

pulsar solstice
slate swan
#

theres was some function in os module for that

naive briar
slate swan
#

!d os.path.exists

unkempt canyonBOT
#

os.path.exists(path)```
Return `True` if *path* refers to an existing path or an open file descriptor. Returns `False` for broken symbolic links. On some platforms, this function may return `False` if permission is not granted to execute [`os.stat()`](https://docs.python.org/3/library/os.html#os.stat "os.stat") on the requested file, even if the *path* physically exists.

Changed in version 3.3: *path* can now be an integer: `True` is returned if it is an open file descriptor, `False` otherwise.

Changed in version 3.6: Accepts a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object).
pulsar solstice
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: '990868386584076388.txt'

naive briar
#

Can you show the whole error message

slate swan
#

its not supposed to read if the file doesn't exist at all, use the wr+ combination mb

naive briar
#

Oh yeah, that too 🥴

pulsar solstice
# naive briar Can you show the whole error message
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Public Bot\main.py", line 225, in wordbanner
    handle = await aiofiles.open(f'{ctx.guild.id}.txt', mode='r+')
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\aiofiles\base.py", line 70, in __await__
    resp = yield from self._coro
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\aiofiles\threadpool\__init__.py", line 80, in _open
    f = yield from loop.run_in_executor(executor, cb)
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
FileNotFoundError: [Errno 2] No such file or directory: '990868386584076388.txt'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: '990868386584076388.txt'```
pulsar solstice
slate swan
#

hm?

#
@commands.Cog.listener()
    async def on_message(self, message):
        if message.author.id == commands.user.id:

            return

        msg_content = message.content.lower()
        zabronioneslowa = ['https', 'http', 'www', 'discord.gg', 'd.gg']
        curseWord = zabronioneslowa

        if any(word in msg_content for word in curseWord):
            await message.delete()
            embed = disnake.Embed(title="OSTRZEŻENIE!", description="Nie możesz reklamować się na serwerze!", colour = 0x2f3136)
            embed.set_footer(text="© SetCode.PL", icon_url="https://cdn.discordapp.com/attachments/1011358034196430898/1011595743292825771/logosetcode.png")
            await message.author.send(embed = embed)```
#

how i can fix it?

vocal snow
#

What is that even supposed to check

maiden apex
#

hey, do someone have a little part of code that can print every channel my bot have access to ?

vocal snow
maiden apex
#

on like a single server

vocal snow
#

Then bot.get_guild to get the target guild and then for loop over guild.text_channels

slate swan
vocal snow
#

That's not what I'm asking about

maiden apex
#

i have this but i still get this error

gilded gust
#

Hey, I'm making a py-cord bot using discord.ext.bridge.Bot. When I create a bridge command on this bot, it is unable to process prefixed commands, but the slash commands work just fine. How do I make it such that it recognizes the prefixed commands too?

slate swan
#

do you have an on_message event?

gilded gust
#

All intents are enabled (in the code and in developer portal)

slate swan
#

i want my bot to add people to a ticket just with there id or username
what docs should i look for to do that?
for e.g the user says a name or id and the bot just adds that user to the ticket

slate swan
gilded gust
#

dm?

slate swan
#

sure

slate swan
unkempt canyonBOT
#

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

The method to override to do conversion logic.

If an error is found while converting, it is recommended to raise a [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError") derived exception as it will properly propagate to the error handlers.
slate swan
#

convert?

#

alr thanks ThumbsUp

#

how do i install humanfriendly

slender hamlet
gilded gust
slate swan
gilded gust
#

then its already installed

slate swan
gilded gust
#

vscode stupid

#

lmfao

slate swan
#

lol how can i fix it

#

ill try uninstalling it and installing again

slender hamlet
#

what error do you even get?

slate swan
maiden apex
#
@client.event
async def on_message(message):
    username = str(message.author).split('#')[0]
    message_content = str(message.content)
    channel = str(message.channel.name)
    print(f'{username}: {message_content} ({channel})')

so, i have this part of code wich have to print the the username, the content of the message and the channel whenever a message is getting send but i don't know why, the content of the message isn't printed, i only get the username and the channel name

#

can someone help me to fix this

shrewd apex
slate swan
#

oh

maiden apex
# maiden apex

the message content should be between the username and the channel name

slate swan
#

then what do i do?

shrewd apex
#

find out which u installing to

#

u can do py --version

#

then py -m pip install humanfriendly

slate swan
#

WORKED

shrewd apex
#

👍

slate swan
pulsar solstice
naive briar
#

You want to invoke a command by button click?

slate swan
#
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 316, in mute
    await member.edit(timeout=discord.utils.utcnow()+datetime.timedelta(seconds=time))
TypeError: Member.edit() got an unexpected keyword argument 'timeout'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 183, in on_command_error
    raise error
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Member.edit() got an unexpected keyword argument 'timeout'```
#

anyone know the way i can make my code print the user and the very small pic next to it like this pic below

#
@bot.command()
async def mute(ctx, member:discord.Member, time, *, reason):
  time = humanfriendly.parse_timespan(time)
  await member.edit(timeout=discord.utils.utcnow()+datetime.timedelta(seconds=time))
  await ctx.send(f"{member.mention} Has Been Mute For {reason}")

@bot.command()
async def umute(ctx, member:discord.Member, *, reason):
  await member.edit(timeout=None)
  await ctx.send(f"{member.mention} Has Been Unmuted For {reason}")```
slate swan
slate swan
naive briar
unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

ty

#
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 316, in mute
    await member.edit(timeout=discord.utils.utcnow()+datetime.timedelta(seconds=time))
TypeError: Member.edit() got an unexpected keyword argument 'timeout'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 183, in on_command_error
    raise error
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Member.edit() got an unexpected keyword argument 'timeout'``` the error


```py
@bot.command()
async def mute(ctx, member:discord.Member, time, *, reason):
  time = humanfriendly.parse_timespan(time)
  await member.edit(timeout=discord.utils.utcnow()+datetime.timedelta(seconds=time))
  await ctx.send(f"{member.mention} Has Been Mute For {reason}")

@bot.command()
async def umute(ctx, member:discord.Member, *, reason):
  await member.edit(timeout=None)
  await ctx.send(f"{member.mention} Has Been Unmuted For {reason}")```
the code
naive briar
#

!d discord.app_commands.Command.callback - I think you could call its callback function

unkempt canyonBOT
unkempt canyonBOT
#

await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") to do this.

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
slate swan
#

Oh

slate swan
#

i dont understand where do i put it

naive briar
slate swan
naive briar
#

You should at least have a bit of OOP knowledge before using dpy

slate swan
#

i do i just dont understand this'

meager chasm
slate swan
#

ig??

#

🍊 s over 🥔 es

meager chasm
naive briar
#

I mean, you can get the command's callback function using .callback and then call it, like:

async def some_button_callback(self, interaction):
    slash_command_callback = some_slash_command.callback # get the callback

    await slash_command_callback(interaction) # call the callback

I don't know if that's a recommended thing to do

slate swan
meager chasm
#

OH

slate swan
#

oranges over potatoes

meager chasm
#

i just realised 😆

whole hull
#

wheres the problem ?

slate swan
#

flatten no longer exists

whole hull
#

what do i put instead then

#

?

slate swan
#
# before
users = await reaction.users().flatten()

# after
users = [user async for user in reaction.users()]
``` similar to this
#

does anyone know anything about image resizing

#

use pillow

#

me?

#

!d PIL.Image.Image.resize

unkempt canyonBOT
#

Image.resize(size, resample=None, box=None, reducing_gap=None)```
Returns a resized copy of this image.
slate swan
slate swan
maiden apex
#

hey, do anyone know how can i make message.content working ?

#

i heard that it's beacuse "discord intents" are not enabled but i don't even know what it is and i don't know how to enable

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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

whole hull
#

working :D @slate swan

slate swan
#

gg

#
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 316, in mute
    await member.edit(timeout=discord.utils.utcnow()+datetime.timedelta(seconds=time))
TypeError: Member.edit() got an unexpected keyword argument 'timeout'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 183, in on_command_error
    raise error
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Member.edit() got an unexpected keyword argument 'timeout'``` the error


```py
@bot.command()
async def mute(ctx, member:discord.Member, time, *, reason):
  time = humanfriendly.parse_timespan(time)
  await member.edit(timeout=discord.utils.utcnow()+datetime.timedelta(seconds=time))
  await ctx.send(f"{member.mention} Has Been Mute For {reason}")

@bot.command()
async def umute(ctx, member:discord.Member, *, reason):
  await member.edit(timeout=None)
  await ctx.send(f"{member.mention} Has Been Unmuted For {reason}")```
the code
#

hi

maiden apex
# naive briar !intents

hmm i still get a error

Traceback (most recent call last):
  File "C:\Users\arsbu\Documents\CODE\PKbot\getoswebhook.py", line 20, in <module>
    client.run('token')
  File "C:\Users\arsbu\Documents\CODE\DiscordXP\venv\lib\site-packages\discord\client.py", line 723, in run
    return future.result()
  File "C:\Users\arsbu\Documents\CODE\DiscordXP\venv\lib\site-packages\discord\client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\arsbu\Documents\CODE\DiscordXP\venv\lib\site-packages\discord\client.py", line 666, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\arsbu\Documents\CODE\DiscordXP\venv\lib\site-packages\discord\client.py", line 601, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001A7360B0310>
Traceback (most recent call last):
  File "C:\Users\arsbu\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\arsbu\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\arsbu\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
    self._check_closed()
  File "C:\Users\arsbu\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
unkempt canyonBOT
#

await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") to do this.

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
slate swan
naive briar
naive briar
slate swan
#

yes ik but where do i put that

naive briar
#

Where you want to timeout the member

slate swan
#

but i already did that

#

await member.edit(timeout=discord.utils.utcnow()+datetime.timedelta(seconds=time))

naive briar
#

What even is that?

slate swan
#

its making the member being timeouted

naive briar
#

!d discord.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., 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
#

oh

#

@bot.command()
async def mute(ctx, member:discord.Member, time, *, reason):
time = humanfriendly.parse_timespan(time)
await member.edit(timed_out_until=discord.utils.utcnow()+datetime.timedelta(seconds=time))
await ctx.send(f"{member.mention} Has Been Mute For {reason}")

#

yes it works

#

tysmm

unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

whole hull
#

"discord.User" is not defined how do i do

#
@bot.command
async def kick(ctx, user : discord.User, *reason):
    reason = " ".join(reason)
    await ctx.guild.kick(user, reason = reason)
    await ctx.send(f"{user} a été kick\nRaison : {reason}")
naive briar
whole hull
#

oh

#

i imported discord

naive briar
whole hull
#

what

#

wtf

#

what do i put instead then

#

to kick

naive briar
# whole hull what

You have to put parentheses after the @bot.command to register the command

@bot.command()
async def kick(...):
    ...
next coral
#

😅 anyway to solve this

#

Idk if im nab

vital echo
#

how can i make something like this?

naive briar
unkempt canyonBOT
#

Hey @vital echo!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

vital echo
#

Traceback (most recent call last):
File "c:\Users\TOKO-TEKLA\Downloads\Desktop\Gervase.py\main.py", line 565, in <module>
from discord import app_commands
ImportError: cannot import name 'app_commands' from 'discord' (C:\Python310\lib\site-packages\discord_init_.py)

#

Error

naive briar
vital echo
#

update what?

whole hull
#

nvm catgal i just wrote @bot.command instead @bot.command**()**

vital echo
naive briar
naive briar