#discord-bots

1 messages · Page 547 of 1

inner girder
#

Thanks

slate swan
#

in place of "bot.user" if i put certain someone's id it'll respond to only that person?

#

define a variable before using it ..

#

+1

slate swan
#

@slate swan

slate swan
inner girder
#

@slate swan that?

slate swan
#

cool enough ,yes

inner girder
#

Thx m8

slate swan
#

now click on 'Run' in that notebook

#

🥴

inner girder
#

Sure thing

boreal ravine
# inner girder

cant read that paper but its supposed to be bot = commands.Bot(command_prefix=".")

#

hm

#

oh same thing

inner girder
#

Thanks guys!!! It worked

slate swan
#

if i want it to respond to for ex. this id :
704130818339242094

#

how do i

inner girder
wintry shore
slate swan
wintry shore
slate swan
#

oh

#
if message.author.id == the id :
  #do something``` @slate swan
placid skiff
# slate swan oh

By the way to send a DM message the bot and the user must at least share 1 server

slate swan
#

thanks

#
@bot.listen()
async def on_message(message):
  if message.author.id == the id :704130818339242094
    return
  if message.content == 'hi':
    await message.channel.send("Hello!")

is this right?

#

mb

covert palm
#

Hey guys, I have a question I really need help, i want to install a repo but I dont understand how can someone help?

#

I know its not discord related but I ve been trying the past 1 hour

slate swan
#
@bot.listen()
async def on_message(message):
  if message.author.id == 704130818339242094:
    return
  if message.content == 'hi':
    await message.channel.send("Hello!")

what about now

slate swan
slate swan
#

quite sure you'd need git installed for that

covert palm
covert palm
slate swan
covert palm
#

I install go? then make?

#

idk+

slate swan
#

read the repo it has instructions , also i aint a go user neither the channel is related to it so yeah

wintry shore
pliant gulch
#

Those are ephemeral messages, they are only available to send through interaction, i.e application commands, webhooks, and component responses

boreal ravine
#

When you click the button it'll show an ephemeral message

#

weren't you dissing someone earlier for no reason lol

long fog
#

how do u make an help cmd dm e user

boreal ravine
long fog
#

yes

#

if you do ?help it dms the help and doesnt flood chat

boreal ravine
#

yes

#

send the message

long fog
#

how?

boreal ravine
#

to the author of the message

boreal ravine
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
long fog
#

thanks

#

what if its an embed?

boreal ravine
#

same thing

#

.send(embed=embed)

kind radish
#

can these channel permissions be set?

            create_public_threads=False,
            manage_threads=False,
            send_messages_in_threads=False,
            start_activities=False,
            use_external_stickers=False,

I couldn't find the correct (if any) alternatives of these
I am doing this (for more roles too)

        guild = channel.guild

        Muted = discord.utils.get(guild.roles, name="Muted")
        await channel.set_permissions(Muted, add_reactions=False, attach_files=False, connect=False, deafen_members=False, embed_links=False, external_emojis=False, manage_channels=False, manage_messages=False, manage_permissions=False, manage_webhooks=False, mention_everyone=False, move_members=False, mute_members=False, priority_speaker=False, read_message_history=False, request_to_speak=False, send_messages=False, send_tts_messages=False, speak=False, stream=False, use_slash_commands=False, use_voice_activation=False, view_channel=False)```
boreal ravine
#

it's literally a permission

kind radish
# boreal ravine yes

but if i add these in my code, bot throws error
ValueError: no permission called send_messages_in_threads.

boreal ravine
#

!d discord.Thread

unkempt canyonBOT
#

class discord.Thread```
Represents a Discord thread.

x == y Checks if two threads are equal.

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

hash(x) Returns the thread’s hash.

str(x) Returns the thread’s name.

New in version 2.0.
boreal ravine
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
maiden fable
boreal ravine
#

hm

maiden fable
#

Idk I can be wrong too

kind radish
# unkempt canyon

this, permissions, i checked already and couldn't find anything related to thread
gonna check thread now, thank you

lusty swallow
#

!d discord.Permissions.create_public_threads

unkempt canyonBOT
lusty swallow
#

there's supposed to be a thread there

pliant gulch
maiden fable
#

Sec

lusty swallow
boreal ravine
#

use 2.0 its better

lusty swallow
dim cedar
#

hello

#

i need help in making an ascii cmd

pliant gulch
#

Although discord.py has been archived I doubt everyone has moved to v2.0, which is why I was pointing it out

lusty swallow
dim cedar
lusty swallow
dim cedar
lusty swallow
#

what's that

boreal ravine
#

whats ascii

#

just use a lib for that

dim cedar
lusty swallow
#

ohh ascii text

dim cedar
lusty swallow
#

wym?

dim cedar
lusty swallow
#

use code blocks

dim cedar
#

see

lusty swallow
#

!pypi art

unkempt canyonBOT
boreal ravine
#

he used codeblocks

#

you didnt

slate swan
#

`

dim cedar
dim cedar
lusty swallow
#

11111111
messages

11111111
messages
```Difference
slate swan
#

\

dim cedar
#

i understand

#

but how can i make my text in a code block?

boreal ravine
lusty swallow
dim cedar
boreal ravine
lusty swallow
#

yeah in theory

dim cedar
#

ok

final shard
#

For some reason my slash commands dont work

#

The code is okay but it doesn't show on discord.

slate swan
#

global commands take 1-2 hrs to register

lusty swallow
#

add a test guild

#

what module are you using

slate swan
#

try using a test guild thingy

pliant gulch
#

There is also times when it isn't loaded properly on your client

#

If its not a global command, try refreshing your discord client

final shard
#

Wait what are you talking about?

lusty swallow
dim cedar
#

thanks

final shard
#

Can u give example

lusty swallow
final shard
lusty swallow
#

nvm can i see the code that use slash

final shard
#

sure

lusty swallow
#

and all the imports you used

final shard
#
import discord
from discord.ext import commands
from discord.ext.commands import Bot
from discord.ext.commands import has_permissions, MissingPermissions
from discord.ext import commands, tasks
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
from discord import guild

bot = commands.Bot(command_prefix='$', help_command=None)
slash = SlashCommand(bot, sync_commands=True)

@slash.slash(
  name="Slash",
  description="Very First Slash Command of this bot.",
  guild_ids=[751483504767926417]
)

async def slash(ctx:SlashContext):
  await ctx.send("Yay! It works!")
#

Some of the exports arent relevent

#

its for other commands (normal ones)

lusty swallow
#

slash = SlashCommand(bot, sync_commands=True, guild_ids=[751483504767926417]) test this

pliant gulch
#

Did you give your bot the applications.commands scope before actually inviting the bot?

#

As that new scope is required for making slash commands

pliant gulch
#

Ok, so you need to give the bot that scope

final shard
#

oh

pliant gulch
#

And after that if it still doesn't appear try reloading the client

dim cedar
lusty swallow
# final shard where
import discord
from discord.ext import commands
from discord.ext.commands import Bot
from discord.ext.commands import has_permissions, MissingPermissions
from discord.ext import commands, tasks
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
from discord import guild

bot = commands.Bot(command_prefix='$', help_command=None)
slash = SlashCommand(bot, sync_commands=True, guild_ids=[751483504767926417])

@slash.slash(
  name="Slash",
  description="Very First Slash Command of this bot.",
  guild_ids=[751483504767926417]
)

async def slash(ctx:SlashContext):
  await ctx.send("Yay! It works!")
final shard
#

its a error now

#

it says discord_slash isnt found

boreal ravine
lusty swallow
#

did you try the code in the past?

final shard
boreal ravine
#

bru

final shard
lusty swallow
final shard
#

wait ah

#

how should i install it now

lusty swallow
final shard
lusty swallow
#

yeah nvm

final shard
#

its my first time adding a code like this

#

to my original

lusty swallow
#

i advice you use an all-in-one package like disnake

placid skiff
final shard
#

its only the slash

placid skiff
#

If you did you should not be confused on how to use the package

final shard
#

hm

slate swan
#

Code Add-credit

placid skiff
#

The only thing that slash package do is to add Interaction Commands

#

All other things are pretty copied from dpy and similar fork

#

So they're essentially the same

#

If i remember there isn't a way into dpy to check if an user has the premium/nitro
The only thing you can do is to check if he is a booster in a server

boreal ravine
#

do you have intents?

heavy folio
#

yes

boreal ravine
heavy folio
#

all intents are enabled and defined in commands.Bot

dim cedar
#

how can i make a cmd that has spaces

placid skiff
dim cedar
#

like $who is

placid skiff
#

Subcommand

dim cedar
forest delta
#

does anyone know why this happebns

#

happens

heavy folio
#

what happens

forest delta
#

alrdy satisfied

heavy folio
#

yeah cuz u have it installed

placid skiff
#

It means that you have already downloaded the package

forest delta
#

when it wont let me run my bot

heavy folio
#

did u immport it

forest delta
heavy folio
#

nvm

placid skiff
#

In the shell type pip freeze

valid niche
# forest delta

Because pip install discord is the long by now discontinued branch that doesn’t work

forest delta
#

o

valid niche
forest delta
#

ok

#

ok fs it doesnt work idk what ur saying

placid skiff
#

Type pip freeze

valid niche
#

Don’t forget the -u flag

#

That way it updates

forest delta
#

so pip -u install discord.py

heavy folio
#

or just uninstall and install

heavy folio
valid niche
forest delta
#

ok

heavy folio
#
      # checks if member has premium (nitro) or not
      if bool(member.premium_since) is True:
        yourPremiumDate = f"<t:{datetime.timestamp(member.premium_since)}:D>"
      else:
        yourPremiumDate = "None"

      fields = [
        ("Nitro Since", yourPremiumDate)
      ]

      for name, value in fields:
        new_embed.add_field(name=name, value=value, inline=True)
```my friends nitro is active but the bot showed "None" meaning i did not have nitro
did i do something wrong?

also i did ```py
      # checks if member has banner or not
      if bool(member.banner) is True:
        new_embed.set_thumbnail(url=member.banner.url)
      else:
        pass
```on someone who has a profile banner but its not showing
#

yes but u forgot to close the string and bracket

lusty swallow
#

it would probably throw an error. Blank name field

heavy folio
#

") at the back

#

wdym

valid niche
heavy folio
#

then what is it

valid niche
#

Premium since is when they used their boost on the specific server

heavy folio
#

ohh

valid niche
#

!d discord.Member.premium_since

unkempt canyonBOT
#

An aware datetime object that specifies the date and time in UTC when the member used their “Nitro boost” on the guild, if available. This could be None.

placid skiff
#

Told ya

heavy folio
#

on any server or that server where the command was used in?

valid niche
#

Hmm doesn’t work for reasons

placid skiff
#

That server

heavy folio
#

oh okay

placid skiff
#

If the server isn t available it return None

valid niche
heavy folio
pliant gulch
heavy folio
#

nvm got it

valid niche
#

Due to self bot stuff

#

Was hidden a bit in the docs

heavy folio
heavy folio
placid skiff
#

I saw how to do this once but i really can't remember

dim cedar
#

hi

dim cedar
#

i have a problem

heavy folio
#

@valid niche do u know

dim cedar
#

i need help

#
async def Who_is(ctx, person: str):
  personality = person
  info = wikipedia.summary(personality, 1)
  await ctx.send(info)```
#

why this code not work

heavy folio
visual island
heavy folio
dim cedar
heavy folio
visual island
dim cedar
visual island
#

how did you invoke it?

dim cedar
#

=who_is obama

dim cedar
valid niche
#

There is a very important note there

dim cedar
#

😶

valid niche
#

Yes

#

Either create_thread on the channel or on the message

urban shell
#

hey guys, I was wondering if there's a way to make a bot that lets one view the server pfp of a user?

dim cedar
valid niche
urban shell
valid niche
#

I don’t do anything with JavaScript so idk

urban shell
slate swan
#

im trying to make a race command but im getting this error
Command raised an exception: TypeError: 'NoneType' object is not subscriptable

code:

    @commands.command()
    async def race(self, ctx, opponent: discord.Member):
        if opponent == ctx.author:
            await ctx.send("You cannot race yourself!")
        elif opponent.bot:
            await ctx.send("You cannot race bots!")
        elif ctx.author.bot:
            pass
        else:
            
            comp = [Button(label="Drag", custom_id="dragbtn"), Button(label="Drift", custom_id="driftbtn"), Button(label="Street", custom_id="streetbtn")]
            emoji = ["1️⃣","2️⃣","3️⃣"]
            opponent_car = collection.find_one({"discord_id":opponent.id})
            your_car = collection.find_one({"discord_id":ctx.author.id})
            opponent_json = res.get_car(opponent_car["car"])
            your_json = res.get_car(your_car["car"])
            msg = await ctx.send(f"{ctx.author.mention} is racing {opponent.mention}!\nChoose your race type:\n1. Drag\n2. Drift\n3. Street", components=comp)
            interaction = await self.bot.wait_for("button_click",check=lambda inter:inter.author==ctx.author)
            if interaction.custom_id == "dragbtn":
                track = res.get_track("drag")
                await msg.edit(content=f"RACE BETWEEN {ctx.author.name} AND {opponent.name}\nTrack: {track}", components=[])
                await asyncio.sleep(2)
                if your_json["speed_skill"] > opponent_json["speed_skill"]:
                    await msg.edit(content=f"{ctx.author.name} won the race")
                elif your_json["speed_skill"] == opponent_json["speed_skill"]: 
                    await msg.edit(content=f"tied")     
                elif your_json["speed_skill"] < opponent_json["speed_skill"]:
                    await msg.edit(content=f"{opponent.name} won the race")```
#
            if interaction.custom_id == "driftbtn":
                track = res.get_track("drift")
                await msg.edit(content=f"RACE BETWEEN {ctx.author.name} AND {opponent.name}\nTrack: {track}", components=[])
                await asyncio.sleep(2)
                if your_json["drift_skill"] > opponent_json["drift_skill"]:
                    await msg.edit(content=f"{ctx.author.name} won the race")
                elif your_json["drift_skill"] == opponent_json["drift_skill"]: 
                    await msg.edit(content=f"tied")     
                elif your_json["drift_skill"] < opponent_json["drift_skill"]:
                    await msg.edit(content=f"{opponent.name} won the race")
            if interaction.custom_id == "streetbtn":
                track = res.get_track("street")
                await msg.edit(content=f"RACE BETWEEN {ctx.author.name} AND {opponent.name}\nTrack: {track}", components=[])
                await asyncio.sleep(2)
                your_score = your_json["drift_skill"] + your_json["drag_skill"]
                opponent_score = opponent_json["drift_skill"] + opponent_json["drag_skill"]
                if your_score > opponent_score:
                    await msg.edit(content=f"{ctx.author.name} won the race")
                elif your_score < opponent_score:
                    await msg.edit(content=f"{opponent.name} won the race")
                elif your_score == opponent_score:
                    await msg.edit(content=f"tie")```
#

ping me if you found why it gives the err

heavy folio
slate swan
#

i need help

#

don't ask to ask

#

@bot.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.channels, name='channel name here')
await channel.send(f"Hi {member.mention}")

#

it gives me erros

#

what error

#

let me show u

#

yeah

#

this isn't even your code

#

full traceback?

#

or full code

boreal osprey
#

i get this everytime i try to start my bot up

valid niche
# slate swan

you should decide if you want to use either tabs or spaces for indents. You cannot mix and match

slate swan
#

internet problems

valid niche
slate swan
#

restart internet

valid niche
#

most often caused by an outdated OS

slate swan
#

wat

#

well that's a problem then

valid niche
#

when you see that SSL error, the user has to install the SSL certificate

boreal osprey
#

how do u install that

valid niche
#

here is the solution

#

it's pinned here

boreal ravine
#

!d discord.Client.fetch_user

unkempt canyonBOT
#

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

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

Note

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

there's a big note for it in the docs

boreal ravine
dusk pumice
#

how can I send message to every guilds?

slate swan
#

wt

slate swan
boreal ravine
dusk pumice
#

Like when I say "!say [text]"
I want my bot to send text to every guilds

boreal ravine
valid niche
slate swan
#

how can my bot say welcome when a person joins the discord server

boreal ravine
valid niche
dusk pumice
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

the only thing I don't like is the discord.utils.get

boreal ravine
slate swan
#

oh man

#

wrong response

valid niche
#

and for the event to work you must have the members intent

slate swan
#

can u send me the whole code

slate swan
# slate swan i didnt understand
@bot.event
async def on_member_join(member):
    channel = discord.utils.get(member.guild.channels, name='channel name here')
    await channel.send(f"Hi {member.mention}")
valid niche
#

we don't spoonfeed so no

slate swan
#

just like you did

#

the discord.utils.get in this case is kinda dum

#

is 'channel name here' really in your code?

valid niche
#

did you name it client?

slate swan
#

oh so it is copied indeed

slate swan
valid niche
#

then what is your bot/client variable named?

slate swan
#

how did you define commands.Bot?

boreal ravine
#

🗿

slate swan
slate swan
valid niche
slate swan
#

that it threw a different error

slate swan
slate swan
#

does anyone know a purge command

valid niche
unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Examples

Deleting bot’s messages...
valid niche
#

it uses discords own purge

slate swan
#

k

errant shuttle
#

Hey, how do I change my bot's nickname on a certain time?

heavy folio
unkempt canyonBOT
#

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

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
heavy folio
#

use the nick parameter

tawdry perch
heavy folio
#

oh wait

errant shuttle
tawdry perch
#

self.bot.edit(nick="name") should work (if you are on cogs)

slate swan
#

nope

unkempt canyonBOT
#

property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
slate swan
#

this returns the bot as discord.Member object , and you can edit it

waxen palm
#

what

boreal ravine
#

Is custom eval better or jishaku better?

rain olive
#

jishaku is good for debugging, 100% recommended to have it in ur bot

slate swan
#

How do I create a channel that can only be seen by a specified user?

odd walrus
#

possible to add something to command so it executes for 1 hour only?

slate swan
#

how do u uhm make ur bot invite his own bot link

tawdry perch
tawdry perch
odd walrus
#

nah its like i have a command that does while true until specific shit is found in req
but i want it to stop when it reaches a specific time

slate swan
tawdry perch
#

No I can't remember, yes there is a site with permission but nor do I remember that

#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

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

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
tawdry perch
#

hmm

heavy folio
#

anyone has any idea why i got this error ```py
Ignoring exception in command userinfo:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\user\Desktop\theBot\cogs\misc.py", line 204, in userinfo
await before.edit(embed=new_embed, view=self.UserInfo_Button)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\message.py", line 1285, in edit
payload['components'] = view.to_components()
TypeError: to_components() missing 1 required positional argument: 'self'

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

Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 894, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 176, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised

dusk pumice
#

Is my code right?

@bot.event
async def on_member_join(member):
  await member.guild.channel.send("hello")
valid niche
dusk pumice
valid niche
#

you need to tell it WHAT channel to send it to

heavy folio
heavy folio
dusk pumice
dusk pumice
heavy folio
#

discord being dumb not letting classic users have 4000 chars limits catbruh

dusk pumice
#

BRUH

slate swan
#

so I'm asking you what I should do:

  1. start making bots again with normal commands
  2. start using forks (in this case which one)
  3. wait for what happens with dpy
heavy folio
valid niche
heavy folio
# dusk pumice DPY buttons
pip install -U git+https://github.com/Rapptz/discord.py```if u need help with buttons its best to join dpy server lmao
slate swan
#

no I didn't mean creating forks lmao

valid niche
#

we're no fork

slate swan
heavy folio
valid niche
#

it's a rewrite, but someone broke everything and forgot you cannot use circular imports, then pushed to master

#

and forgot to test too

valid niche
slate swan
#

it was joe

valid niche
#

we're making our own wrapper with features

heavy folio
#

dpy is archived already

heavy folio
slate swan
#

I wonder what s6uek's talking about

slate swan
#

but everyone said 2 lmao

#

I hate using unofficial stuff

heavy folio
#

what unofficial

covert igloo
#

It's either that or waiting till one fork separates itself from the rest

heavy folio
#

the only option is forks lmao

covert igloo
#

??

slate swan
#

that's not what happens with dpy...

heavy folio
heavy folio
covert igloo
#

Only requirement is slash commands

#

Im@pretty sure

heavy folio
#

yeah

slate swan
#

but it's only for verified bots innit

covert igloo
#

Wait Fr?

slate swan
#

pretty sure

covert igloo
#

Oh wtf I thought it was for all

valid niche
#

message content will become a priviledged intent in march 2022 and the applications to get this intent recently opened

slate swan
#

applications?

valid niche
#

due to the fact bots below 75 guilds can enable these intents without much fuss, they can do whatever

slate swan
#

do you need discord's allowance for it or smth

valid niche
#

only bigger bots, above 75 guilds, will require slash commands

#

because they need to verify and have a legit use for the intent

pliant gulch
slate swan
#

not discord ruining itself

#

wtf

valid niche
#

it's just another priviledged intent, works just like members and presence

pliant gulch
#

Except this is totally breaking to current commands

merry sleet
#

hi! I am making a lyric bot using genius API (i am using lyricsgenius wrapper) and the code is
@commands.command()
async def lyrics(self, ctx, arg1, arg2):
song = genius.search_song(arg1, arg2)
print(song.lyrics)
gembed = discord.Embed(title=arg1.capitalize(), description=arg2.capitalize())
gembed.add_field(name="Lyrics:", value=song.lyrics)
await ctx.send(embed=gembed)

BUT... this is what i get send (I am using embed to send)

slate swan
#

intents

pliant gulch
#

And not to mention how limited application commands are

slate swan
#

but that's just discord

pliant gulch
#

You can barely do anything cool

slate swan
#

nvm

heavy folio
valid niche
#

a field can only be 1024 characters long

heavy folio
#

oh right got it nvm

slate swan
#

but is this a music bot

merry sleet
#

Is there a way i can split it? and send it into 2 fields?

valid niche
merry sleet
valid niche
heavy folio
valid niche
heavy folio
merry sleet
#

Thank you soo much!

valid niche
#

@merry sleet read this

slate swan
#

I'm gonna choose option 1

#

which is making bots normally

#

option 1 and 3 both

heavy folio
#

because now it says the command doesnt exist

slate swan
#

he's sure af

valid niche
slate swan
#

he's right af

heavy folio
#

the first isnt a command

valid niche
#

or button

#

oh wait i see, i didn't realize that was the view

heavy folio
#
# Define a View that will give us our own personal counter button
class EphemeralCounter(discord.ui.View):
    @discord.ui.button(label='Click', style=discord.ButtonStyle.blurple)
    async def receive(self, button: discord.ui.Button, interaction: discord.Interaction): # remember to pass in self
      
        # ephemeral=True makes the message hidden from everyone except the button presser

        await interaction.user.send('Hello!') # to respond to interaction, do '''await interaction.response.send_message("message", ephemeral=True)'''

@bot.command()
async def button(ctx):
  await ctx.reply("Press!", view=EphemeralCounter())
```this is how it works
#

yeah its a view, not a command

valid niche
#

yeah i know how buttons worked, i just read over it blindly

slate swan
#

why do you use @commands.command() then

boreal ravine
heavy folio
#

its a cog?

slate swan
#

hmm

#

where

heavy folio
#

wdym where

#

i just didnt include the irrelevant parts of my code

slate swan
#

so show the cog part

valid niche
#

also that's the way to make buttons in dpy 2.0

heavy folio
slate swan
#

ok

boreal ravine
#

but it looks messy

valid niche
#

add more whitespace

boreal ravine
#

just put your button classes inside your command

heavy folio
#

oh

valid niche
boreal ravine
slate swan
#

creating a class everytime you call a command

boreal ravine
#

hm

slate swan
#

drakeyea

boreal ravine
valid niche
slate swan
#

be'er

heavy folio
valid niche
# boreal ravine wait what

if you put the class definition in the command, not only do you have a SUPER long function, it also means your class definition is run every time someone uses the command, and the class definition is removed from memory after the command finishes

#

if multiple people run the same command at the same time, you will have the same class definition multiple times in memory

boreal ravine
#

hm

#

good point

valid niche
#

i did notice that in the send_message i didn't do view=self.(view class) but just did view=(view class)

dusk pumice
#

How can I change role name if I have role id?

heavy folio
dusk pumice
#

Please anyone help me

valid niche
heavy folio
#

!d discord.Role.edit

unkempt canyonBOT
#

await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the role.

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

All fields are optional.

Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.

Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead.
dusk pumice
#

Tnx

valid niche
# heavy folio

hm. If you look at the link i sent, at the bottom of the highlighted area you see the send, i did it without self

#

or wait nvm

#

i did self just one line above

heavy folio
valid niche
#

i said nothing

boreal ravine
valid niche
#

@heavy folio what is before?

visual island
valid niche
#

it's not defined anywhere

heavy folio
valid niche
heavy folio
#

then thereafter to edit the message after 1 sec using async io

visual island
#

in c you do it manually, but in python it automatically does that for you

valid niche
heavy folio
#

i didnt copy it into the pastebin

#

i didnt copy lots of irrelevant stuff

valid niche
#

please actually copy it so i can see the full code

heavy folio
#

okay

slate swan
heavy folio
heavy folio
#

its called selects

vocal magnet
valid niche
#

!d discord.ComponentType.select

unkempt canyonBOT
valid niche
#

wait @heavy folio i think i see the error finally

#

you forgot to add parentheses

heavy folio
#

@slate swan you need dpy v2 for that tho py pip install -U git+https://github.com/Rapptz/discord.py

heavy folio
valid niche
heavy folio
#

oh right

slate swan
#

Thanks yall!

heavy folio
#

hold on

valid niche
#

because you need to construct the class

heavy folio
#

yoo it finally works now smh i keep making some careless mistakes

#

@valid niche one more thing, could you help?

valid niche
#

not without a question

dusk pumice
#

How to add role to a bot?

valid niche
boreal ravine
unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
dusk pumice
#

I thought it was not like member

#

Tnx

valid niche
#

look in my example code i send above on how i did buttons, i did something similar where i passed the entire ctx to the View class

#

i send a view like this

        lbview = self.LeaderBoard(self.bot, ctx, page, data)
        lbview.message = await ctx.send(embed=embed, view=lbview)
heavy folio
#

oh

valid niche
#

and made an init

    class LeaderBoard(discord.ui.View):
        def __init__(self, bot, ctx, page, data):
            super().__init__()
            self.bot = bot
            self.ctx = ctx
            self.page = page

            self.timeout = 20
            self.message = None
dusk pumice
#

What's wrong with my code???

await bot.add_roles(get(ctx.guild.roles, name="Bot"))
#

Should I use get_member???

valid niche
#

because bot is your bot class, it's not the actual member

#

guild.me would be the member version of your bot

dusk pumice
#

Okay

valid niche
#

bot doesn't refer to the actual account, it instead is the main part of the code

dusk pumice
#

Hmm... I see

#

I didn't knew that!

#

Tnx

valid niche
unkempt canyonBOT
#

property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
dusk pumice
maiden fable
#

Oh seb. Hi there

valid niche
#

hi hunter

river hollow
#

can someone help me why this isnt working ```from discord.ext import commands

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

message_id = 900116048362221668

@bot.command()
async def react_message(ctx):
message = ctx.channel.get_message(message_id)
await message.add_reaction("👍")

bot.run('token')``` i want if i start the bot it reacts to the message via message ID

maiden fable
#

Cz theres nothing like get messagw

slim whale
#

how i can make a change prefix command?

maiden fable
#

!d discord.TextChannel.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
river hollow
maiden fable
unkempt canyonBOT
#

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

Retrieves the prefix the bot is listening to with the message as a context.
maiden fable
river hollow
#

how

valid niche
maiden fable
#

Just told u...

maiden fable
river hollow
#

message = fetch_message(message_id)

#

@maiden fable ?

maiden fable
#

Breh

valid niche
#

and in your command just change the database entry

maiden fable
#

msg = await ctx.channel.fetch_message(id)

#

Yes

river hollow
#

why isnt this working then

maiden fable
#

Cz u didn't tell it the ID...

river hollow
#

with a variable

maiden fable
#

...

#

Show

river hollow
#
bot = commands.Bot(command_prefix='>')

message_id = 900354407403782154


@bot.command()
async def react_message(ctx):
    msg = await ctx.channel.fetch_message(id)
    await msg.add_reaction("👍")
            

    

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

Then change id to message_id 🤦

river hollow
#

now i did and it is still not working

heavy folio
maiden fable
river hollow
#

it isnt reacting

valid niche
#

did you run your command?

maiden fable
#

Error?

river hollow
river hollow
maiden fable
#

Wait, in which channel is the message present?

#

What if it's not in the current channel?

river hollow
#

or now there is a error

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji```
valid niche
#

yep, you need to run it in the right channel

maiden fable
#
bot = commands.Bot(command_prefix='>')

message_id = 900354407403782154


@bot.command()
async def react_message(ctx):
    msg = await ctx.channel.fetch_message(id)
    await msg.add_reaction("👍")
            

    

bot.run('token')
#

Better. I can't see code without codeblock

heavy folio
#

@river hollow

river hollow
heavy folio
river hollow
#

nothing happens

heavy folio
#

can u just send the error and edited code

river hollow
heavy folio
#

just send the code

river hollow
#

ok

valid niche
#

depends on how it's caused

#

and how you'd like to handle it

heavy folio
#

did you use it in the right channel

#

where the message is

river hollow
valid niche
#

that seems like a coding error and not something for an error handler

#

so the way to handle that error is to fix your code pretty much

slate swan
#

How do I create a channel that can only be seen by a specified user?

valid niche
#

after getting the data verify if it's empty or not

valid niche
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
valid niche
#

as you can see, there's an overwrites kwarg, where you can pass permissions to set

heavy folio
river hollow
#

ok why

heavy folio
#

get the message id and replace it with the old one

#

what why no one can help you without any context

valid niche
#

could you send the code for this? worst case i'd say use a try except, but there should be a "cleaner" method of doing it

river hollow
boreal ravine
valid niche
#

an error handler should idealy only be used for user errors, internal errors are best handled without an error handler

heavy folio
valid niche
#

and which table is expected to be empty?

river hollow
heavy folio
#

wdym you think

valid niche
#

is it async with self.bot.db.execute("SELECT channel_id FROM level_channel WHERE guild_id = ?", (guild_id,)) as cursor:?

river hollow
valid niche
#

the error appears from

            data = await cursor.fetchone()
            channel_id = data[0]
#

fetchone will return None because the table is empty

#

so i would say if data:, if this passes you know there is data, if it fails, you can make an else statement to handle missing entries

heavy folio
river hollow
#

just the code i sended

valid niche
heavy folio
#
---------------------
Ignoring exception in command react:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 167, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:/Users/user/Desktop/theBot/main.py", line 54, in react
    await msg.add_reaction(":thumbsup:")
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\message.py", line 1406, in add_reaction
    await self._state.http.add_reaction(self.channel.id, self.id, emoji)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 335, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji

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

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 894, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 176, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
#

based on your code:```py

message_id = 900388137837166634

@bot.command()
async def react(ctx):
msg = await ctx.channel.fetch_message(message_id)
await msg.add_reaction(":thumbsup:")

valid niche
heavy folio
#

exactly

#

got that from his code

#

^^

boreal ravine
#

its :thumbsup:

valid niche
#

you will need to use the unicode one

#

\👍

#

^ you can copy paste that, that's the unicode version

river hollow
#

ok

#

will try

valid niche
#

very simple site, not ads

boreal ravine
#

or just add a backslash before to a discord emoji

valid niche
#

until you hit search, because then it goes to a different website :p

heavy folio
#

@river hollow are u very certain you dont have an error handler

#

cuz you should be getting the same error as me (unknown emoji)

valid niche
#

you probably want to return in the else statement to block it from running the rest of the code

#

oh also

#

!or

unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
valid niche
#

for this one

slate swan
#

Channel not created
What am I doing wrong?

lament mesa
#

any errors?

merry sleet
#

Hi! i am facing a bit of difficulties here... like i made a Discord bot to import lyrics from genius... IT WORKS FINE BUT AT THE END, I GET THIS 80% OF THE TIME.. how can i fix that?

lament mesa
#

@novel apex is open source

#

@small crown

merry sleet
#

Can enyone help me with that issue?

heavy folio
lament mesa
slate swan
#

i changed the bot prefix , but i need to restart inorder for the changes to apply ? is their a way to avoid it

#
bot = commands.Bot(command_prefix=prefix, intents=intents, owner_id=626127081419571206)
#

here is how i defined my prefix


with open('prefix.json') as fhand:
    x = json.load(fhand)
    prefix = x["prefix"]```
slate swan
#

For example await os.execv(sys.executable, ['python'] + sys.argv)

#

wrong.

slate swan
reef shell
unkempt canyonBOT
slate swan
#

something like that

#

dont share false info please 9ACOSP_pray

slate swan
slate swan
slate swan
heavy folio
boreal ravine
maiden fable
ripe finch
#

i would like to ask for help in programming my bot, it was fine at first, but now it doesnt act on my main commands

boreal ravine
#

error? @ripe finch

ripe finch
#

no, i think there's no error. the @raven peak doesnt work anymore

#

im a beginner in python btw

#

the bot doesnt act on it, or doesnt recognize it idk

slate swan
# slate swan This shit is wrong lmao

its correct bruh , lmao it worked


async def get_pre(bot, message):
  with open('prefix.json') as fhand:
      x = json.load(fhand)
      return x["prefix"]
bot = commands.Bot(command_prefix=get_pre, intents=intents, owner_id=626127081419571206)``` dont try to share false information please or things your not sure of
slate swan
#

folk ?

sick birch
# slate swan

Though I don’t really see why, you could just pass in a list or string to the command_prefix to the bot instance

#

This function is often used for dynamic prefixes

slate swan
#

its used to update the prefix

sick birch
slate swan
#

lmao

sick birch
scarlet fjord
#

@slate swan just use bot.command_prefix = 'command_prefix'

slate swan
scarlet fjord
#

huh?

zenith zinc
#

hii

kindred epoch
scarlet fjord
kindred epoch
#

Huh?

kindred epoch
scarlet fjord
#

so you can have everything up until the point u need to restart, then in ur code just have bot.command_prefix = 'command_prefix' and that will change the prefix the bot is listening for to that new prefix

#

and you dont have to restart anything

kindred epoch
#

Isn't that what I just said in 7 words?

#

You need to restart ur bot in order for the new changes to apply

scarlet fjord
#

no. u dont

toxic wharf
#

how can i do loop every 30 seconds?

kindred epoch
scarlet fjord
#

in mine the bot doesnt restart at all

#

it just updates what prefix the bot is listening for

fluid shadow
#

Does anyone know how to host your bot 24/7 without using heruko or having a tab open?

fluid shadow
#

ya

fluid shadow
#

Free?

brazen raft
#

Free.

#

It's free if you want it to be free.

fluid shadow
#

Well ofc

#

How would I connect my replit script to it tho

brazen raft
#

You can ssh and copy the files to it

#

It worked for me

slate swan
#

you can download you repl project

#

and upload it

mild lance
#
    notbot = member.id != bot.user.id```
#

AttributeError: 'NoneType' object has no attribute 'id'

slate swan
mild lance
#

someone can help me with that

#

?

zenith zinc
# fluid shadow **Does anyone know how to host your bot 24/7 without using heruko or having a ta...

#Discord #FreeHosting #BotHosting

Website: https://cubichosting.xyz
Discord: https://discord.gg/73Cx8yfvaR

Cubic Hosting is a free Discord Bot Hosting company that allows you to host Javascript, Python, Java, Go, and more scripts. All files you upload are private and can only be accessed by you or an administrator (don't worry, they won't peak...

▶ Play video
#

use this

slate swan
slate swan
#

Also those specs look almost identical to heroku's, but on heroku you don't have to "afk" on some shitty page so heroku > that host including any other "afk" page host

slate swan
#

It's not invalid syntax

kindred epoch
#

So ur saying you don't need to restart ur bot in order for new changes to apply?

mild lance
#

notbot = member.id != self.bot.user.id

#

'NoneType' object has no attribute 'id' and i have this error

slate swan
#

You've literally just been answered

mild lance
#

?

slate swan
kindred epoch
#

😂

mild lance
#

so how i get it syntax

slate swan
#

??

#

Your "member" is None

#

I have no clue where you defined it so I can't help

mild lance
#

member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members)

slate swan
#

Although you should be expected to fix this yourself since it's a basic python error

mild lance
#

this is my member

slate swan
mild lance
#

yes

#
    @commands.Cog.listener()
    async def on_raw_reaction_add(self, payload):
        guild = self.bot.get_guild(744705734566084619)
        if guild:
            message_id = payload.message_id
            guild_id = payload.guild_id
            member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members)
            channel1 = self.bot.get_channel(payload.channel_id)
            message = await channel1.fetch_message(payload.message_id)
            data = cogs._json.read_json("setupdata")
            notbot = member.id != self.bot.user.id
            channel3 = await self.bot.fetch_channel(payload.channel_id)
            chekchannel = channel3.name.startswith("verification")
            if chekchannel:
                if payload.emoji.name == '✅' and notbot:
                    if str(member.name) in data and str(member.id) in data:
                        name = data[str(member.id)]
                        char = data[str(member.name)]
                        steam = data[str(member.mention)]```
#

not this

#

sorry my miss

slate swan
#

It returns None because the member isn't in the guild then

#

Check the guild's id and check your intents

mild lance
#
   @commands.Cog.listener()
    async def on_raw_reaction_add(self, payload):
        message_id = payload.message_id
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id == guild_id, self.bot.guilds)
        member = discord.utils.find(
            lambda m: m.id == payload.user_id, guild.members)
        role = discord.utils.find(lambda r: r.name == 'Moderator', guild.roles)
        role2 = discord.utils.find(lambda r: r.name == 'Sale Team', guild.roles)
        notbot = member.id != self.bot.user.id
        if payload.emoji.name == '📨' and notbot:
            overwrites = {
                guild.default_role: discord.PermissionOverwrite(read_messages=False),
                guild.me: discord.PermissionOverwrite(read_messages=True),
                member: discord.PermissionOverwrite(read_messages=True, send_messages=True, attach_files=True),
                role: discord.PermissionOverwrite(read_messages=True),
                role2: discord.PermissionOverwrite(read_messages=True)
            }


slate swan
#

Do you have intents

mild lance
#

what do you mean

slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

mild lance
#

its need to be a ticket system

#

import discord
from discord.ext import commands
import random
import datetime
import time
import platform
import asyncio
import json
from pathlib import Path
from discord.utils import get

import cogs._json

slate swan
mild lance
#

look at this, it the all code

slate swan
#

Dude

slate swan
dusk dust
#

i want to edit an embed when the user reacted the message... how can i do this with a conditional?

slate swan
dusk dust
#

ok

mild lance
#

so what to do please help meee

slate swan
#

🤦‍♂️

slate swan
# unkempt canyon

Go to your main.py file, add this piece of code, then go to dev portal in your bot and go to "bot" and then enable the intents

#

When a user joins a server, I want to know how to create a channel dedicated to that person.

#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
slate swan
#

Using this on member.guild

#

Thank you very much. Can you also tell me more about how to set permissions?

dusk dust
slate swan
#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

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

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
slate swan
#

^ overwrites

slate swan
#

How does a reaction stay in or out of a var what

dusk dust
# slate swan ?

the message it's an embed and i typed this to the bot add reaction on message... i put this text in or out of the var?

slate swan
#

It looks good so far

#

Can we host from our own ip address if yes how

slate swan
#

I am on android

#

I doubt you can host on mobile

#

Even if you can your battery will die most likely in 2-3h

#

Not recommended

dusk dust
slate swan
#

No what I meant is your Message object had to be in a var, which is what you're doing there, so it's good so far

dusk dust
#

ok

slate swan
dusk dust
#

i create a conditional like that?: if message.reaction == '⚙️': ....

boreal ravine
#

@slate swan indents

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

toxic wharf
#

what should i change

slate swan
toxic wharf
toxic wharf
#

first line in my code

slate swan
toxic wharf
slate swan
#

replace tasks.run(...) with check_voice.start()

toxic wharf
#

thank you

slate swan
#

yw

#

Channel created, but permissions not overridden

#

help me

fallow mauve
#

making music bot, and it says there's an error at "youtube" whats wrong here?

#

pls ping for feedback

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)
toxic wharf
fallow mauve
slate swan
# toxic wharf

yeah that's because a User object doesn't have a status

toxic wharf
maiden fable
slate swan
#

get guild, get member from guild

maiden fable
#

Oh nvm

toxic wharf
#

and get his status

slate swan
maiden fable
#

Never knew that 😐

slate swan
maiden fable
#

Weird tbh

slate swan
#

discord limitation probably

errant shuttle
#

Hey, so I made a change prefix command but I also have a "help on command" command and there is this field called usage and it sends something like this for now: e> ping. So I want it to send like this. {your server prefix} ping
So here is my code currently
The change prefix command

def get_prefix(client, message):
    with open('modules/prefixes.json', "r") as prefix_file:
        prefixes = json.load(prefix_file)

    return prefixes[str(message.guild.id)]
client = commands.Bot(
    command_prefix=get_prefix,
    strip_after_prefix=True,
    case_insensitive=True,
)
@client.event
async def on_guild_join(guild):
    with open('modules/prefixes.json', "r") as prefix_file:
        prefixes = json.load(prefix_file)

    prefixes[str(guild.id)] = 'e>'

    with open('prefixes.json', 'w') as prefix_file:
        json.dump(prefixes, prefix_file, indent = 4)
@client.event
async def on_guild_remove(guild):
    with open('modules/prefixes.json', "r") as prefix_file:
        prefixes = json.load(prefix_file)

    prefixes.pop(str(guild.id))

    with open('prefixes.json', 'w') as prefix_file:
        json.dump(prefixes, prefix_file, indent = 4)
@client.command(aliases = ['newprefix', 'prefix', 'makeprefix', 'makenewprefix', 'setprefix'])
async def changeprefix(ctx, prefix = "e>"):
    if ctx.message.author.guild_permissions.administrator or ctx.message.author.guild_permissions.manage_guild:
        with open('modules/prefixes.json', "r") as prefix_file:
            prefixes = json.load(prefix_file)

        prefixes[str(ctx.guild.id)] = prefix

        with open('modules/prefixes.json', 'w') as prefix_file:
            json.dump(prefixes, prefix_file, indent = 4)
        
        await ctx.reply(f"Prefix successfully changed to `{prefix}`")
    else:
        await ctx.reply("You don't have the permission `manage server`")

wait dont read this now

maiden fable
slate swan
#

User.status was never a thing nor in dpy nor in any fork

maiden fable
slate swan
#

¯_(ツ)_/¯

toxic wharf
slate swan
slate swan
unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
slate swan
#

it's supposed to be a kwarg not an arg

#

The channel settings are not overwritten. What should I do?

chrome bloom
#

I'm probably better off asking here, how would I go about creating a queue for audio when another user request another audio source?

@commands.command()
async def play(self, ctx, sound):
    if ctx.author.voice is None:
        await ctx.send("Please connect bot to voice channel first!")
        else:
            if ctx.voice_client.is_playing():
        ctx.voice_client.stop()
        source = <folder from pc>
                vc.play(source)
                while vc.is_playing():
                    await sleep(4)
                    if vc.is_paused:
                        return
                    else:
                        await vc.disconnect()```
 I've tried 
```py
class music(commands.Cog):
    def __init__(self, client):
        self.client = client
        self.queue = []

    @commands.command()
    async def play(self, ctx, sound):
        if ctx.author.voice is None:
            await ctx.send("Please connect bot to voice channel first!")
        else:
            if ctx.voice_client.is_playing():
                print("DEBUG: ")
                (self.queue).append[url]
                print(*self.queue, sep="\n")```But it gets as far as the DEBUG:  line and doesn't print the queue list, which probably means it's not adding
errant shuttle
#

hey, in the role command, how do i set up permissions?

fallow mauve
#

i can use yt videos for my music bot as long as its only for one server right? like a private bot

fallow mauve
#

k nice, good to know im not doing smth illegal 👍

sick birch
#

You prolly shouldn’t but YouTube doesn’t care

sick birch
fallow mauve
#

ok

#

well if they want me to stop they can ask me themselves

slate swan
#

one database and create multiple tables for all your data

#

why would you even consider using multiple different databases

#

¯_(ツ)_/¯

zenith zinc
#

how to set in activity bot.guilds.count

#

?

placid skiff
#

That's a simple answer for that
If you will host your bot, more database you have more you have to pay
Hosting provider don't make you pay how many storage you use, they make you pay how many storage you take

zenith zinc
# placid skiff That's a simple answer for that If you will host your bot, more database you hav...

not pay bro https://youtu.be/_5bUAfr0Uyk this is a free

#Discord #FreeHosting #BotHosting

Website: https://cubichosting.xyz
Discord: https://discord.gg/73Cx8yfvaR

Cubic Hosting is a free Discord Bot Hosting company that allows you to host Javascript, Python, Java, Go, and more scripts. All files you upload are private and can only be accessed by you or an administrator (don't worry, they won't peak...

▶ Play video
placid skiff
#

Please bro they are the worst for hosting anything
Check the pinned message in this channel, they'll explain you why

valid niche
#

free hosting doesn't really exist

#

i doubt that host is any good

zenith zinc
#

i`m host of this tutorial broo

valid niche
#

that thumbnail already says enough

#

a VPS costs less than a cup of coffee a month

zenith zinc
#

bro

#

help me

#

i need help

#

how change bot guilds count in activity?

valid niche
#

!d discord.Client.change_presence

unkempt canyonBOT
#

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

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
placid skiff
zenith zinc
valid niche
smoky portal
#

How can I get a list of everyone with a role?

valid niche
#

everyone always has 1 role, the @ everyone role, if they have 2 or more roles, so len(roles) > 1, you can add them to the list

slate swan
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: not enough values to unpack (expected 2, got 1) https://pastebin.com/j8Ajzfe1

placid skiff
#

Line?

valid niche
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

placid skiff
slate swan
#
not enough values to unpack (expected 2, got 1)
  File "/run/user/1000/gvfs/smb-share:server=pythonbot.local,share=techmoboxer/techmobot.py", line 108, in unban
    member_name, member_discriminator = member.split('#')
  File "/run/user/1000/gvfs/smb-share:server=pythonbot.local,share=techmoboxer/techmobot.py", line 141, in <module>
    bot.run("")``` full code https://pastebin.com/6xv4b7tD
valid niche
placid skiff
#

Oh so that's lol

valid niche
#

because a member isn't just a name, a member is a full member object

#

so if you try to split it, there is no literal string to split it on

#

you want to get str(member).split()

placid skiff
#

Bro member is just a string in that case i checked the code

#

He is trying two assign two values with 1 assignement

valid niche
#

oh yeah i see

#

it's not typehinted/converted

placid skiff
valid niche
#

assuming that split returns at least 2 values

slate swan
#

from member_name, member_discriminator = member.split('#') to member_name, member_discriminator = str(member).split()?

valid niche
#

!e

l = ["a", "b"]
a, b = l
print(a)
print(b)
placid skiff
#

Lol

valid niche
#

okay srsly? what's wrong with this?

unkempt canyonBOT
#

@valid niche :white_check_mark: Your eval job has completed with return code 0.

001 | a
002 | b
valid niche
#

there

placid skiff
#

!e

string = "abc def"
a, b = string.split()

print(f"{a} {b}")
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

abc def
placid skiff
#

Uhm so i think that it really convert member to a member object

#

It can do it automatically? I always used converters when declared commands lol

slate swan
#

!e

for i in range(30):
print("loop?")```
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print("loop?")
003 |     ^
004 | IndentationError: expected an indented block after 'for' statement on line 1
slate swan
#

k

valid niche
#

but you can convert to a discord.User and work from there

#
@bot.command()
async def foo(ctx, user: discord.User):
#

i would add a space between the comma and user, just makes it more readable

#

also it's discord.User, capitalized U

#

also if you want it to work with multiple members, you will need to typehint to a list of discord.User, so

async def foo(ctx, users: commands.Greedy[typing.Union[discord.User, discord.Object]])
#

afaik that should work in d.py

#

it should auto convert

hasty iron
#

List doesnt work

#

its commands.Greedy

valid niche
#

ah yeah greedy

proud glade
hasty iron
#

Object if you have the id

#

and want to avoid API calls

proud glade
#

i mean, discord.User won't work unless the bot shares another server with that user

#

pretty sure it works for anything yeah