#discord-bots

1 messages · Page 1044 of 1

paper sluice
#

😳

slate swan
#

!d discord.Client.create_guild there's a limitation tho

unkempt canyonBOT
#

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

Creates a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

Bot accounts in more than 10 guilds are not allowed to create guilds...
paper sluice
#

python -m pip install git+https://github.com/rapptz/discord.py make sure u have git installed as well

fading harness
#
pip uninstall discord
pip install git+https://github.com/Rapptz/discord.py

note theres some breaking change

slate swan
#

or just pip install -U git+https://github.com/Rapptz/discord.py

fading harness
slate swan
#

i feel like writing this in hikari now

#

okay thanks

paper sluice
#

what diff about hikari?

slate swan
#

cache things are better + im way more comfortable with it

regal pulsar
#

hmm

short silo
#

so, i needed to know if i put reactions on messages, how many would i be able to track at a time without issues ?

regal pulsar
#

i forgot the controls of gaming 💀

slate swan
short silo
#

not like that

#

i am saying for number of messages

regal pulsar
#

on reaction add and on raw reaction add

slate swan
short silo
#

whats the best way to go about making a translator without the hassle of writing some command each time.

fading harness
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.
regal pulsar
#

or some translating api

short silo
#

back end is complete, but i havent worked with discord

fading harness
#

!docs discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
short silo
slate swan
#

the reaction_add event needs Member intents, it gives you 2 args, message and user, reaction being reaction: discord.Reaction and user being user: discord.User | discord.Member

the raw_reaction_add event gives you a single payload which is payload: discord.RawReactionActionEvent @regal pulsar

fading harness
short silo
regal pulsar
#

you mean a translator command?

#
@bot.slash_command(aliases=[“tl”])
async def translate(inter: discord.Applicationcommandinteraction, *, txt: str):
    txt = await translate_function(txt)
    await inter.response.send_message(txt, ephimeral = True)
short silo
#

no no. wait

regal pulsar
#

translate function is a function that returns the translated text

#

that you need to code in

#

then you just do

#

/translate gracias amigos

#

and it’ll send thanks friends

#

in an ephimeral so only you can see it

short silo
#

i have a few options to work with. I set a default language for the user, they would choose. Then all they write is the command. Give them option to manually change as well. Other thing, I wanted to do reactions for the country flags but i am not sure how man i could track

regal pulsar
#

manually change?

#

well then

short silo
#

no

#

/trentofrench

#

like that or either whatever they have set as default

#

or /trfrench to automatically detect and so convert to french, command being /tr

regal pulsar
#
@bot.slash_command(aliases=[“tl”])
async def translate(inter: discord.Applicationcommandinteraction, *, txt: str):
    lang = read json for users language
    txt = await translate_function(txt, language = lang)
    await inter.response.send_message(txt, ephimeral = True)

@bot.slash_command()
async def setlang(inter: Applicationcommandinteraction, *, lang: str):
    set users language in json/db
nova stag
#

thanks worked

slate swan
#

Hm, a question

regal pulsar
#

np

tired hinge
#

hey guys, can anybody get me started on embed buttons, as in, the buttons that appear below embeds, and how can i call a function when the button is pressed

regal pulsar
#

i havnt worked with buttons but i assume its similar to selec menus

short silo
regal pulsar
#

you create a button instance and set a name/emoji

tired hinge
#

is it discord.Interaction or smth?

regal pulsar
#

then add it to a view

regal pulsar
#

and set the traceback

#

!d discord.ui.Button

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.
regal pulsar
#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
tired hinge
#

ty

regal pulsar
#

np

regal pulsar
short silo
slate swan
#

Select menu in v2.0?

regal pulsar
regal pulsar
regal pulsar
#

but i use disnake

slate swan
regal pulsar
#

hmm

slate swan
#

😔

slate swan
#

how to make tic toe game game

#

Link?

#

tic tac toe*

slate swan
#

k

paper sluice
#

.src ttt 😔

slate swan
#

💀 never knew that disnake allowed attaching disnake.File s to embeds directly

paper sluice
#

sadge

slate swan
#

uh

#

not for discord bot

eternal scarab
#

есть русские

slate swan
slate swan
#

didnt use it in a while, so wasnt aware

#

im using disnake for like after 2 months now~

slate swan
slate swan
slate swan
paper sluice
#

😳 run the code check lmao, don't worry about linting xD

slate swan
#

but

paper sluice
#

actually it doesn't work

slate swan
#

that isn;t tic tac toe

paper sluice
#

anyways

slate swan
river kindle
#

hi guys i am creating a command and in this command when i run it it has to create a room and add the people mentioned, only it adds the user who used the command, how can i fix my code?
code (if there are gaps in the code, the translator does this):

async def real1v1 (ctx, member: discord.Member, arg, product, *, stars):
  embed = discord.Embed (title = f "New realistic 1v1 wager for {arg}", description = f "** Team 1: {product} vs Team 2: {stars} **", color = discord.Color.red ())
  guild = ctx.guild
  member = ctx.author
  member2 = ctx.author.member
  admin_role = get (guild.roles, name = "RoleTestAdmin")
  overwrites = {
        guild.default_role: discord.PermissionOverwrite (read_messages = False),
        member: discord.PermissionOverwrite (read_messages = True),
        member2: discord.PermissionOverwrite (read_messages = True),
        admin_role: discord.PermissionOverwrite (read_messages = True)
    }
  channel = await guild.create_text_channel (f'Team1-Team2 ', overwrites = overwrites)
  #await channel.send (f "{product} {stars}")
  embed.set_footer (text = f "{ctx.guild.name}")
  await ctx.send (embed = embed)```
paper sluice
slate swan
#

like

#

x and o

#

type in the box's number where you want to place you x and o s

#

Selectoption link for d.py?

#

!d discord.SelectOption click on the blue title

unkempt canyonBOT
#

class discord.SelectOption(*, label, value=..., description=None, emoji=None, default=False)```
Represents a select menu’s option.

These can be created by users.

New in version 2.0.
paper sluice
# slate swan x and o

its that, just have the index there for easy access, remove the True from a = TTT(3, True) to play without the random choice

#

anyways, if u want to make like a ttt which might actually be better, cuz that one i sent is not readable in anyway. ask in #game-development

slate swan
#

getting this error

#
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
client = commands.Bot(",")
#

code ^

tired hinge
#

!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/master/api.html#discord.Client "discord.Client") and as a result
anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with
this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality
to manage commands...
slate swan
tired hinge
slate swan
heady sluice
river kindle
tired hinge
#

it's alright hehe

slate swan
tired hinge
slate swan
#

nvm meh's quicker 😔

heady sluice
#

I'm speed

tired hinge
#

i tried to make a command to get a definition from urbandictionary.com, and now i'm trying to make it so that when the user reacts with a right/left arrow, it goes to the previous/next definition, and i ended up screwing the entire command up. if anyone'd like to go through the torture of going through my code, i'd appreciate it - https://paste.pythondiscord.com/xazafocipa

#

the response from the urbandictionary api is an array of objects

#

and yes, i realize that requests is blocking and i'll be replacing it soon

#
reaction, user = await self.bot.wait_for("reaction_add", check=check)
                     ^
SyntaxError: 'await' outside async function
slate swan
#
class view(View):
  def __init__(self):
    super().__init__(timeout=None)

  @button(label = "1", custom_id = '1')
  async def counter(self,button: Button, interaction: Interaction):
    label = str(button.label)
    label += 1

    button.label = str(label)

    await interaction.send(content="123")

@client.command()
async def test(ctx):
  await ctx.send("mf", view = view())

code ^

paper sluice
slate swan
#

2.0?

#

v2.0

paper sluice
#

then its interaction, button

#

not button, interaction

slate swan
#

Ye

slate swan
tired hinge
#

why am i so dumb, ty

slate swan
#

its the same code but i get this on button click

#

Brooo wtf read error

#

To quack*

#

TypeError: Parameters to Generic[...] must all be type variables

#

?

#

Code

#

Jsk

paper sluice
#

huh?

slate swan
#

Nvmd

paper sluice
#

u can't assign using = in function calls

slate swan
#

Ye

#

I was trying to get the same error as shown above

paper sluice
#

not even walrus, its sad

sullen pewter
#

how can I fix the error

slate swan
#

Use f strings

#

!fstring

sullen pewter
#

interaction doesn't have an attribute author

loud junco
#

f' '

slate swan
#

!fstrings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

paper sluice
#

its Interaction.user

sullen pewter
slate swan
#

how can i send interraction reponse for button?

loud junco
#

!eval
Name = 'jh'
print(f'My nane is {Name}')

unkempt canyonBOT
#

@loud junco :white_check_mark: Your eval job has completed with return code 0.

My nane is jh
slate swan
loud junco
#

My nane

sullen pewter
slate swan
#

He litteralt used interaction.user after that

#

They are objects

sullen pewter
#

I need members name and discriminator

slate swan
paper sluice
# sullen pewter

show ur code, u need to use the interaction u took as arg for ur function, not the actual class lmao

slate swan
#

thats the repr of the Interaction.user

sullen pewter
slate swan
slate swan
sullen pewter
#

@paper sluice

slate swan
#

Imagine

sullen pewter
#

being sparky

slate swan
#

Bro they are objects

paper sluice
slate swan
#

change it to interaction.user

#

use name attribute

sullen pewter
#

interaction is not defined

slate swan
#

^ yea that too else it would be like Sparky#3940#Sparky#3940

#

..

slate swan
#

👏

paper sluice
sullen pewter
#

2 messages

tired hinge
sullen pewter
slate swan
#

What

slate swan
#

Why 😩

sullen pewter
slate swan
#

Did u enable the intents

#

small i.

sullen pewter
#

yea I did

#

bruh

slate swan
#

Send code on discord I can't see!!!!

#

how to make object on visual studio for game?

paper sluice
sullen pewter
#
@client.command()
@commands.has_permissions(administrator=True)
async def ticket(ctx): 
  button1 = Button(label = "Ticket", style = discord.ButtonStyle.green)
  button2 = Button(label = "Close", style = discord.ButtonStyle.red)
  category = discord.utils.get(ctx.guild.categories, name="Tickets")

  async def button_callback(interaction: discord.Interaction):
    ticket_channel = await interaction.guild.create_text_channel(name="Ticket", category=category)

    async def button2_callback(interaction: discord.Interaction):
      await interaction.channel.delete()

    button2.callback = button2_callback
    view2 = View()
    view2.add_item(button2)
    await ticket_channel.set_permissions(interaction.user, read_messages=True, send_messages=True, read_message_history=True)
    await ticket_channel.edit(permissions_synced=True)

    await ticket_channel.send(embed=embed, view=view2)

  view = View()
  button1.callback = button_callback
  view.add_item(button1)

  embed = discord.Embed(title="New ticket from {}#{}".format(Interaction.user.name, Interaction.user), description= "Click the Red Button below to delete this ticket.", color=discord.Color.orange())

  await ctx.send(embed = discord.Embed(title = "Ticket", description = "Click the Green Button below to create a ticket.", color=discord.Color.orange()), view = view)```
slate swan
sullen pewter
paper sluice
#

no

slate swan
#

Lol

paper sluice
#

a
a

sullen pewter
#

ye

paper sluice
#

that is, python cares about indentation

slate swan
#

a
a
A

#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

sullen pewter
#

and in the created channel it sends a message with a button to close the ticket

slate swan
#

Lol

slate swan
#

I cut ur lemon in half

#

Timing

sullen pewter
#

ye lol

#

🍋

#

@slate swan

slate swan
#

?

sullen pewter
#

can you see now?

slate swan
#

Sry gtg

sullen pewter
#

I need a username of the person who interacted

#

not the ones who used the command

slate swan
#

How to send the button interaction privately?

granite parcel
#
    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def un(self, ctx, user: discord.User):
        userh = self.client.fetch_user(user)
        await ctx.guild.unban(userh)
        await ctx.send(f"{user.mention} has been unbanned!")```
#

this unban cmd is not working

slate swan
#

Like which is having the option for “dismiss this message”

slate swan
slate swan
#

ephemeral*

granite parcel
# slate swan

Command raised an exception: AttributeError: 'function' object has no attribute 'id'

#

removed that and getting this error

#

@slate swan?

regal pulsar
unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.Select.values "discord.ui.Select.values").

New in version 2.0.
tired hinge
#

reaction, user = await self.bot.wait_for("reaction_add", check=check)
how can i pass custom arguments to the check?

#

right now there's only reaction and user, i'd like to pass another

#

there's probably like a really straightforward solution and i'm too dumb to find it

heady sluice
#

you can't cuz you don't even call it

sullen pewter
slate swan
#

@regal pulsar dm

sullen pewter
#

@regal pulsar help me

slate swan
#
class View1(View):
  em1 = client.get_emoji(970556505973739540)
  def __init__(self):
    super().__init__(timeout=None)

  @button(custom_id='3', style = '3', emoji=':1779_check:')
  async def counter(self,interaction: Interaction, button: Button, ctx):
    member = ctx.author
    await interaction.response.send_message(await member.ban)

  @button(custom_id = '2', style = '2', emoji=':1326_cross:')
  async def counter1(self,interaction: Interaction, button: Button):
    await interaction.response.send_message("Cancelled ban cmd")

@client.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, *, reason=None):
  await ctx.send(f"Are you sure you want to ban {member.mention}", view = View1())
``` this is my code but i cant ban the user
#

error ^

#

the error says pretty much already

vernal fog
#
import disnake
from disnake.ext import commands

clientToken = ""
clientPrefix = "!"
clientIntents = disnake.Intents.default()
clientIntents.message_content = True
clientIntents.members = True

serverId = 973645962666975344

bot = commands.Bot(command_prefix = clientPrefix, intents = clientIntents)

@bot.event
async def on_ready():
    print(f"{bot.user.name} | online")

    # Get Server by ID
    server = bot.get_guild(serverId)

    # Get Member-Names in List
    global memberList
    memberList = []
    for member in server.members:
        memberList.append(member.name)

@bot.command()
async def members():
    for member in memberList:
        print(member)

bot.run(clientToken)```
#

i was trying to switch from discord.py to disnake, but i get an error that says the ctx is missing. even though i dont wanna use ctx at all. does anyone know how to fix this?

granite parcel
#
Command raised an exception: NotFound: 404 Not Found (error code: 10013): Unknown User```
#

how to make error for this

heady sluice
#

and there's no way this worked in dpy

vernal fog
#

why would i add ctx to my command if I dont need it for the logic? I'll get another error!

heady sluice
#

cuz dpy/disnake passes it to you anyways

vernal fog
#

i'll get another error!

heady sluice
#

what error

slate swan
#

pass a context ~

#

wait wtf

#
@button(custom_id='3', style = '3', emoji=':1779_check:')
  async def counter(self,interaction: Interaction, button: Button, ctx):
    member = ctx.author
    await interaction.response.send_message(await member.ban)``` why is a ctx there?
#

the style is also wrong, needs to be ButtonStyle or an integer

slate swan
#

its a string~

#

But still it works

#

!e print(type("3"))

unkempt canyonBOT
#

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

<class 'str'>
slate swan
#

well, remove ctx from that function ..

#

if you want the user who added that interaction use interaction.user

slate swan
slate swan
#

!d discord.Member.ban

unkempt canyonBOT
#

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

Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
slate swan
#

!d discord.Guild.ban

unkempt canyonBOT
#

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

Bans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to
do this.
slate swan
slate swan
surreal ruin
#
python bot.py
Traceback (most recent call last):
  File "bot.py", line 12, in <module>
    import helpers
  File "/home/runner/poketwo-6/helpers/__init__.py", line 1, in <module>
    from . import checks, constants, context, converters, pagination
  File "/home/runner/poketwo-6/helpers/context.py", line 5, in <module>
    class ConfirmationView(discord.ui.View):
AttributeError: module 'discord' has no attribute 'ui'
exit status 1```
#

anyone?

slate swan
surreal ruin
#

how to import helpers

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
slate swan
slate swan
#

await ban?

#

what?

surreal ruin
#
python bot.py
Traceback (most recent call last):
  File "bot.py", line 12, in <module>
    import helpers
  File "/home/runner/poketwo-6/helpers/__init__.py", line 1, in <module>
    from . import checks, constants, context, converters, pagination
  File "/home/runner/poketwo-6/helpers/converters.py", line 5, in <module>
    from durations_nlp import Duration
ModuleNotFoundError: No module named 'durations_nlp'```
slate swan
#

how to i put this tree in my game

tired hinge
#

how can i edit an embed based on the reaction that a user adds to it?

slate swan
#

ss

tired hinge
slate swan
#

u

tired hinge
#

ping when you reply smh, okay

#

of code or the embed?

slate swan
#

embed

tired hinge
slate swan
#

mhm

#

ss code

tired hinge
#

i dont have any code related to editing based on reactions, just made the bot add the ◀️ and ▶️ reaction on the embed

slate swan
#

mhm

#

u want when ctx.author react on that reactions to switch page or?

slate swan
#

ss code

#

of the embed

tired hinge
#

okay

#
async def ud(self, ctx, *, term):  
        try:
            r = requests.get(f"https://api.urbandictionary.com/v0/define?term={term}").json()
        except:
            return await ctx.send("that word doesn't even exist what are you doing")
        num = 0
        definition = r["list"][num]['definition']
        word = r["list"][num]['word']
        example = r['list'][num]['example']
        thumbsup = r['list'][num]['thumbs_up']
        thumbsdown = r['list'][num]['thumbs_down']
        author = r['list'][num]['author']
        if '[' in example or ']' in example:
            example = example.replace('[', '')
            example = example.replace(']', '')
        if '[' in definition or ']' in definition:
            definition = definition.replace('[', '')
            definition = definition.replace(']', '')
        e = discord.Embed(title=word, color=discord.Color(0xf9f03b))
        try:
            e.add_field(name="Definition: ", value=definition, inline=False)
        except:   
            await ctx.send("That definition is too long for me to send")
        e.add_field(name="Example: ", value=f'*{example}*', inline=False)
        e.add_field(name="👍", value=thumbsup, inline=True)
        e.add_field(name="👎", value=thumbsdown, inline=True)
        e.set_footer(text=f"Written by: {author}")
        e.set_thumbnail(url='https://media.discordapp.net/attachments/960947264770150442/961946894559481957/unknown.png')
        e.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
        ms = await ctx.send(embed=e)
        await ms.add_reaction("◀️")
        await ms.add_reaction("▶️")```
#

i know requests is blocking, im gonna switch it out soon

slate swan
#
        await ms.add_reaction("▶️")```
#

sec

#

huh

#

hmmm

tired hinge
#

forgot to add the num = 0 line

#

because i would like num to be 1 when the user clicks next and -1 vice versa

slate swan
#

its okay i just needed that 2 last lines to see

tired hinge
#

...so how do i edit the embed based on the reactions

slate swan
#

like page?

tired hinge
# slate swan like page?

yes - when the num variable becomes 1 then all the values (definition, example, author, etc) will come from the next item in the array

slate swan
#

sry can't help i don't know so much about embed i tryed to find something but cna't help i'm really sorry

tired hinge
#

;-;

#

its alr

tired hinge
slate swan
#

do u know how to i add some pic in my game visual studio not for discord bot like object

#

that pic to be object

#

like this i wanna to be tree object

tired hinge
slate swan
slate swan
#

how to get a guild id on a on_ready event

maiden fable
slate swan
vocal plover
#

what's the context?

regal pulsar
#

then channel.send

regal pulsar
#

also you should probably learn python before making this 💀

vocal plover
#

I take it you didn't actually bother to read the message they sent after

heady sluice
#

he ignored me

#

😭

regal pulsar
#

im on mobile it scrolls down when i send a message

regal pulsar
#

everything after can be added by you

slate swan
#

Anyone?

#

!from discord_buttons_plugin import *

spring flax
#

can someone remind me of how to do this:
this is not correct i assume but it should give a idea of what I want to be done. BOTH_ROLE_IDS is a list variable
this is waht i have now if any(BOTH_ROLE_IDS) not in member._roles:

heady sluice
#

if any(BOTH_ROLE_IDS not in member._roles):

#

oh wait nah

uncut portal
heady sluice
#

if any(role_id not in member._roles for role_id in BOTH_ROLE_IDS):

uncut portal
#

looks good to me

slate swan
slate swan
#

This is eval code

uncut portal
#

you're syntax looks slightly muddled although I haven't used any discord library in a very long time so I don't really know what you are trying to do either

slate swan
#

💀

uncut portal
#

To be honest I haven't actually used python in quite a long time

tropic burrow
#

how do you delete someone's roles

#

via the bot

thin raft
thin raft
#

then use

#

member.remove_roles(role)

tropic burrow
#

i have a command to mute someone, it gives a muted role and removes everything else

thin raft
#

don't do that

tropic burrow
#

how to remove everythong else

thin raft
#

no

tropic burrow
#

ok

thin raft
#

just put mute role on top of all roles

#

like this muted role permissions will overwrite other ones

tropic burrow
#

ohhhhh

slate swan
#

hi

thin raft
#

hey Sparky

slate swan
#

@slate swan

slate swan
slate swan
#

Error eval

thin raft
#

the syntax ong

slate swan
#

show full traceback

#

Ok wait

#
@commands.check(is_bot_owner)
@client.command(name="eval", aliases=["exec", "execute", "codexe"])
async def _eval(ctx, *, code):
    code = clean_code(code)
    local_variables = {
        "discord": discord,
        "commands": commands,
        "bot": client,
        #"Token": T, 
        "client": client,
        "ctx": ctx,
        "channel": ctx.channel,
        "author": ctx.author,
        "guild": ctx.guild,
        "message": ctx.message,
    }

    stdout = io.StringIO()

    try:
        with contextlib.redirect_stdout(stdout):
            exec(
                f"async def func():\n{textwrap.indent(code, '    ')}",
                local_variables,
            )

            obj = await local_variables["func"]()
            result = f"{stdout.getvalue()}\n-- {obj}\n"

    except Exception as e:
        result = "".join(format_exception(e, e, e.__traceback__))

    pager = Paginator(
        timeout=180,
        use_defaults=True,
        entries=[result[i : i + 2000] for i in range(0, len(result), 2000)],
        length=1,
        prefix="```py\n",
        suffix="```",
    )

    await pager.start(ctx)
#

@slate swan

thin raft
#

show imports

slate swan
thin raft
#

my eyes athisisfine

#

why you have those imports

#

and why there are so many errors

spice adder
#

Heyo, working on modifying this code to only write bans with "alt" in the reason (not words like "shalt" either). I tried to use re.find('pattern', ban.reason) to run the check, but it says that "re" has no attribute "find"

current code: ```py
import discord
from discord.ext import commands
import os, re, datetime, json
from requests import get
from dotenv import load_dotenv

just showing imports here

@client.event
async def on_ready():
print("Hello Wrold lets kick ass and Wahoo basketball")
await client.change_presence(activity=discord.Game("waba"))

try:
g = client.get_guild(507364684924452896)
await banlist(g)
except Exception as e:
print(e)

async def banlist(g):
try:
bans = await g.bans()
banids = [banentry.user.id for banentry in bans]
f = open("banlist.txt", "w")
f2 = open("banlist-formatted.txt", "w")
for id in banids:
if re.find('\balt\b', ban.reason):
f.write(str(id) + '\n')
for ban in bans:
if re.find('\balt\b', ban.reason):
f2.write("User: " + str(ban.user.name) + '/' + str(ban.user.id) + " Reason: " + str(ban.reason) + '\n')
except Exception as e:
print("Something happened" + str(e))
finally:
f.close()
f2.close()

thin raft
#

use with open

slate swan
#

💀

#

@thin raft now tell?

spice adder
#

Well actually, let me rephrase, what position would it go in with open?

thin raft
#

install those modules first

slate swan
#

Bruh

#

Just tell me why this is now working

spice adder
#

They're telling you why

thin raft
#

module is not fouhnd

#

you don't have it installed it

#

instead of open("file")

#

use with open("file", "r/w") as f:
data = f.read()

spice adder
#

Thanks!

thin raft
#

but that isn't the issue

#

just wanted you to know the best way of doing it

spice adder
#

Mm, what's the issue then?

thin raft
#

i dont understand what you're trying to do

spice adder
#

Basically output a list of all current guild bans

#

The code has worked before, the only thing being changed is the regex stuff

#

How it looks when ran without the regex part

stiff gorge
#

how to make my bot print ist ?

mellow mauve
#

Does anyone know why this does not work

slate swan
#

how to make when ctx.author send command to bot add reaction and when ctx.author react on it bot delete message

modern dragon
#

does anyone knows a bot that gives roles to the person sitting the vc?

slate swan
#

?

slate swan
#

what does "not work" mean? does the command not execute?

#

is "Anime_hug_gif" a list?

sick birch
sick birch
slate swan
#

BUT

#

where to i put it

#

wow u said just add-reaction and wait_for what

stiff gorge
#

how to make a command which will work in a specific server with given id

sick birch
#

You put all that stuff after the part where you send the message

slate swan
#

i suppose the easiest way for a beginner would to use an if-statement at the start of the command

sick birch
#

Make a check

#

If it’s for all commands you can do that inside your on message EVENT

slate swan
#

yeah but add_reaction()

#

u forget on ()

#

and do i need to put emoji in ()?

sick birch
slate swan
#

k i know that for wait_for and add_reaction but i don't know next

sick birch
#

And check if the reaction returned by wait for is the same reaction returned by add_reaction

#

If so, delete the message

slate swan
#

-_-

sick birch
#

Easy as that

slate swan
#

i need add_reaction(<what here?>)

sick birch
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji")...
slate swan
#

finnaly

sick birch
#

I also linked you to this yesterday

slate swan
#

👍

#

under await ctx.send?

sick birch
#

Right

#

Remember ctx.send returns the sent message

#

Which you need to add a reaction to

slate swan
sick birch
#

Needs to be in a string

slate swan
#

?

#

{}?

#

oh ""?

sick birch
#

And that should be your first argument

#

It’s not gonna work just sitting there by itself

#

also add_reaction needs to be called on a message instance

slate swan
#

?

slate swan
#

uh

#

can't help me

sick birch
#

What can’t?

#

!d discord.Client.wait_for has an example waiting for reactions

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
slate swan
#

english is not my first language so i cna't understand that

sick birch
#

It has everything you need

slate swan
#

can't*

sick birch
#

Sending message, adding reaction, and waiting for a reaction

spice adder
#
@client.event
async def on_ready():
  print("Hello Wrold")
  await client.change_presence(activity=discord.Game("waba")) 

  try:
        g = client.get_guild(507364684924452896)
        await banlist(g)
  except Exception as e:
        print(e)

async def banlist(g):
    try:
        bans = await g.bans()
        banids = [banentry.user.id for banentry in bans]
        f = open("banlist.txt", "w")
        f2 = open("banlist-formatted.txt", "w")
        for id in banids:
          if re.search('\balt\b', ban.reason):
            f.write(str(id) + '\n')
        for ban in bans:
          if re.search('\balt\b', ban.reason):
            f2.write("User: " + str(ban.user.name) + '/' + str(ban.user.id) + " Reason: " + str(ban.reason) + '\n')
    except Exception as e:
        print("Something happened" + str(e))
    finally:
      f.close()
      f2.close()
``` Alright so, found out I was just stupid when using re.find instead of search because of Go, but now it's saying that: `local variable 'ban' referenced before assignment`

Do I need to define 'ban' and if so, what do I define it as?
slate swan
sick birch
#

Then look at the example

sick birch
spice adder
#

Hmm, so how should I define it to have it come before the loop?

slate swan
#

guys in a command how can i check that content of the second parameter?

thin raft
#

wdym

slate swan
#

lets say i have
@bot.command()
async def pog(ctx, poe)
how can i check the content of poe in the code?

spice adder
thin raft
#

it's a variable

slate swan
#

Yes

thin raft
slate swan
#

it's a variable and i wanna something to happen if the variable had something

thin raft
#

do you know even python basics?

sick birch
slate swan
#

yes?

thin raft
sick birch
#

@slate swan you can assume that variable always has something in it

#

Because if not, discordpy throws an error

#

Unless you specify a default value

spice adder
sick birch
#

I don’t think that’s what they’re asking for

slate swan
#

i'll explain,
the command sets a log channel and everything is right
what i wanna do is check if the logchannel argument is "None" For example and do the rest of the code, i tried stuff multiple times and yeah

spice adder
#

Oh? My apologies

sick birch
#

Give it a default value of “None”

#

Then check if that variable is none inside your code

slate swan
#

alright, thanks

stiff gorge
#
async def main():
  async with bot:
      async for i in (
        'connect4',
        'dev',
        'Dev',
        'economy',
        'help',
        'profile',
        'utility',
        'info',
        'image',
        'fun',
        'SubredditFetcher',
        'hangman',
      ):
        await bot.load_extension(f'cogs.{i}')
    async def main():
    ^
IndentationError: unexpected unindent```
how to run the cogs in main.py ?
cosmic kestrel
#

Is forking the python discord bot , editing and creating your own bot copyright infringment or something?

paper sluice
stiff gorge
#

there is a lot

thin raft
#

just the thing before

#

not all

stiff gorge
#
@bot.command(name="lock",
                   brief="Locks channel(s).",
                   help="Lock current/all channel(s)"
                   )
@commands.has_permissions(manage_channels = True)
async def _lock(self, ctx, channel=None):
    if ctx.guild.id == 841155872259833886:
      overwrite = ctx.channel.overwrites_for(ctx.guild.default_role)
      try:
        if channel == None and overwrite.send_messages != False:
          await ctx.channel.set_permissions(ctx.guild.default_role, send_messages = False)
          await ctx.send("Locked.")
          if channel == None and overwrite.send_messages == False:
            await ctx.send("This channel is already locked.")
            if channel == "all":
              await ctx.send(f"This will **lock** *all* channels. Type `{confirm}` to confirm.")
              def check(m):
                return m.channel.id == ctx.channel.id and m.author.id == ctx.author.id
                try:
                  msg = await self.bot.wait_for("message", timeout=30, check=check)
                except asyncio.TimeoutError:
                  return await ctx.send("Time's up. Aborted.")
                  if msg.content.lower() != confirm:
                    return await ctx.send("Aborted.")
                    await ctx.send("Locking all channels...")
                    await self.send_m(ctx=ctx, check=False)
                    await ctx.send("Locked all channels ✅.")
slate swan
slate swan
frozen patio
#

Hello.

loud junco
frozen patio
#

Hey

paper sluice
stiff gorge
#

ohk

frozen patio
#

1 thing I hate about Python has the no mixing spaces and tabs thing

#

Be like

slate swan
#

that raises a syntax error

slate swan
frozen patio
#

VS Code does that

slate swan
#

yup

frozen patio
#

Thank god it does

slate swan
#

amen

frozen patio
#

I started making a whole API in Py

slate swan
#

with flask?

frozen patio
#

No

slate swan
#

or fastapi?

frozen patio
#

Fastapi

slate swan
#

mhm nice

frozen patio
#

Yes

#

With interactive docs

slate swan
#

now ill wrap itshipit

frozen patio
#

And pipelines for the api and such

slate swan
#

lovely

frozen patio
#

Yea it’s gonna be full blown cause yes

slate swan
#

i need to wrap the ani api and then im going to try out ursina

frozen patio
#

Nice

#

Sounds fun

slate swan
#

yup

#

you should wrap your own api😳

frozen patio
#

We decent python devs

frozen patio
slate swan
#

i was thinking of making an api with flask but i dropped the idea

frozen patio
frozen patio
slate swan
#

oohhh nice

#

i just used flask for webdev

frozen patio
#

I do too

slate swan
#

and i learned a bit of css and html along the way with templates

frozen patio
#

I made a cool web thing with flask

slate swan
#

!ot

unkempt canyonBOT
slate swan
#

ash mad she dont have any cool projects

frozen patio
#

Ok yes go to an ot channel

slate swan
#

😔

frozen patio
#

With django

frozen patio
#

Add in the json file

#

{}

#

Then let the code do it

slate swan
frozen patio
slate swan
frozen patio
#

Ok

slate swan
frozen patio
slate swan
#

i have a command to add the guild id and the logschannel and im trying to make a command that pops it from the json file

frozen patio
#

Oh

slate swan
#

idk tbh

frozen patio
#

Don’t use json for that

#

SQL for that

slate swan
#

god damn sql

#

i have like absolute 0 idea about sql

frozen patio
#

Read the docs

slate swan
#

mongoDB is trash imo

frozen patio
#

Ikr

slate swan
frozen patio
#

SQL is where it’s at

slate swan
#

i never used any database structures b4

#

whats database structures

frozen patio
#

Databases are good to know

#

Before I could even think about web dev I needed to learn databases

slate swan
#

i meant databases generally never used them

slate swan
slate swan
frozen patio
#

Ikr

#

I learned both 🙂

slate swan
#

same

frozen patio
#

Yes

slate swan
frozen patio
#

Great

slate swan
#

i guess i'll spend time doing that so pepeshrug since people seriously always asked me to do when i faced issues with json db's

slate swan
slate swan
slate swan
slate swan
#

!e

import __hello__```
unkempt canyonBOT
#

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

Hello world!
frozen patio
slate swan
stone beacon
#

I like myself some firebase

loud junco
#

And they dont even teach None

#

Imagine the suffering im going through

sullen pewter
regal pulsar
#

can someone ping me

slate swan
#

@regal pulsar

thin raft
regal pulsar
slate swan
#

Im trying to alert the bot when the message content is less than 3 characters, how do i do this?py if message.content > 3:

#

len(message.content)>3

full lily
#

> is "more than"

slate swan
#

oh poop, mb

nimble plume
#

How do I hack someone bot

thin raft
#

You don't

nimble plume
#

Why I want to

#

It's my dream

native wedge
#

i wanna make a slash command with disnake
and i want it to be
/verify username:

how do i take what the author says for username to turn it into a variable

nimble plume
#

No

glad cradle
native wedge
nimble plume
#

Commonsense

native wedge
glad cradle
#

or other libraries?

native wedge
#

disnake

glad cradle
#

ok

native wedge
#

im new to slash commands

glad cradle
#
@commands.slash_command()
async def verify(self, inter, member: disnake.Member):
...
slate swan
#

anyone know why my help cmd isnt working

from discord.ext import commands
import discord
import os

client = commands.Bot(command_prefix='-',help_command = None, intents=discord.Intents.all())
@client.event
async def on_ready():
    print("bot:user ready == {0.user}".format(client))

client.remove_command("help")

@client.command(description = "Shows This Embed")
@client.group()
async def help(ctx):
    if ctx.invoked_subcommand != None:
        return
    embed = discord.Embed(title = 'Categories', description = "Shows This Embed")
    for command in client.walk_commands():
        description = command.description
        if not description or description is None or description == "":
            description = "No description provided"
            
        embed.add_field(name = f"-{command.name}", value = description, inline = False)
    await ctx.send(embed=embed)

@help.command()
async def download(ctx):
    #ill send an embed here```
slate swan
#

also, you should never name your function as "help"

native wedge
slate swan
#

Yo how to add a reaction to a message?

native wedge
#

and then make a variable based of that

slate swan
unkempt canyonBOT
#

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

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji")...
glad cradle
#
@commands.slash_command()
async def verify(self, inter, username: str):
  ...
nimble plume
#

@supple thorn I saw ur pfp on new mr beast vid

nimble plume
#

New mr beast reacts video

nimble plume
supple thorn
nimble plume
#

See

slate swan
ebon island
#

How do I handle it if after a connection interruption my Bot is still connected a channel but if you check the is_connected() method it returns false? How do I handle this case?

maiden fable
#

well dpy should automatically handle that

native wedge
#
from disnake import CommandInteraction
from disnake.ext.commands import Bot
import os
from private.config import token

bot = Bot()

@bot.event
async def on_ready():
    print("The bot is ready!")

@bot.slash_command(
    name="ping",
    description="A simple ping command."
)
async def ping(inter: CommandInteraction) -> None:
    await inter.send(f"Pong! {bot.latency * 1000:.2f}ms")

    
bot.run(token)```

my ping command doesn't appear, any help?
ebon island
#

I've been trying to nail down the issue with the voice connection, it disconnects and does not resume when reconnected if the disconnection is more than a minute so I'm trying to troubleshoot how to make that happen and it is proving a tricky proposition

maiden fable
#

Try opening an issue in the dpy repo, its more of an internals issue

ebon island
#

dpy or disnake? I know disnake is a fork so not sure if there is a separation of responsibilities or something or even any idea how that division works

#

in terms of git issues

vocal plover
ebon island
#

Will do 🙂

vocal plover
#

ideally the lib should definitely be reconnecting, so assuming I can recreate the issue that definitely needs looking into soon

paper sluice
ebon island
#

steps to recreate - start playing to a voice client, disconnect for more than a minute and reconnect, it will not resume playing after the connection is reestablished

#

I assume 60 seconds is the cutoff since that is the default time in dpy

#

but shorter interruptions it will continue playing

#

longer interruptions it will not

formal basin
#

How can I make my description like this

glad cradle
ebon island
#

I am testing implementation for a 24/7 music bot but when there is an interruption it will stop and will simply sit idle thereafter'

#

I have tested it repeatedly both in natural case where the internet cuts out overnight due to upgrade (I have starlink) and artificial where I manually disconnect my ethernet cable from my dev PC, both produce similar results

torn sail
formal basin
native wedge
lethal moat
#

is there a limit to the amount of running views a bot can have? I have my bot in a 70k person discord server (its a ticket bot) and the close buttons stopped working after hundreds of tickets were made..
(the buttons are persistent)

slate swan
#

Guys is this possible to make slash commands visible to members if they have certain role (I know how to do this) or if their user id is in a list??

#

ye

#
from discord.ext import tasks

@tasks.loop(minutes= 120)
async def blabla():
    #Do something

@client.event
async def on_ready():
    blabla.start()```
quaint forum
#

Is there a way to get a list of all the people with a specific role?

slate swan
#

no

#

!d discord.Role.members

unkempt canyonBOT
slate swan
#

ye this too

quaint forum
#

thank you

slate swan
#

nah i dont think so

slate swan
#

thats just calling different kwargs and you should wait_until_ready

regal pulsar
unkempt canyonBOT
slate swan
#

!d discord.ext.commands.Bot.wait_until_ready

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready...
regal pulsar
slate swan
#

😅

unkempt canyonBOT
#

Hey @coral vessel!

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

coral vessel
heady sluice
#

I don't like it

frozen patio
#

New line?

native wedge
#
from disnake import CommandInteraction
from disnake.ext.commands import Bot
import os
from private.config import token

bot = Bot()

username = ""

@bot.event
async def on_ready():
    print("The bot is ready!")

@bot.slash_command(
    description="Links your Geometry Dash account to Discord"
    )
async def link(inter, username: str):
    await inter.response.send_message(username)
    
bot.run(token)```
maiden fable
native wedge
#

any idea why it gives the error in the image i sent

frozen patio
#

If you’re receiving html errors in your python code, that means an API timeout

#

@coral vessel this

slate swan
sage otter
frozen patio
#

Happens to my friend

slate swan
frozen patio
#

Yeah

#

But his code can’t be the error

maiden fable
native wedge
#

replit is bad, thats the error

slate swan
frozen patio
maiden fable
#

And yea, Discord Party Mode sucks and is annoying

frozen patio
#

It does get annoying

maiden fable
#

I agree

slate swan
#

(I havent tried it but anyways it looks annoying to the eye)

sage otter
#

You line breaks. You know \n

paper sluice
maiden fable
#

Eh, it seems fun at start but I hate the effect when there is confetti on the top of the cursor when I am typing in the text bot

paper sluice
#

plain old discord typing gets boring

maiden fable
#

Lmao I just set the confetti to max lets see how annoying it can get before I turn it down to 0

paper sluice
#

les go

sage otter
#

The heck is that

#

I’ve never seen that before.

slate swan
#

party mode made my client have a stroke

torn sail
maiden fable
sage otter
#

Is that new or something

maiden fable
#

Yea

#

Releasing nowadays only

slate swan
maiden fable
#

Ngl it would have made more sense if they did it for their 10th anniversary

slate swan
#

it would be better if everyone got nitro for 3months

paper sluice
#

discord won't do that

maiden fable
#

Meh discord likes feeding nitro codes to self bots via YT video

slate swan
#

so then they get no money and they go broke

paper sluice
#

Microsoft will buy discord b4 its 10th bday

maiden fable
#

OT anyways

native wedge
slate swan
native wedge
#

how do i update it

slate swan
#

pip install -U disnake and rerun the code it should work

#

idk where this CommandInteraction thing is coming from~

native wedge
slate swan
#

ah, its just an alias for disnake.ApplicationCommandInteraction

native wedge
#

but is the code itself good or

slate swan
#

😭 you are using an ancient version of python as it says

#

update your python, then disnake

native wedge
#

i thought i was running 3.10

#

lemme update

river kindle
#

hi guys i am creating a command and in this command when i run it it has to create a room and add the people mentioned, only it adds the user who used the command, how can i fix my code?
code (if there are spaces in the code, the translator does this):

async def real1v1 (ctx, member: discord.Member, arg, product, *, stars):
  embed = discord.Embed (title = f "New realistic 1v1 wager for {arg}", description = f "** Team 1: {product} vs Team 2: {stars} **", color = discord.Color.red ())
  guild = ctx.guild
  member = ctx.author
  member2 = ctx.author.member
  admin_role = get (guild.roles, name = "RoleTestAdmin")
  overwrites = {
        guild.default_role: discord.PermissionOverwrite (read_messages = False),
        member: discord.PermissionOverwrite (read_messages = True),
        member2: discord.PermissionOverwrite (read_messages = True),
        admin_role: discord.PermissionOverwrite (read_messages = True)
    }
  channel = await guild.create_text_channel (f'Team1-Team2 ', overwrites = overwrites)
  #await channel.send (f "{product} {stars}")
  embed.set_footer (text = f "{ctx.guild.name}")
  await ctx.send (embed = embed)```
native wedge
slate swan
#

@native wedge py -m pip install -U disnake

native wedge
#
  bot = Bot()```
#

this is fine cause im using slash commands right?

slate swan
#

yes

#

you can use InteractionBot instead if you need only slash commands

gusty shard
#

im trying to code an anti-bot for my server

#

it sends message to the channel when user joins

#

but its not working when user writes the answer

#
num = ""
num2 = ""

@bot.event
async def on_member_join(member):
    global num
    global num2
    num = random.randrange(1, 11)
    num2 = random.randrange(1, 11)
    channel = bot.get_channel(973669891284533258)
    await channel.send(f"{member.mention}")
    await channel.send("You have to enter the answer for access the rest of server.")
    await channel.send(f"`{num} + {num2}`")
    guild = member.guild
    channel2 = bot.get_channel(973676840424185926)
    await channel2.send(f'{member.mention} joined, now we are {guild.member_count}.')


@bot.event
async def on_message(message):
    await bot.process_commands(message)
    global num
    global num2
    if message.channel.id == 973669891284533258:
        if message.content == int(num) + int(num2)
            kullanici = message.author
            role = discord.utils.get(kullanici.guild.roles, name="Member")
            await kullanici.add_roles(role)
            await message.channel.purge()
            await kullanici.send("Welcome to the server")```
#

can sombody help me please?

zealous jay
#

@gusty shard do you have your intents on?

#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way.
You can set and retrieve individual bits using the properties as if they
were regular bools.

To construct an object you can pass keyword arguments denoting the flags
to enable or disable...
gusty shard
#

let me check

#

yes they are on

zealous jay
#

Both in developer portal and in your code?

gusty shard
#

yep

#

bot asks the question

zealous jay
#

oh

gusty shard
#

but when user answers the question it is not doing anything

gusty shard
zealous jay
#

i think there's something to make the bot wait for a response

torn sail
#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
zealous jay
#

That one

#

Maybe using this will help

gusty shard
#

let me research

#

well i tried it

#

and looks like i have to use it on on_member_join part

#

but i cant

#
num = ""
num2 = ""

@bot.event
async def on_member_join(member):
    global num
    global num2
    num = random.randrange(1, 11)
    num2 = random.randrange(1, 11)
    channel = bot.get_channel(973669891284533258)
    await channel.send(f"{member.mention}")
    await channel.send("You have to enter the answer for access the rest of server.")
    await channel.send(f"`{num} + {num2}`")
    def check(m):
        return m.content == int(num) + int(num2) and m.channel == channel
    msg = await bot.wait_for('message', check=check)
    guild = member.guild
    kullanici = message.author
    role = discord.utils.get(kullanici.guild.roles, name="Member")
    await kullanici.add_roles(role)
    await message.channel.purge()
    await kullanici.send("Welcome to the server")
    channel2 = bot.get_channel(973676840424185926)
    await channel2.send(f'{member.mention} joined, now we are {guild.member_count}.')```
#

because code will look like that

#

and message is not defined here

#

what should i do now @zealous jay

#

also thanks for helping

zealous jay
#

I guess getting the message and check if its right?

livid hinge
#

anyone know how i would retrieve a deleted message

#

so far i have the message id and the channel that it was in

#

and can i tell who has deleted it

#
Deleted message: {'t': 'MESSAGE_DELETE', 's': 83, 'op': 0, 'd': {'id': 'xxx', 'channel_id': 'xxx', 'guild_id': 'xxx'}}```
#

can i fetch the message still or is it too late once it's been deleted 🤔

cunning osprey
#

Hey guys, I'm getting this error
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
I'm on Mac, I think it's something to do with the certificate, but I'm not entirely sure how to modify this stuff on macOs

livid hinge
#

my goal is to post all the deleted messages to a dedicated channel for review purposes

livid hinge
pliant gulch
cunning osprey
#

What do I do?

pliant gulch
#

You can't make a new request to fetch it

livid hinge
#

so you would have to log all messages and go back and find it ?

pliant gulch
#

Your best bet would be to make a message cache being id:object, then receiving MESSAGE_DELETE look for the ID in your cache. Otherwise use the partial object

#

I might be understanding you wrong though, are you just trying to get a full message object?

livid hinge
#

makes sense .. yeah i just want to be able to show the message content and maybe time and author

pliant gulch
#

Welp, yea you will have to make a cache then

livid hinge
#

is the user that initiated the delete not part of the MESSAGE_DELETE ?

pliant gulch
#

The person who deleted the message is not given with MESSAGE_DELETE

#

You'd have to fetch the auditlog, if it's None then that means the message's author deleted the message

livid hinge
#

oh, thanks, that helps

#

what does the partial message come from ? would that include the content?

pliant gulch
#

Partial message is given in some events, not sure off the top of my head for which, except MESSAGE_DELETE, it doesn't include the content of the message

livid hinge
#

ok thanks 👍

formal basin
#

What does this error mean

maiden fable
#

Seems like warns is a list

#

And not a dictionary

formal basin
maiden fable
#

Well u need a dict

formal basin
#

So what should I call the dict?

formal basin
urban oasis
#

Hi how do i send some data to a discord webhook? from my script?

slate swan
#

how can i make error handlings for slash commands? Like when someone doenst have the required permissions?

vast flicker
slate swan
regal pulsar
#

idr if error handlers work with slash commands

#

just do

vast flicker
regal pulsar
#
@bot.slash_command()
async def test(inter):
    pass

@test.error
async def on_test_error(inter, error):
    if isinstance(error, commands.MissingRequiredPermissions):
        await inter.send(“No perms”)
vast flicker
#

if member.roles.cache.has('role-id-here'): //code

#

or if member.permissions.has(Permissions.FLAGS.ADMINISTRATOR )

regal pulsar
#

np

vast flicker
#

Oh wow

sick birch
#

Do you have message intents in your code and the dashboard turned on?

brave forge
livid hinge
brave forge
#

after installation discord.py version 2.0 bot stopped responding to commands and events. what to do?

livid hinge
#

to make up for the fact that the server audit log just says "Deleted Message"

#

what does sync_permissions=True do when creating the bot

livid hinge
brave forge
livid hinge
#

it should indicate that the bot was successfully added on the gateway end

#

it just runs if you have a listener for that particular event

dire folio
#

how do you those form things

livid hinge
#

the other possibility is if you have an on_message event but you dont have await bot.process_commands(message) at the end - that will prevent a lot of things from firing

brave forge
#

@livid hinge

import discord
bot = discord.Bot()



@bot.event
async def on_ready():
    print("ok")


@bot.slash_command()
async def hi(ctx):
    await ctx.send(f"Hello!")```
#

what's the problem?!

livid hinge
#

you have a bot.run right ?

brave forge
#

there is

livid hinge
#

does it print "ok"

brave forge
#

yes

#

here I do not understand everything in general, there are no errors, but he does not respond to any command

#

when there was an old version 1.7.3 everything worked with the new one nothing works

livid hinge
#

do you see anything in the log when you run your command? does the slash command show up in discord

brave forge
#

no

livid hinge
#

no to both ?

brave forge
#

@livid hinge maybe my python version is too new ?

brave forge
livid hinge
#

when you added the bot, did you do both "bot" and "application.commands" here?

livid hinge
# brave forge what ?

i mean did you answer no to both questions above (nothing printed in console as well as slash command not showing up when you type./)

livid hinge
brave forge
livid hinge
#

this is on the Bot -> URL Generator page in the developer console for your app

brave forge
#

@livid hinge I didn't know that

livid hinge
#

then you copy the url at the bottom and go there to get it added to your guild with these permissions

brave forge
#

@livid hinge How to add a discord bot correctly so that everything works ??

livid hinge
#

unfortunately just by doing each step correctly 🤣

#

you see where im talking about ?

brave forge
brave forge
dire folio
#

how would i make smth like this

brave forge
#

@livid hinge And for buttons and voice command, do you need some unique checkboxes when adding?

livid hinge
#

there are a number of checkboxes for voice, yeah - not sure about buttons

brave forge
#

the most basic thing when adding a bot is which checkboxes are needed ?

#

which of these 100% will be needed in good operation?

livid hinge
# brave forge the most basic thing when adding a bot is which checkboxes are needed ?

thats one of them - the other is making sure you have the right "privileged intents" checked on the Bot page for reading messages, getting members' info, and presence updates, and finally passing in all the necessary intents when you create the bot.. like where you have

bot = Bot()``` you might need to do something like
```py
bot = Bot(intents=discord.Intents.all())```
#

also if you check the wrong boxes it will start asking for additional input values like redirect URI and webhooks and stuff

brave forge
#

@livid hinge By the way, the bot still does not respond to events

brave forge
#
@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    
    if message.content.startswith('Hello') | message.content.startswith('hello') | message.content.startswith('Hi') | message.content.startswith('hi') | message.content.startswith('Привет') | message.content.startswith('привет') | message.content.startswith('прив') | message.content.startswith('Прив'):
        await message.channel.send(random.choice(["Привет","привет","прив","Прив","Hello","hello","Hi","hi","ПОКА!!"]))```
livid hinge
#

it responded to on_ready at least, right

quaint forum
#

Earlier I asked how to get a list of all the members of a specific role and someone suggested I use

discord.Role.members```
I've been looking at this, https://discordpy.readthedocs.io/en/master/api.html#role, and I don't understand how I actually set a specific role for the bot to check. I've also tried looking things up but can't seem to find any examples relating to what I want to be done
brave forge
livid hinge
#

thats a case where you need the message content enabled under "privileged intents"

dull terrace
#

what's the best way to check if your bot is in a guild if you have their id?

brave forge
dull terrace
#

would i have to fetch each one to check

empty kernel
#

I'm working to create a welcome bot for when new people join a server. I'm making it for a couple friends (each has their own discord server). On my test server it's easy enough to hard code the general channel's ID, but if the bot is being used on multiple servers/guilds, how do I send the welcome message to the general channel of JUST the server that has that new member?

livid hinge
#

you could do something like

is_in_guild = any(g.id == 12345 for g in bot.guilds)```
slate swan
dull terrace
brave forge
#

@livid hinge after I added what you wrote, it started showing errors

slate swan
#

you could do so with discord.utils.get

livid hinge
#

the Intents.all() ?

slate swan
#

this will return a discord.Role object, which you can then use to access the members property

quaint forum
#

Okay thank you very much

livid hinge
#

looks like this

quaint forum
slate swan
#

look at the assigned variable name

quaint forum
#

Oh thats all

#

Ohh

#

Ok I understand lol thanks

digital mason
#

Hello everyone

livid hinge
#

it should have logged a more useful error further up @brave forge

slate swan
quaint forum
#

Ill check it out thanks again

digital mason
#

I noticed that my bot is too slow to load with intents, any idea how to make it run faster ?

#

What I mean is that on_ready takes longer to run with intents than without

brave forge
livid hinge
brave forge
#

@livid hinge and he swears at bot.run

livid hinge
digital mason
#

Is it possible to get a user avatar in the current guild instead of the user avatar

brave forge
#

@livid hinge bot.run('token', intents= True)

livid hinge
#

intents dont go there, they go to the Bot constructor I think

digital mason
#

True

livid hinge
#

and True is probably not a valid intent value

#

@brave forge just delete everything about intents, it seems to be causing more problems than it solves

brave forge
#

@livid hingestop it turns out that the bot will not be able to respond to events at all ?

livid hinge
#

it will, its just you've missed a step in developer portal

humble fern
#

stop cross-posting, you opened a help channel and i've told you what is wrong with your code and you aren't doing what i've said

urban oasis
#

Hi how do i send some data to a discord webhook? from my script?

slate swan
slate swan
#

yes, a music bot which streams copyrighted music from services that have no affiliation with discord

#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
dull terrace
#

wait what, it's against tos to scrape youtube for any data?

#

breaking tos whenever you watch a video with a friend in starbucks looks like froggy_chill

unkempt canyonBOT
#

Hey @empty kernel!

It looks like you tried to attach file type(s) that we do not allow (.pdf). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

empty kernel
#

Trying to better understand discord bots. I made this diagram and I'm just looking for thoughts/feedback on major mistakes. It's more of an overview, so I'm not looking to add tons of details, just wondering if I've got the gist of it right? or where my mistakes are?

sick birch
#

Looks about right - I do have to say you're overcomplicating it a bit

#

There's really nothing much to "understand" about discord bots, really

empty kernel
#

As someone new to bots, I kinda disagree, but I assume once I've spent enough time with it, then it'll be easier 🙂

zealous jay
quaint forum
#
channelID = client.get_channel(submissionChannelID)
role = discord.utils.get(channelID.guild.roles, id=winnerRoleID)
print(role)
pastWinners = role.members
print(pastWinners)```

Im trying to get all the members of a certain role, it is getting the role, but it is not printing out all the users. It prints out an empty list. Also, another thing is that it just completely ends the script. Would someone with knowledge on the subject help me out