#discord-bots

1 messages · Page 1143 of 1

iron sorrel
#

no, no:

#

!d disnake.ApplicationCommandInteraction.response

unkempt canyonBOT
paper sluice
#

what is Inter?

#

custom class? if yes, what does it subclass

#

no, just do create_channel.send('test') instead of message.channel.send("test")

iron sorrel
#

disnake.ApplicationCommandInteraction

#

remove () from message.content

paper sluice
# iron sorrel

oh ic, so you type hinted with the interactionresponse, but it still highlights for interaction

slate swan
#

Interaction has channel and reponse too btw...

swift pumice
#

where can i find the slash docs? like for the slash commands

paper sluice
#

look for it in the docs of the library you use

sour peak
#

I would like a bot to save status, username and activity data to a json file do you think this would be a good layout or do you have any improvement ideas?
this is my first time using json so if something is wrong with the format please tell me. 😄

{
    "109238457190284375": {
        "2022-07-04 16:30": {
            "NAME": "User#1234",
            "STATUS": "Offline",
            "ACTIVITY": "None"
        },
        "2022-07-04 17:00": {
            "NAME": "User#1234",
            "STATUS": "Online",
            "ACTIVITY": "Spotify"
        }
    },
    "577817213575102464": {
        "2022-07-04 15:12": {
            "NAME": "User#1234",
            "STATUS": "Offline",
            "ACTIVITY": "None"
        },
        "2022-07-04 17:00": {
            "NAME": "User#1234",
            "STATUS": "Online",
            "ACTIVITY": "None"
        },
        "2022-07-04 20:19": {
            "NAME": "User#1234",
            "STATUS": "Offline",
            "ACTIVITY": "dnd"
        },
        "2022-07-04 22:15": {
            "NAME": "User#1234",
            "STATUS": "Offline",
            "ACTIVITY": "None"
        }
    }
}
wary shadow
#

Depending on the size of the server and what changes you are tracking that will very quickly become a bottle-neck for reading/writing the file.

slate swan
#

anyway to get this to play multiple different gifs? like maybe 5

sour peak
vocal snow
slate swan
#

after another

#

like >>highfive then one gif then >>highfive again a different gif that highfives

shrewd apex
#

best way is to pil append them all

#

or u could just use a for loop to edit the message attachment

wary shadow
unkempt canyonBOT
#

itertools.cycle(iterable)```
Make an iterator returning elements from the iterable and saving a copy of each. When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely. Roughly equivalent to:

```py
def cycle(iterable):
    # cycle('ABCD') --> A B C D A B C D A B C D ...
    saved = []
    for element in iterable:
        yield element
        saved.append(element)
    while saved:
        for element in saved:
              yield element
```...
sour peak
slate swan
#

is someone able to help me setup a api? for sending images

flat solstice
#

Do button labels have a limit on how long they can be? is 36 chars too long? and what happens to buttons with long labels, does it splice a ... when it's too long or does it make the button longer? (dpy 2.0)

slate swan
flat solstice
#

okay thanks Ashley

slate swan
ashen dagger
#

How can I delete a message if it contains a certain word?

Right now I have

async def on_message(message):
    if str(message.channel) == "mod-log" and message.content == "test": 
        await message.channel.purge(limit=1)

But that only deletes it if its ONLY test ...

paper sluice
#

do await message.delete()

swift pumice
paper sluice
swift pumice
#
async def Geschlecht2(ctx):
    channel = bot.get_channel(985970666643816498)
    message = await channel.send('Was ist dein Geschlecht?(Weiblich)[Reagiere auf die nachricht]')
    await message.add_reaction('♀️')
    role = ctx.guild.get_role(992450008051875930)
    await ctx.author.add_roles(role)


@bot.event
async def on_raw_reaction_add(reaction, user):
    Channel = bot.get_channel(985970666643816498)
    if reaction.message.channel.id != Channel.id:
        return
    if reaction.emoji == "♀️":
        Role = discord.utils.get(user.server.roles, name="Weiblich")
        await user.add_roles(Role)```
hi guys i have a problem, it only works for the first reaction how can i fix that?
upper belfry
#
import discord 
from discord.utils import get
from discord.ext import commands
import os
import asyncio

discord_token = "..."

client = commands.Bot(command_prefix=";")

client.remove_command("help")

@client.event
async def on_ready():
    print(f"The One and Only, THE {client.user} HAS JOINED")

#Kick
@client.command(name="kick", aliases=["Kick", "KICK"], description="Kicks the Specified User") #might change
@commands.has_permissions(manage_messages=True, manage_roles=True, kick_members=True, ban_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
    if not member:
        await ctx.send("Who do you want to kick?")
        return

    if member.guild_permissions.administrator:
        await ctx.send("Mr {ctx.author.mention}, you can't softban an admin")
        return

    if member == ctx.author:
        await ctx.send("Imagine trying to kick yourself! ***LOL***")
        return  # Add Extra things Later
    else:
        embed = discord.Embed(colour=0xFF0000)
        embed.set_author(name=(f"User Kicked | {member}"), icon_url=member.avatar_url)
        embed.add_field(name="User", value=(f"{member.mention}"), inline=True)
        embed.add_field(name="Moderator", value=(f"{ctx.author.mention}"), inline=True)
        embed.add_field(name="Reason", value=(f"{reason}"), inline=True)

        embed2 = discord.Embed(description=(f"**You were kicked from {ctx.guild.name}... Noob**"), colour=0xFF0000)
        embed2.add_field(name="Reason", value=(f"{reason}"), inline=True)
        embed2.add_field(name="Moderator", value=(f"{ctx.author.name}"), inline=True)

        await ctx.send(embed=embed)
        await member.send(embed=embed2)
        await member.kick(reason=reason)

client.run(discord_token)

#

So I have made this bot which kicks specified users, but the problem is that altho there is no problem and no error in the code(the bot is online in the server), the command doesnt seem to work at all. I have seen someone that has the same problem and reddit but I didnt find the solution there. Anyone know how to fix this problem?

desert heart
#

Does the function get executed at all?

#

Like, if you try to kick yourself, will it show that message you put?

upper belfry
#

nothing

#

nothing appears at all

sick birch
#

You may have a badly written global error handler

desert heart
#

Well, I thought that was the entire program above

upper belfry
sick birch
#

Maybe message events are not getting dispatched

upper belfry
#

i dont know why it suddenly stopped functioning

sick birch
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.

upper belfry
#

1 sec ill c

upper belfry
sick birch
#

You don’t have them enabled?

covert basin
#

My bot can run but don't reply anything.

It shows up it is online but if I input !$help, it doesn't show up anything.

The (token) here will be replaced by the real token.

This is my code:

import discord
#import io
import random
#import textwrap
#import urllib
#import aiohttp
#import datetime
#import os
from discord.ext import commands
from itertools import cycle
from webserver import keep_alive

client = commands.Bot(command_prefix = "!$", case_insensitive=True, help_command = None)

token = "(token)"

keep_alive()

@client.event
async def on_ready():
    print('Ready, Set, Gooooooo')
    await client.change_presence(activity=discord.Game(name="Your Server"))

@client.command()
async def help(ctx=None):
   
  embed = discord.Embed(
      title="Help Index",
      description="Got lost? These might help you",
      color=discord.Color.purple()
    )
  embed.add_field(name="Official Website", value="https://miracle-dev.netlify.app/", inline=True)
  embed.add_field(name="List of commands", value="https://miracle-dev.netlify.app/commands.html", inline=True)
  embed.add_field(name="Support Server", value="(invitelink)", inline=True)

  await ctx.send(embed=embed)


client.run(token)
status = cycle(['Miracle', 'CreateByVio'])

It doesn't have any error code

cold sonnet
#

hello

cerulean solstice
cold sonnet
#

you leaked a whole ass token

#

maybe not the whole

cerulean solstice
#

before ur message

cold sonnet
#

anyways what's the matter

cerulean solstice
#

like the bot wont come online

cold sonnet
#

you typed on ready instead of on_ready

#

I wonder why it doesn't show a single error

cerulean solstice
#

still it isnt working

cold sonnet
#

well, is the token right?

cerulean solstice
#

yea

cold sonnet
#

and after typing on_ready with an underscore, did you save the code, kill the terminal and run the code again?

slate swan
#

Is there discord.User.ban and discord.User.unban ?

cold sonnet
#

there's discord.Member.ban

#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a “server” in the official Discord UI.

x == y Checks if two guilds are equal.

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

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
cold sonnet
#

and discord.Guild.unban

cold sonnet
#

discord.Guild.ban takes a user if you only have a discord.User object

cerulean solstice
#

yeah

cold sonnet
#

first realisation then agreement

#

is this a "yes I did" or an "oh yes I will do it now"

slate swan
cold sonnet
#

no you don't pass discord.Member, you call a method of a discord.Member object

cerulean solstice
#

?

slate swan
#
@bot.tree.command(name="ban", description="Ban out a member.")
async def _ban(interaction : discord.Interaction,
               member      : discord.Member,
               reason      = None):
cold sonnet
#

yeah sure

slate swan
#

i want to know is setting reason to None means parameter reason is missing ?

TypeError: parameter 'reason' is missing a type annotation in callback '_ban'
modest glade
#

imagine it as saying theres nothing there vs there being nothing there

#

in a way

cold sonnet
#

the : str part

cerulean solstice
modest glade
#

why is it indented

cold sonnet
#

first ss it's not

#

that's why sending code in text is better

#

the error's also not related to the channel

slate swan
cold sonnet
#

the = None part works

#

but you need : str

#

because in slash commands discord has to tell you what it wants you to put there

slate swan
#

reason = None : str

modest glade
#

does discord.py support slash commands? i thought it didnt, it was gonna stop being supported because of it

cold sonnet
#

reason: str = None

slate swan
#

i need help make a slash command

modest glade
#

send your error

slate swan
#

it would be reason: None | str = None

slate swan
modest glade
#

learn

quaint epoch
unkempt canyonBOT
#

typing.Union```
Union type; `Union[X, Y]` is equivalent to `X | Y` and means either X or Y.

To define a union, use e.g. `Union[int, str]` or the shorthand `int | str`. Using that shorthand is recommended. Details...
slate swan
#

im dumb

modest glade
#

we wont teach you, more fix learning

quaint epoch
#

looks cleaner imo

modest glade
#

look at examples

slate swan
#

did

slate swan
quaint epoch
slate swan
#

they all dont work

#

i would disagree ngl

#

operator over referencing a class

#

and either way Union wouldnt be the cleanest impl

#

!d typing.Optional

unkempt canyonBOT
#

typing.Optional```
Optional type.

`Optional[X]` is equivalent to `X | None` (or `Union[X, None]`).

Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the `Optional` qualifier on its type annotation just because it is optional. For example:

```py
def foo(arg: int = 0) -> None:
    ...
```  On the other hand, if an explicit value of `None` is allowed, the use of `Optional` is appropriate, whether the argument is optional or not. For example...
mossy jacinth
#

how can i make it so the user can select a channel with an modal?

cold sonnet
silent portal
#

Why does this not work? message.author gives me user instead of member for some reason.. No DM's, only Guild Messages

@bot.event
async def on_message(message):
    if not message.author.guild_permissions.administrator:
        # Error

Error: 'User' Object has no attribute 'guild_permissions'

slate swan
#

hence why Message.author returned a User obj over a Member obj

slate swan
silent portal
slate swan
#

!d discord.Message.guild

unkempt canyonBOT
silent portal
#

it's literally not working

cold sonnet
#

why if bot.ready

silent portal
#

I still get 'User' Object has no attribute 'guild_permissions'

cold sonnet
#

cuz you switched != and ==

silent portal
cold sonnet
#

you did
if no guild: do guild shit

slate swan
#

if not*

cold sonnet
#

I didn't pythonize it

#

it was Englished

slate swan
#

you mean pseudo code?

#

😭

silent portal
#

what do you guys mean

cold sonnet
#

dumbo code

cold sonnet
silent portal
#

it's right?

if guild is not none -> if guild: do guild shit

slate swan
#

you can use isinstance as well

slate swan
cold sonnet
#

you can if message.guild: do guild shit

#

and remove if bot.ready

#

also what's attachement_delete

#

prolly your own func

silent portal
#

it deletes an attachement after 15 minutes

#

but doesn't matter in this case

cold sonnet
#

wait wth

silent portal
#

@slate swan @cold sonnet
I got it now. It was because the on_message Event was triggered by the webhooks that were sent in our server. Since they can't be viewed as a member it gave me that error.

slate swan
#

thats so funny to me, a webhook invoking a command😭💀

hoary cargo
#

is there a way to check if a user has the phone number verified? 🤨 i know about .VerificationLevel but that's to check guild's one

slate swan
#

Ares👁️👁️

silent portal
slate swan
#

lol

hoary cargo
hoary cargo
#

didn't touched any code in months Sadge and now i forgor
so about my question FlushedPeek

slate swan
#

not sure if dpy handles it tho

hoary cargo
slate swan
hoary cargo
slate swan
#

already checked their docs and src :((

hoary cargo
#

well tbh, i don't think so there's any valid way to check the phone number, i wanted to handle the interaction error it gives when you try to select an option from dropdown but the channel requires to have ur phone number verified Why and if u don't yk, not even reacts won't work, but well, i guess i can live with that error since it doesn't affect the actual code

slate swan
#

it seems like its not given ig

{
  "id": "80351110224678912",
  "username": "Nelly",
  "discriminator": "1337",
  "avatar": "8342729096ea3675442027381ff50dfe",
  "verified": true,
  "email": "nelly@discord.com",
  "flags": 64,
  "banner": "06c16474723fe537c283b8efa61a30c8",
  "accent_color": 16711680,
  "premium_type": 1,
  "public_flags": 64
}
#

the example structure only shows a verified key

#

which is their email verification

median drum
#

Hi guys I’m new to the discord bot development world do you have any suggestions how to start the whole journey? I have no idea about discord bot token etc. I was just a normaln discord user for 4 years but now I decidet to became discord developer and if anyone can give me some tips where and how to start i would be really gratefull

mossy jacinth
#

how can i make it so it saves the given channels id in the file?

cloud dawn
#

Are you making a txt for each guild for settings?

sick birch
short silo
#

Is it possible to have dropdowns inside of a modal or not currently ?

hushed galleon
#

though looking in discord developers server, i think its in the works

torn sail
#

I saw it be used in dpy server

#

?tag modal select in dpy server if u want

hushed galleon
#

oh shit yeah it does work

#

now if only the text inputs could render discord markdown

short silo
#

thnx o_O

hushed galleon
#

doesnt show up on iOS and android tho

#

is it only the canary version of discord on desktop that supports it?

short silo
hushed galleon
#

i was hoping to migrate my tag commands to modals, but unfortunately i finished the prototype over a night only to find out that the input boxes dont autocomplete markdown tags and channel mentions, so i just scrapped it

slate swan
#

anyone know?

grave sand
#

You used request instead of requests

#

I've done that before, lol.

#

@slate swan

cloud dawn
#

He needs to use aiohttp

#

not even requests

flat pier
#

he doesn't need to though it is recommended to use aiohttp in most cases

cloud dawn
#

It's an async command.

slate swan
#

he should use aiohttp so you actually give the function to the event loop

#

blind eye

#

alr

grave sand
#

aiohttp helps avoid async/await?

slate swan
#

no its asynchronous

flat pier
#

requests is blocking which is why you shouldn't use it

#

when dealing with asynchronous things

slate swan
#

well i got another error list indices must be integers or slices, not str

#

ctx, *, ipaddr: str = '9.9.9.9'

#

its a string bro

#

you index them with ints

#

i did hold on i got this error

#

you tried to annotate the arg as an int but gave it a default value that isnt an int

#

so it had a conversion issue

cloud dawn
#

Python is an interpreter but not an 🍎

slate swan
#

?

cloud dawn
#

Non ableist language makes it nearly impossible to self incriminate or say something sucks.

#

Therefore an apple

slate swan
#

:( apples are smart ok

cold tide
#

Anyone know how I use the userid of the user who uses a command?

slate swan
unkempt canyonBOT
slate swan
unkempt canyonBOT
#

property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.id "discord.User.id")
cold tide
slate swan
unkempt canyonBOT
cold tide
slate swan
#

im correct :))

cold tide
slate swan
#

you want to mention the user who invoked the command or?

cloud dawn
slate swan
unkempt canyonBOT
cloud dawn
#

ctx.author.mention or interaction.user.mention

slate swan
#

panda spoonfeeding todaypithink

cold tide
#

Thankyou @cloud dawn

#

Im kinda new lol

#

don't mind the noob

cloud dawn
#

Np okimii kinda useless

#

🐒

#

🔫

tough lance
#

Heh

slate swan
#

i encourage people to learn and actually learn how to read a packages documentation ;))

cloud dawn
#

Same but I need to use brain for docs

#

And its late

slate swan
#

you have a brain!?!?!?

cloud dawn
#

no

slate swan
#

i can play that game tooyert

cloud dawn
#

Just tried to uncap an uncapped bottle

#

True story

slate swan
#

!ot

unkempt canyonBOT
tough lance
#

-goes ot
-says !ot

slate swan
#

!rule 7

unkempt canyonBOT
#

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

cloud dawn
#

That's the way the cookie crumbles.

short silo
#
..Some other Modal..
async def callback(self, interaction: discord.Interaction):
        password = self.children[0].value
        if password==Actual_Password:
            InputList=[]
            for i in range(0,5):
                InputList.append(self.children[i].value)
            await interaction.response.send_modal(Feedback2(Value="New Hero"))
        else:
            embed = Embed(title=f"Password was found incorrect, Mr.{interaction.user.display_name}!",color=Colour.red())
            await interaction.response.send_message(embed=embed)
        
class Feedback2(discord.ui.Modal):
    def __init__(self, Value):
        super().__init__(custom_id="Hero Add2", title="Hero Add Part 2")
        self.add_item(five_Star_Ability) 
        self.add_item(WAR) 
        self.add_item(DEF) 
        self.add_item(CMD) 
        self.add_item(exclusive_Skill)

...some callback... 
    ```
#
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {4, 5, 6, 7}.
hidden snow
#

hey how would i collect user info when they join a discord server
i thought about on_member-join() but i really dont know how to use it

short silo
hidden snow
tough lance
short silo
#
Traceback (most recent call last):
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
    await value.callback(interaction)
  File "e:\Python Projects\Top-War-Bot-Re\Input_Forms\Hero_Input.py", line 174, in callback
    await interaction.response.send_modal(Feedback2(Value="New Hero1"))
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 901, in send_modal
    await self._locked_response(
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 933, in _locked_response
    await coro
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {4, 5, 6, 7}.
cold tide
#

@bot.command()
async def dm(ctx, user: discord.User, *,message=None):
message=(f"Dm From {ctx.author.send}",message)

#

Can anyone help?

#

I can't use indentation here sadly.

short silo
cold tide
#

It doesn't show the user who triggered the cmd

#

@bot.command() async def dm(ctx, user: discord.User, *,message=None): message=(f"Dm From {ctx.author.send}",message)

hidden snow
#

or are there a bunch of tutorials on that

#

on things like that i should say

short silo
slate swan
#

making this ticket command it works great just wondering if there's anything i should add to make it better? that i could be missing

hidden snow
#

is interaction.user automated?

short silo
hidden snow
#

like is it ran autmatically

#

or will they have to do something in discord

#

sending a message creating a event in someway

short silo
#

as you said earlier, on member join

hidden snow
#

oh alright

#

ty ill use this

short silo
short silo
hushed galleon
# slate swan making this ticket command it works great just wondering if there's anything i s...

(edit: if you want a single place to create tickets from,) you'll need a database to store your bot's ticket messages and have a listener to check reactions, otherwise after a restart, your bot wont know what messages it needs to look for
also tickets are usually private, so to set the permissions you'll need to provide an overwrites= kwarg to create_text_channel()
(ive written an example of overwrites earlier here <#discord-bots message>)

slate swan
#

To my knowledge binary tree roots using pointers and numpy arrays is the hardest to implement in discord bots.

sick birch
slate swan
#

wait im dumb 😭

#

nevermind i got it hah

#

can you send embeds in dms?

#

or is that not possible cuz of self bots

robust fulcrum
#

How can we add permission to a command?

fading marlin
slate swan
slate swan
fading marlin
robust fulcrum
fading marlin
#

but what command? is it a slash command or a message command? /command [...] or ?command [...]?

robust fulcrum
#

Prefix comamnd

#

?command

fading marlin
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
robust fulcrum
#

I am getting error with that

fading marlin
#

you add the decorator to your command, and then set manage_guild to True

robust fulcrum
#

I typed manager_server

fading marlin
cold tide
#

I'm trying to found out how I can only make certain roles access comands can anyone help? Couldn't find any source online.

short silo
slate swan
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
slate swan
#

its a decorator

cold tide
#

Just found the source but Thankyou!

slate swan
#

if you're talking about the stackoverflow link its super outdated, the decorator part is correct tho.

slate swan
#

hello 👋

ember trail
#

can someone help me with my discord bot pls?

#

i want it to add reactions to its own message when sent but idk how to do it

hidden snow
#

Hey im making a discord bot but when i use this decorator it gives me this error code
@client.command()
async def displayembed():
pass

maiden fable
#

client = commands.Bot

#

Not discord.Client

hidden snow
#

?

slate swan
#

make a bot instance like

bot = commands.Bot(commands_prefix="!")
@bot.command()
async def displayembed():
   pass
dusky pine
#

sparky edgy pfp

hidden snow
#

it says module object is not callable

fading marlin
#

commands.Bot(...)

hidden snow
slate swan
#

change it to @bot.command()

hidden snow
#

that didnt work either

slate swan
#

show

hidden snow
slate swan
#

bro

#

define bot instance

hidden snow
#

huh?

hidden snow
slate swan
#

remove the s

#

command_prefix="!"

hidden snow
dusky pine
slate swan
#

😭

dusky pine
#

remove the discord. in the decorator

hidden snow
#

doesnt work either

slate swan
#

no way

hidden snow
#

wait

slate swan
#

show

hidden snow
#

naw i didnt try that it works

slate swan
#

nice

hidden snow
#

ty

#

💪

slate swan
slate swan
slate swan
#

sparky show us what you made

slate swan
#

it doesnt update for some reason

#

i update it everytime i start

#

i gorn to repair it

#

but after somedays it starts again

#

👀 this shows that i havent started my pc from another 16 days

#

i was making a help command

rain olive
slate swan
#

subclassed

rain olive
#

nc

slate swan
#

hardcoded subclass 🥂

rain olive
#

neat

slate swan
#

try it

#

the paginator doesnt work

#

i havent did anything yet in that

#

just the choose command and category works

rain olive
#

hikari-lightbulb has a built-in help command that is already paginated

slate swan
#

oh :p
try making your own paginator

#

ye indeed

#
    @commands.command(description="Sends help")
    async def help(self,ctx : commands.Context,help=None):
        if help  is None:
         await ctx.reply("** **",view=DropdownView(self.bot)) 
class Dropdown(disnake.ui.Select):
    def __init__(self,bot : commands.Bot):
        self.bot = bot
        options = []
        for cogs in self.bot.cogs:
         options.append(disnake.SelectOption(label =cogs))
        super().__init__(placeholder='Choose the category', min_values=1, max_values=1, options=options)

    async def callback(self, interaction: disnake.Interaction):
        abh = self.values[0]
        a = self.bot.get_cog(abh)
        em = disnake.Embed(title=abh,color=aqua)
        sdf = []
        for cmds in a.get_commands():
            em.add_field(name=cmds.name,value=cmds.description)
            sdf.append(cmds.name)
        await interaction.response.edit_message(embed=em,view=paginator(self.bot,sdf))
class DropdownView(disnake.ui.View):
    def __init__(self,bot:commands.Bot):
        super().__init__()
        self.add_item(Dropdown(bot))
class Dropdown2(disnake.ui.Select):
    def __init__(self,bot : commands.Bot,lip : list):
        self.bot = bot
        options = []
        for co in lip:
         options.append(disnake.SelectOption(label=co))
        super().__init__(placeholder='Choose the command', min_values=1, max_values=1, options=options)

No hardcode 😡

rain olive
#

disnake

slate swan
#

yes

#

my help command just asks you to use another command 🥂

#

lol

slate swan
#

why you pass bot in the Dropdown

robust fulcrum
#

Guys any comamnd idea for me?

slate swan
#

you can always access the bot using Interaction.client

#

!d discord.Interaction.client

unkempt canyonBOT
#

property client```
The client that is handling this interaction.

Note that [`AutoShardedClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AutoShardedClient "discord.AutoShardedClient"), [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot"), and [`AutoShardedBot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.AutoShardedBot "discord.ext.commands.AutoShardedBot") are all subclasses of client.
slate swan
#

it's easy though soooo

robust fulcrum
lament depotBOT
#
You're bad at computers.

@obtuse obsidian, please enable your DMs to receive the bookmark.

slate swan
#

nice

robust fulcrum
#

Whats this?

slate swan
#

it helps in saving a message

#

^

#

basically sends it to ur dms

robust fulcrum
#

Like i react 📌 to message it dm me?

slate swan
#

make it accept replied, id or link of the message

shrewd apex
#

how to send a modal?

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

thx

robust fulcrum
#

And do i need confirm and cancel for bookmark?

slate swan
#

.bm hi

lament depotBOT
#
You're bad at computers.

Your input was invalid: You must either provide a valid message to bookmark, or reply to one.

The lookup strategy for a message is as follows (in order):

  1. Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')
  2. Lookup by message ID (the message must be in the context channel)
  3. Lookup by message URL

Usage:```
.bookmark [target_message] [title=Bookmark]

slate swan
#

click pin

#

lets all bookmark ash's uwu messages

slate swan
#

uwu

slate swan
robust fulcrum
#

Oh cool

slate swan
#

f

#

.bm 995552424238514286

robust fulcrum
#

I'll make

slate swan
#

it can also work with message ids

slate swan
#

take a snowflake arg

#

and th link of the message too

robust fulcrum
#

Reply thing is fine at start

slate swan
#

it's easy though 😔 cant think of a hard command

#

i like how discord handles the snowflakes

robust fulcrum
#

And should i use raw reaction add or reaction add?

slate swan
#

you can get User.created_at just by using the ID

shrewd apex
#

how to respond to a modal interaction

slate swan
#

!d discord.ui.Modal.on_submit

unkempt canyonBOT
#

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

Called when the modal is submitted.
slate swan
#

weirdos

shrewd apex
#

thx

slate swan
#

async def callback(self, inter: discord.ModalInteraction):

robust fulcrum
#

Like i have comamnd called >pin and i have varible message in it and the message varible is seprate for every guild or global?

slate swan
#

I had a stroke reading that

robust fulcrum
slate swan
#

varible

#

var good

#

let

#

there can be only one message with a ID

#

no

#

2 messages cannot have same ID

#

unique ids for every message that is

#

but they are binded with channels as per the API

#

ye every msg has its unq id

robust fulcrum
#

Bro i asking like i use >cm comand at same time will the variable different for every user?

slate swan
#

anyways

#

;-; ofcourse whatever they will provide

shrewd apex
#

is there anyway to respond to a textinput in a modal

slate swan
#

Oop caps

shrewd apex
#

oh ic thx

slate swan
#

u mean in the modal

slate swan
#

when its on display

slate swan
unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

slate swan
#

yeah i knew

#

💀

#

use Interaction.values then

shrewd apex
slate swan
#
    async def callback(self, inter: discord.ModalInteraction):
        for key, value in inter.text_values.items():
                pass

#

u do like this

#

interaction.data best

slate swan
#

its implemented by disnake

#

in disnake it is

#

oh

#

imagine not using self.values

#

its a modal

#

idk

#

f

#

how much commands per page?

#

paginator

#

suggest pls

rain olive
#

6 at max

slate swan
#

okay

#

thx :D

shrewd apex
#

5 with inline False

slate swan
#

hayyyy

rain olive
#

5 is odd number

slate swan
#

ye

rain olive
#

so ew

slate swan
#

6 is fine 3 both side

rain olive
#

yes 3 both

slate swan
#

6.9 commands

#

:yes:

rain olive
#

💀

slate swan
#

i dont have so many commands 💀

slate swan
#

ping, pong, latency, heartbeat_latency, roundtrip

#

💀 lol

#

just realised idh ping command

rain olive
#

use words normal ppl understand

slate swan
#

i have description tho

rain olive
#

latency and roundtrip shudnt be used IMO

#

not every user is a geek

slate swan
#

just make the bot answer in "my connection good" & "my connection bad"

rain olive
#

yep

#

id say anyt above 50 is bad bcuz i get 18ms average 💀

#

but thats jst me, 50 aint bad still

slate swan
#

i get an average of 50-70ms

#

cuz free host

#

which host

#

!!!

#

railway.app, it has buildstructure like heroku/nix/docker and you'll need a github repo

vocal snow
#

I get 20ms on azure

#

But azure fcking sucks

slate swan
#

sarth can u pls teach me how do i host

robust fulcrum
#

How to get message to which we reply?

slate swan
#

i have the azure credits which i got from github students on my acc, but i dont feel like using azure

slate swan
unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

robust fulcrum
#

Ok

slate swan
robust fulcrum
#

How to get GitHub student?

slate swan
#

ye

#

huh?

slate swan
vocal snow
#

It makes you want to die

slate swan
rain olive
#

Hetzner's CPX11 (Ashburn) has gotten me single digit pings at lowest with an average at 14-20ms

spare urchin
#

So basically I was getting the full server list through client.guilds and then passed client.guilds.name etc etc..
I also wanted thumbnail to be the server icon so i passed in client.guilds.icon.url and it surely returns the server icon as an thumbnail
But
For the servers which doesnt have a icon it just show the error NoneType object has no attribute url
How should I resolve it ??

slate swan
#

you would have to do a list comprehension

#

!list-comp

unkempt canyonBOT
#

Do you ever find yourself writing something like this?

>>> squares = []
>>> for n in range(5):
...    squares.append(n ** 2)
[0, 1, 4, 9, 16]

Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:

>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]

List comprehensions also get an if statement:

>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]

For more info, see this pythonforbeginners.com post.

spare urchin
#

;-;

slate swan
#

anyways, you can have a check ```py
icon_url = Guild.icon.url if Guild.icon else None

spare urchin
#

Um yes.. it works and shows guild name guild ID guild owner guild owner ID thumbnail as the icon of the server
But
Only for the server which doesn't have an icon it shows the NoneType error
How to resolve that ??

#

Ooh ohk

#

There isn't any other ways right ??

#

Coz in js it would automatically return None for that icon

slate swan
#

json doesnt use Asset objects

#

it provides the link, or none directly

#

Guild.icon in discord.py gives you a discord.Asset object or None

#

!d discord.Asset

unkempt canyonBOT
#

class discord.Asset```
Represents a CDN asset on Discord.

str(x) Returns the URL of the CDN asset.

len(x) Returns the length of the CDN asset’s URL.

x == y Checks if the asset is equal to another asset.

x != y Checks if the asset is not equal to another asset.

hash(x) Returns the hash of the asset.
slate swan
#

and Asset here has a url property

#

you can also str(Guild.icon) to get the icon url

robust fulcrum
slate swan
#

what bot message?

#

anyone know?

robust fulcrum
slate swan
slate swan
robust fulcrum
#

pH k

#

How to fix this

@bot.command()
async def bm(ctx):
    conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)).content
    embed = discord.Embed(title="bookmark", description="react to 📌 to get message to dm",color=discord.Color.green())
    message = await ctx.send(embed=embed)
    await message.add_reaction('📌')
    id = message.id
quick gust
#

reply is not defined, it's pretty self explanatory

quick gust
#

have u copied this command from somewhere?

robust fulcrum
robust fulcrum
#

I forgot to define message reference

slate swan
#

how to make so a button can only be pressed if you have a certain role?

quick gust
quick gust
robust fulcrum
#
@bot.command()
async def bm(ctx):
    reply = ctx.message.reference
    conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)).content
    embed = discord.Embed(title="bookmark", description="react to 📌 to get message to dm",color=discord.Color.green())
    message = await ctx.send(embed=embed)
    await message.add_reaction('📌')
    id = message.id

@bot.event
async def on_raw_reaction_add(payload):
    channel = await bot.fetch_channel(payload.channel_id)
    message = payload.message_id
    user = await bot.fetch_user(payload.user_id)
    emoji = payload.emoji
    if message == id and emoji == '📌':
        await channel.send(conten)

Guys why this is not sending message

shadow vigil
#

oh lol. I said that as a joke. i didn't excepted someone named nae-nae

swift pumice
#

can i make that a bot can use slash commands? (for disboard)

slate swan
#

no

slate swan
#

and that's a really bad way of making a bm command

#

How can I get the message content for a message I reply to?

slate swan
slate swan
unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

slate swan
#

Do you have an example?

slate swan
# slate swan Do you have an example?
@bot.command()
async def bm(ctx):
    reply = ctx.message.reference
    content = (reply.cached_message or await ctx.channel.fetch_message(reply.message_id)).content
tough lance
unkempt canyonBOT
slate swan
slate swan
tough lance
#

So you're comparing a string with a class instance

slate swan
slate swan
#
if not ctx.message.reference:
  logging.info("no replies for the message")
do uwu stuff here
tough lance
#

uwu stuff 💀

slate swan
#

me

slate swan
slate swan
#

if you have issues then just look for the docs yourself

slate swan
# slate swan what
reply = ctx.message.reference
if not reply:
   # do something

Would that be correct or not, Is what I meant mb

slate swan
#

I mean

#

it wont raise any attribute error, I'm going out of my mind

#

yes it's right

#

I see

robust fulcrum
slate swan
robust fulcrum
#

I am starting up yet

#

I will improve it i am just getting idea how to works

robust fulcrum
slate swan
#

oh wait nvm

#

what's the error

karmic horizon
#

Yo, I just bought a Discord bot course on Udemy, I've downloading the libraries and stuff she's explained but I'm getting the error ModuleNotFoundError: No module named 'discord' When Running my bot

Code:

import discord

client = discord.Client()

client.run("token")

karmic horizon
karmic horizon
#

I'm on Windows 10

dusky pine
karmic horizon
#

Alright

karmic horizon
karmic horizon
#

I am getting a error message "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases."

vocal snow
#

you have to install python first

karmic horizon
slate swan
#

Waste of money tbh

#

20$

hoary cargo
#

bruh

#

paying 20$ for knowing nothing

vocal snow
#

hi ares long time no see

vocal snow
#

how much coffee do you think you can get with 20 bucks

slate swan
#

hi

slate swan
#

30 here

#

coffe

hoary cargo
slate swan
#

smh

vale wing
#

We have rubles here 😀

#

20 dollars is like 1200 rubles

slate swan
#

I'm moving to wherever, that rubble shit is cheap

crisp hinge
#

Hello there, it's been More than one day but my Bot global slash commands are not updated in other servers.

It's in 1000+ servers. So it is not possible for every servers to re invite the bot agin

slate swan
#

no option

vale wing
hoary cargo
#

tbh, at first i had warning messages about switching to slash then gradually i removed all prefix ones and fully switched

crisp hinge
vale wing
#

He means like warning embed field when using command

crisp hinge
hoary cargo
vocal snow
#

shouldn't discord automatically grant the application.commands scope to verified bots

vale wing
#

You specify it when generating invite link or configuring bot invite button

hoary cargo
#

i think it might be the case, ik i also asked about this in discord dev server

hoary cargo
crisp hinge
#

Someone told me that slash commands will become global after one hour

slate swan
vale wing
slate swan
#

and it normally doesn't take an hr now :walk:

vale wing
#

:walk:

slate swan
#

:walk:

#

don't blame me, my nitro expired but discord still shows custom emojis on my suggestions

crisp hinge
#

So only option is to reinvite the Bot in every server smh

hoary cargo
vale wing
#

I haven't ever heard about it

hoary cargo
vale wing
#

All bots added to the server before March have the commands scope
So basically all bots that didn't have the scope before it was invented got it automatically from what I understand

#

Do you have MM/DD/YYYY date format or smth

hoary cargo
vale wing
#

Weird

hoary cargo
#

oh, the lang is set on english, US, that's probably the case

#

i sent almost 5 months ago an email to discord support about moving a verified app to a team then they did answer few days ago, it was just clyde and they auto closed the ticked without even helping me whatsoever lmao pepeannoyed discord moment

slate swan
#

thats discord canary

tranquil marsh
#

how do i make my bot reply to any dm with a given prompt from config? And i also need it to be toggable

robust fulcrum
slate swan
#

pog

robust fulcrum
summer flume
#

do anyone know how much time I should wait to be unbanned from discord.py requests?

slate swan
robust fulcrum
summer flume
robust fulcrum
#

Ig not good reason

slate swan
robust fulcrum
#

Ok

#

Go and watch

#

Me do some tricks

summer flume
#

so

slate swan
summer flume
#

let me see

robust fulcrum
summer flume
summer flume
slate swan
slate swan
unkempt canyonBOT
#

Hey @summer flume!

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

slate swan
summer flume
#

ok I will try

slate swan
vale wing
#

Solution 2 is better

slate swan
#
mes = message.content
   if mes.startswith("-google"):
        searchContent = ""
        text = str(message.content).split(' ')
        for i in range(2, len(text)):
            searchContent = searchContent + text[i]

        for j in search(searchContent, tld="co.in", num=1, stop=1, pause=2):
            await message.channel.send(j)

Typeerror: coroutine object is not iterable.

#

in the second for loop

#

Full trace back

#

wwhat

#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#

oh

slate swan
#

search() got an unexpected arguement 'tld'

#

Full traceback and code

#

I’m not Houdini, work with me here

boreal ravine
slate swan
#

The only time someone’s about me section is true

#

Hi all, I was wondering if anyone can help advise.

I am trying to build an embedded multi reaction role post similar to what I currently have through MEE6, but I am not sure what else I need to think about in order to get it to work.

I am not looking for anyone to rewrite my code to a working state, but I would love some guidance in to what I should look into next in order to get it working (and post the message to a specific channel) the code itself is; https://paste.pythondiscord.com/bowawepofe

The Bot does come online after implementing this code, so I can only assume I am missing bits to get it to post this and allow itself to add 1 reaction to the post so users have an emoji to go off, and then I can shut off the MEE6 stuff eventually.

Cheers.

#

!d discord.on_reaction_add

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Reaction.message "discord.Reaction.message").

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
slate swan
#

!d discord.on_raw_reaction_add

unkempt canyonBOT
#

discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
slate swan
#

Read these

#

So I guess I will need to create 2 more bot events and some how point these to my current code cheers.

slate swan
slate swan
slate swan
mossy jacinth
#

How can I make it so my bot sends a Embed with a button below to select channels? And then save that channel selected? Nextcord

slate swan
mossy jacinth
slate swan
#

!d discord.Guild.channels

unkempt canyonBOT
slate swan
#

It returns an iterable that you can put in a for loop

#

!d discord.Guild.text_channels

unkempt canyonBOT
#

property text_channels```
A list of text channels that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
slate swan
#

For only text channels

slate swan
#

            my_mod_role =  interaction.guild.get_role(995338615058079794)
            
            overwrites = {
                interaction.guild.default_role: nextcord.PermissionOverwrite(read_messages=False),
                interaction.user: nextcord.PermissionOverwrite(read_messages=True),
                my_mod_role: nextcord.PermissionOverwrite(read_messages=True)
            }

            channel = await interaction.guild.create_text_channel(f"{interaction.user.name}{interaction.user.discriminator} ticket", overwrites=overwrites)

            tickembed = nextcord.Embed(description=f"**Created Ticket:** {channel.mention}", color=nextcord.Color.blurple())
            await interaction.response.send_message(embed = tickembed, ephemeral=True)
            supportEmbed = nextcord.Embed(title = "Support Ticket!", description="**TEST**", color=nextcord.Color.blurple())
            await channel.send(f"{interaction.user.mention}", embed = supportEmbed, view=view)```

How can I get the interaction.User from here which is within a select dropdown class and then use it in the code below. I dont know how to do this because they are in different classes. If i add in the interaction.User in the code below it reads of the person who clicked it in my case it will be staff but I want this ticket to be locked for the person who clicked the dropdown from above.

    ```@nextcord.ui.button(label=":lock:", style=nextcord.ButtonStyle.primary)
    async def lock(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
        my_mod_role =  interaction.guild.get_role(995338615058079794)
        embed = nextcord.Embed(description="**:lock: Locked the ticket**", color=nextcord.Color.blurple())
        await interaction.response.send_message(embed=embed)
        overwrites = {
            <interaction.user>: nextcord.PermissionOverwrite(read_messages=True, send_messages=False),
            my_mod_role: nextcord.PermissionOverwrite(read_messages=True, send_messages=True)
        }

        await interaction.channel.edit(overwrites=overwrites)```
#

Don’t use nextcord is the best option

slate swan
slate swan
#

It isn’t very clear what you are trying to do

slate swan
#

aa nvm idk how to explain

slate swan
hushed galleon
#

optimally you'll need the view in your ticket to have related information like the user stored in a database

#

for a non-persistent view the easy way would be to add a user_id parameter to your view's init which your lock button can reference

slate swan
#

What is the point of all this discordpy forks 😭😭😭

#

to do something better/different than danny?

#

And what do they do different

#

not give up in the middle of the day and keep developing good shit blobpain

hushed galleon
#

afaik most of the forks spawned because danny discontinued dpy 2.0

#

but then he came back after seeing none of us were able to decide on one fork

slate swan
#

waiting in the shadows to keep the economy going despair

vocal plover
swift pumice
#

hello

#

men

#
async def Geschlecht2(ctx):
    channel = bot.get_channel(985970666643816498)
    message = await channel.send('Was ist dein Geschlecht?(Weiblich)[Reagiere auf die nachricht]')
    await message.add_reaction('♀️')
    role = ctx.guild.get_role(992450008051875930)
    await ctx.author.add_roles(role)


@bot.event
async def on_raw_reaction_add(reaction, user):
    Channel = bot.get_channel(985970666643816498)
    if reaction.message.channel.id != Channel.id:
        return
    if reaction.emoji == "♀️":
        Role = discord.utils.get(user.server.roles, name="Weiblich")
        await user.add_roles(Role)

hi guys i have a problem, it only works for the first reaction how can i fix that?

slate swan
vocal plover
#

I never said it didn't

slate swan
#

Fair

slate swan
swift pumice
#

how can i do that?

slate swan
unkempt canyonBOT
swift pumice
#

how would it look alike in my code?

slate swan
#
intents.reactions = True

client = commands.Bot(command_prefix=',', intents=intents)```
#

I’m on mobile sorry it took a while 😭

worthy fern
#

what I for my part wonder the most is why people actively dicourage the use of a discord.py fork, like why? a monopoly is almost always bad

swift pumice
slate swan
worthy fern
#

you could make the same argument then for react, vue, next, and so one

rain olive
#

just use hikari

hushed galleon
# slate swan ```if self.values[0] == 'Support': my_mod_role = interaction.guild...

to have your lock button know what user it should update the permissions for, you can add a user_id parameter to your view: ```py
class TicketControls(discord.ui.View):
def init(self, user_id: int):
super().init(timeout=None)
self.user_id = user_id

# lock button can update the channel permissions as follows:
# overwrites = {discord.Object(self.user_id): discord.PermissionOverwrite(...),
#               ...}``` but also if you want the view to keep working across restarts you'll need to store both the message and user id in your database, that way you can re-create the views whenever your bot first starts: ```py

during setup_hook() or somewhere similar, add the persistent views

async for message_id, user_id in database.query('SELECT message_id, user_id FROM ticket'):
view = TicketControls(user_id)
bot.add_view(view, message_id=message_id)``` if the persistency stuff is new to you, see the add_view() documentation: https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.add_view
and an example on persistent views: https://github.com/Rapptz/discord.py/blob/master/examples/views/persistent.py

slate swan
#

Doubt anyone has heard of that anyway

rain olive
#

alot of people have, you're living under a rock or something

#

jk, it's lesser known, but that doesn't mean any less

slate swan
#

Looks pretty solid, it’s a nice competitor

rain olive
#

yah, and it's made so that you can choose between different command handlers or make your own easily

slate swan
#

It looks more complicated though

rain olive
#

discord.py is made to be friendly to users new to the library

#

so comparing those 2, hikari is/feels "more complicated"

#

once you get used to it, you get used to it

slate swan
#

You can say that about literally anything though

rain olive
#

ofc u can

mossy jacinth
#

I want my bot to find a channel named fivem-servers and then send a message in there if it was found but it didnt send a message into the channel and there was no error

slate swan
#

channel.send

#

Ctx is a context object

#

Ctx.send just sends to the channel where the command was ran

mossy jacinth
slate swan
#

also use discord.utils.get to get a channel

#

Then channel.send(“message”)

swift pumice
#
async def Geschlecht2(ctx):
    channel = bot.get_channel(988526792602177636)
    message = await channel.send('Was ist dein Geschlecht?(Weiblich)[Reagiere auf die nachricht]')
    await message.add_reaction('♀️')
    role = ctx.guild.get_role(992450008051875930)
    await ctx.author.add_roles(role)


@bot.event
async def on_reaction_add(reaction, user):
    Channel = bot.get_channel(988526792602177636)
    if reaction.message.channel.id != Channel.id:
        return
    if reaction.emoji == "♀️":
        Role = nextcord.utils.get(user.guild.roles, name="Weiblich")
        await user.add_roles(Role)

@bot.command()
async def Geschlecht3(ctx):
    channel = bot.get_channel(988526792602177636)
    message = await channel.send('Was ist dein Geschlecht?(Divers)[Reagiere auf die nachricht]')
    await message.add_reaction('🌈')
    role = ctx.guild.get_role(992450074665811968)
    await ctx.author.add_roles(role)

@bot.event
async def on_reaction_add(reaction, user):
    Channel = bot.get_channel(988526792602177636)
    if reaction.message.channel.id != Channel.id:
        return
    if reaction.emoji == "🌈":
        Role = nextcord.utils.get(user.guild.roles, name="Divers")
        await user.add_roles(Role)``` hi guys i have something really really weird, idk why but only geschlecht3 is working and geschlecht2 isnt. idk why, i double checked everything but it still wont work do u guys have an idea?
slate swan
mossy jacinth
slate swan
#

Also make sure it’s actually getting a channel

hushed galleon
#

the @bot.event decorator only allows one handler to be assigned to each event, but you're trying to assign two at once

#

not sure if you intend for the reactions to only work for a certain period of time, but if so then a better method would be bot.wait_for(event)

#

^ an example of wait_for

swift pumice
hushed galleon
#

oh so persistent reaction roles

swift pumice
hushed galleon
#

forgot you were the same one that asked about it lol

swift pumice
#

lol

swift pumice
hushed galleon
#

you could hardcode the message id into your reaction roles and use a single listener for it, rather than having commands to send new messages to react to

lyric tinsel
hushed galleon
#

dynamically created messages would otherwise require a database to store those messages in

swift pumice
hushed galleon
#

example of hardcoding the message: py @bot.listen('on_raw_reaction_add') async def my_reaction_roles(payload): if payload.message_id != 995689664864342046: return elif payload.emoji == '🌈': await payload.member.add_roles(...)

#

also on_raw_reaction_add / on_raw_reaction_remove will always work after your bot restarts since they dont rely on message cache, but its a bit more inconvenient to work with

vale sierra
#

Hello, i have this error with my code, but i don't know how to resolve it because the indentation is good ```python
import discord
from discord.ext import commands
import aiosqlite
import datetime
import asyncio

class Warn(commands.Cog):
def init(self, bot):
self.bot = bot
bot.db = await aiosqlite.connect("warnData.db")
await asyncio.sleep(3)
async with bot.db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS warn(user INTEGER, guild INTEGER, reason TEXT, time INTEGER)")
await bot.db.commit()

async def addwarn(self, ctx, reason, user):
    async with self.bot.db.cursor() as cursor:
        await cursor.execute("INSERT INTO warnDATA (user, guild, reason, time) VALUES (?, ?, ?, ?)'",(user.id, ctx.guild.id, reason, int(datetime.datetime.now().timestamp())))
    await self.bot.db.commit()

def setup(bot):
bot.add_cog(Warn(bot))

slate swan
paper sluice
swift pumice
#

i might need to learn python again

vale sierra
slate swan
#

startup functions 🚀

slate swan
swift pumice
#

lmao

vale sierra
swift pumice
#

which allows me to use nitro emojis without nitro

paper sluice
# vale sierra how i am suppose to do so ?

don't connect to the db in the __init__ method. Preferably you connect to the db just before the bot starts and then you make the connection a bot variables, or else you can make an async function then call it in the __init__ using asyncio.run

slate swan
#

Delete rn

swift pumice
slate swan
#

Delete that message 🤨🤨🤨

swift pumice
#

ok

paper sluice
slate swan
swift pumice
slate swan
slate swan
paper sluice
slate swan
slate swan
slate swan
outer parcel
#

it says button got unexpected key word

paper sluice
#

!d discord.ButtonStyle.url

unkempt canyonBOT
outer parcel
#

oh for style?

#

style=discord.ButtonStyle.url

slate swan
#
@bot.event
async def on_raw_reaction_add(payload):
    if payload.user_id != bot.user.id and payload.emoji == "🗑️":
        delet_this = await bot.fetch_message(payload.message_id)
        await delet_this.delete() 
#

I uh. I don't understand why it's not going through the if.

paper sluice
outer parcel
#

still error

#

but wheni remove url

#

it says

#

im so confused

outer parcel
paper sluice
#

dont use the decorator

outer parcel
#

how do i add it to my class

paper sluice
#

just do view.add_item(Button(style=discord.ButtonStyle.url, url='...')

outer parcel
#

ok ty

paper sluice
upper belfry
slate swan
#
@bot.command()
async def flip(ctx):
    results = ['Tails','Head']
    rr = random.choice(rr)
    await ctx.channel.send("Flipping a coin 🪙", delete_after=0.9) 
	   async with ctx.typing():
            time.sleep(0.8)
            await ctx.send(f"You got {rr}!") 
slate swan
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

vocal snow
#

also, use asyncio.sleep instead of time.sleep

slate swan
vocal snow
#

i believe so

slate swan
#

same intents

vocal snow
paper sluice
slate swan
cinder horizon
#

slash commands....do dpy got it or any othr module to be imported?

paper sluice
cinder horizon
#

spenks mayte

#

spenks = thenks....dont take me wrong

quartz reef
#

hello. the bot that i'm developing (with discord.py) has a database. Regarding consistency checks (after restart) with e.g. guilds that the bot is no longer connected to or deleted channels whose ids where stored in db, what's the best event handler to use so I can take the data received from Discord and then do all necessary operations? I was considering to use on_ready event, since it's called after receive all information from discord, but this consistency check needs to be before the bot execute some commands that it might receive. ```python

a silly example:

async def on_ready(self):
await db.consistency_check(self.guilds)

#

or should I disabled all commands and after this enable?

paper sluice
#

you shouldn't use on_ready for such things, use setup_hook its made for that

quartz reef
upper belfry
#

is there a difference between ctx.reply and ctx.send

#

?

shrewd apex
paper sluice
shrewd apex
#

this is a send

quartz reef
#

ohh

upper belfry
paper sluice
upper belfry
#

im dumb, thanks

quartz reef
#

just set each command as disabled?

paper sluice
#

commands shouldn't execute before that

quartz reef
#

ahhh ok. thanks

slate swan
#

in fact commands wont even run properly until on ready

#

hi

lilac mica
#

Hello everyone

#

Help me pls

slate swan
grim oar
#

How can we help you

lilac mica
#

I have a bug

#

in my code

grim oar
#

That didnt help bruh

lilac mica
#

Mb

#

Why are my commands not work after i'm adding this event?

grim oar
#

which event

lilac mica
#

on message

#

this is my code

grim oar
#

ah do you have a process_commands

lilac mica
#

what is that

grim oar
#

it processes commands

lilac mica
#

How do i use it

slate swan
#

it got trigger

daring olive
#

@lilac mica please repost without slurs

lilac mica
#

What slur

slate swan
#

bad words

lilac mica
daring olive
lilac mica
#

It's for my moderation features

daring olive
#

I know, replace them with different dummy words before posting on this server

lilac mica
#

Oh

daring olive
#

something like "fuck" is fine though

grim oar
#

I wanna fuck

daring olive
#

any more questions, DM @novel apex

slate swan
#

😱

#

clipped

grim oar
#

Damn.

lilac mica
#

It's not a slur it's just an olld idiom

#

meaning "something important that was not disclosed"

grim oar
#

I kinda agree with lemon

daring olive
#

you yourself are writing code that puts it in a "bad" list though so remove it and other similar slurs before posting next time.

grim oar
#

I think that "something" That wasnt disclosed is potentially a badword, I think that's why the op is deleting that message.

lilac mica
#

I didnt delete

#

This fckn mod deleted it

slate swan
#

u will be banned

grim oar
#

I see

slate swan
#

dont

lilac mica
#

Ok

#

Sorry i wont do it again

paper sluice
#

you should move on, the things you had in that message was offensive, if you believe it or not

slate swan
#

great

grim oar
#

I don't think it was

slate swan
#

let me show u something

vocal snow
grim oar
#

What message

vale wing
#

Imagine swearing 🤬

slate swan
paper sluice
#

move on!!

lilac mica
#

Should i install pycharm ide or visual studio for writing my code ?

vale wing
grim oar
#

Neovim