#discord-bots

1 messages · Page 459 of 1

slate swan
#

oh

boreal osprey
hasty iron
#

now both the event and the command are inside a command

#

please pay attention to your indents

slate swan
#

it's inside a command

boreal osprey
#

i

slate swan
boreal osprey
#

ok

#

i wanna smash everything for not looking at indents

slate swan
#

that hecc command lmao

#

make sure you're not getting rate limited

hasty iron
#

that command is a literal RuntimeWarning inc

boreal osprey
#

lmfao

#

i mean

hasty iron
#

you didn’t await all of the asyncio.sleeps

#

so it doesn’t sleep

boreal osprey
boreal osprey
hasty iron
#

well its just gonna raise you a ton of warnings in your console

slate swan
boreal osprey
#

Anyways POGGGG

slate swan
#

on every command

#

also, since it's one of the biggest bots ever, the devs have probably asked discord for some priority

boreal osprey
#

K i actually added await to asyncio

honest ermine
#

Hi, so I have a bot with some commands, nothing too fancy. One thing I wanted to to is that, after certain command, my bot would be able to answer messages that contains certain words. In order to do this, I defined the on_message behaviour, but now none of my commands works.

pure reef
#

discord components help ?

brisk fiber
#

no worries!

patent lark
unkempt canyonBOT
#

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

This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.

By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.

This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
patent lark
#

you need to add await bot.process_commands(message) in your on_message event

pure reef
#
interaction = await bot.wait_for("select_option")
    label = interaction.component[0].label
    if label == "Moderation":
        await interaction.respond(
              ephemeral=True,
              embed=embed1
        )
``` wont woork
lofty heron
#

hi, why does the error handler return in console instead of sending a message? i'm really confused lol

boreal ravine
#

@lofty heron The params

#

Look at it

patent lark
#

you wrote that incorrectly

should be: if isinstance(error, commands.CommandOnCooldown

also, on_command_error takes error and ctx parameters. when here, you put self, ctx

boreal ravine
#

why is there self it isnt even in a class

patent lark
#

yeah im wondering that too

covert igloo
#

@patent lark hey can i dm u

patent lark
#

sure

pure reef
#

does anyone know how to send embeds using discord components

glacial echo
reef shell
patent lark
#

okay.

royal zenith
#

how tf do i fix this

#
@bot.command()
async def about(ctx):
    embed = discord.Embed(
        title = 'About Me',
        description = 'This bot was developed by syskey.exe#9999',
        color = discord.Color.red()
    )
    embed.set_footer(text=f'Requested by  = {ctx.author}', icon_url=ctx.author.avatar_url)
    embed.add_field("Hey, wassup, my name is Kuno and im here to make your discord server better and make your life easier lol")
    await ctx.send(embed=embed)
#

this is the code

granite prawn
#
@client.event
async def on_raw_reaction_remove(payload):
  print(payload.user_id)
  guild = client.get_guild(payload.guild_id)
  member = discord.utils.get(guild.members, id=payload.user_id)

i remove a reaction and member is none, how and why is this happening

slate swan
#

yeah this just does not work


@tasks.loop(seconds=5)
async def change_status():
    channel = Bot.get_channel(id)
    await channel.send(f"{random.choice(thoughts)}")
vagrant brook
slate swan
#

i think

vagrant brook
#

Are you sure

slate swan
#

Bot = commands.Bot(command_prefix="v!")

vagrant brook
#

Oh

#

Try printing channel

granite prawn
slate swan
vagrant brook
#

print(channel)

#

To see if it's None

slate swan
#

ok

granite prawn
#

i need member to be a member object of whoever unreacted it

slate swan
# vagrant brook To see if it's None
@tasks.loop(hours=1)
async def change_status():
    channel = Bot.get_channel(735715319783489580)
    print(735715319783489580)
    await Bot.channel.send(f"{random.choice(thoughts)}")```
#

so like this

vagrant brook
#

oh god

#

Not the ID

#

the channel object

#

Also what is Bot.channel

slate swan
#

im a bit special

slate swan
#

should it be

 await ctx.send(f"{random.choice(thoughts}")```
vagrant brook
#

ctx doesn't even exist

slate swan
#

im a idiot

vagrant brook
#

!d discord.TextChannel.send

unkempt canyonBOT
#

await send(content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=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/stable/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/stable/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
vagrant brook
#

So,

#

send from the channel you fetched by doing get_channel earlier

slate swan
#

ok imma try that

slate swan
# royal zenith ```py @bot.command() async def about(ctx): embed = discord.Embed( ti...

try this and make sure to use ```py
from discord.ext import Embed

```py
@bot.command()
async def About(ctx):
    embed = Embed(title="About me", description="This bot was developed by syskey.exe#9999")
    embed.add_field("Hey, wassup, my name is Kuno and im here to make your discord server better and make your life easier lol", inline=False)
    embed.set_footer(text=f'Requested by  = {ctx.author}', icon_url=ctx.author.avatar_url)
    await ctx.send(embed=embed)
slate swan
#

bruh

#

!d discord.Message.reactions

unkempt canyonBOT
slate swan
#

That does not help wtf

broken turtle
#

!id

#

whats the code something like this
if user id=discord id here

#
@bot.command(aliases=['bc'])
@commands.has_permissions(manage_messages = True)
async def botclear(ctx,amount=100):
    await ctx.channel.purge(limit = amount)
    await ctx.send( f'{ctx.author.mention} cleared bot messages')

i want to make it so only the messages of bots gets cleared

maiden fable
#

male a check

#

Make*

broken turtle
#

im thinking of useing discord ids

#

but i dont know how

maiden fable
#

message.author == bot.user

thorny current
#

Can some one tell me what's the complete command to instanl pip install discord new version

thorny current
maiden fable
#

Yea

thorny current
#

Tysm

broken turtle
#

i want my bot to only delete bot messages

maiden fable
#

Your bot's messages or what?

vagrant brook
#

!d discord.TextChannel.purge there's a check kwarg

unkempt canyonBOT
#

await purge(*, limit=100, check=None, 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/stable/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own (unless you are a user account). The [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Internally, this employs a different number of strategies depending on the conditions met such as if a bulk delete is possible or if the account is a user bot or not.

Examples

Deleting bot’s messages
hoary gust
#

Guys is there any module to make a youtube video notifier?

maiden fable
#

I don't think so

hoary gust
#

@maiden fable well it is not breaking the tos of yt right?

vagrant galleon
#
@client.command()
async def test(ctx):
    global headers
    s = requests.Session()
    id_list = [int(123), int(1234), int(12345), int(12344), int(222234), int(1234234)]
    for _id in id_list:
        r = s.get(f'https://example.com/{_id}', headers=headers)
        res = r.json()
        
        for doc in res:
            name = doc['name']
            due = doc['due_at']
            
            if due == None:
                print(f'{name} -- {due}')
            else:
                example = due
                actual_date = example.strip('Z')
                d = datetime.datetime.fromisoformat(actual_date)
                due_date = d.strftime('%Y-%m-%d')
                webhook = DiscordWebhook(url='https://discord.com/api/webhooks', username='test')
                embed = DiscordEmbed(title='test', description=f'\n{name}\n{due_date}', color='0xffffff')
                embed.set_author(name="test")
                embed.set_timestamp()
                webhook.add_embed(embed)
                webhook.execute()
                time.sleep(0.5)```
yo how do i make it just send one big webhook instead of each individual item within the webhook
thorny current
#

Mine (embed=embed) showing some problem

boreal ravine
twilit adder
#

how do you do this?

thorny current
boreal ravine
twilit adder
#

OH ty

boreal ravine
twilit adder
boreal ravine
twilit adder
#

???

boreal ravine
boreal ravine
thorny current
#
@bot.command()
async def About(ctx):
    embed = Embed(title="About me", description="This bot was developed by Roboleon")
    embed.add_field("Hey, wassup, my name is Piro Bot. Im here to make your discord server better and make your life cool in this app ", inline=False)
    embed.set_footer(text=f'Requested by  = {ctx.author}', icon_url=ctx.author.avatar_url)
    await ctx.send(embed=embed)
boreal ravine
#

O

twilit adder
#
@bot.command()
async def About(ctx):
    embed = discord.Embed(title="About me", description="This bot was developed by Roboleon")
    embed.add_field("Hey, wassup, my name is Piro Bot. Im here to make your discord server better and make your life cool in this app ", inline=False)
    embed.set_footer(text=f'Requested by  = {ctx.author}', icon_url=ctx.author.avatar_url)
    await ctx.send(embed=embed)
boreal ravine
#

o

elder python
#

after adding a cog to Cogs what to do

thorny current
#

thinkmon copy that?

elder python
#

it says command not found

boreal ravine
twilit adder
thorny current
#

Ok

boreal ravine
unkempt canyonBOT
#

class discord.Embed(**kwargs)```
Represents a Discord embed.

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

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty").

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

what shld my init file contain

boreal ravine
#

you seen you only did embed=Embed and not embed=discord.Embed

boreal ravine
#

Maybe you forgot to indent the commands?

thorny current
#

Yea worked

sick talon
#

Hey hi,
Can anyone help me out with making a VC alert command

About the command -
If a member joins a VC then the bot would send a message to send a message in channel and after every x hours the bot would ask to the member to send some message in the same channel

elder python
# boreal ravine Show me the code

from discord.ext import commands


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


class Moderation(commands.Cog):
    def __init__(self, bot) -> None:
        self.bot = bot
        super().__init__()

    @commands.command
    @commands.has_permissions(manage_messages=True)
    async def purge(self, ctx, amount=10):
        if amount.isnumeric():
            amount = int(amount)
        else:
            amount = 10

        if amount <= 0 or amount >= 101:
            await ctx.send("enter an integer within range 0-100")
        else:
            await ctx.channel.purge(limit=amount)


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


bot.run('token')
boreal ravine
thorny current
#

Now it's showing problem in from discord.ext import embed

elder python
#

oh

boreal ravine
#

remove that

#

just import discord

thorny current
#

Ohk

elder python
boreal ravine
elder python
#

idk i saw the docs and did that

boreal ravine
elder python
#

oh

boreal ravine
elder python
#

so you where you put the token?

hoary gust
boreal ravine
elder python
#

oh

#

even the prefix?

boreal ravine
#

yes

elder python
#

thabks

maiden fable
unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
lone aurora
#
@client.event
async def on_member_join(member):
    channel = client.get_channel(876172211646504980)
    role = discord.utils.get(member.guild.roles, name='Member')


    embed = discord.Embed(
    title = '',
    description = '',
    colour = blue
        
    )
    embed.set_footer(text='By oSeatch#6969')
    embed.add_field(name='Welcome!', value='Has joined the server!', inline=False)

    await channel.send(embed)
    await member.add_roles(role)``` can someone tell me where im going wrong
#

its giving me this

#

did someone say something i didnt notice

blazing beacon
#

I did but it was wrong

#

Did you import blue from discord.Colors?

lone aurora
#

oh wait that might be what i missed

#

dumb mistake but then again im dumb

blazing beacon
#

Nah, dw

#

Its common to be missing a few imoortd

lone aurora
#
@client.event
async def on_member_join(member):
    channel = client.get_channel(876172211646504980)
    role = discord.utils.get(member.guild.roles, name='Member')


    embed = discord.Embed(
    title = '',
    description = '',
    colour = discord.Colour.random
        
    )
    embed.set_footer(text='By oSeatch#6969')
    embed.add_field(name='Welcome!', value=f'{member.mention} Has joined the server!', inline=False)

    await channel.send(embed)
    await member.add_roles(role)``` changed it to this.. still not working
hoary gust
#

@maiden fable can u plz help me

nocturne lake
#

colour = discord.Colour.random()

lone aurora
#
TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.``` getting this error
nocturne lake
#

.random() is a function

maiden fable
lone aurora
#

whaa ok i am try

hoary gust
#

@maiden fable do u know any event that can trigger the bot to send a msg but that event is not related to any member or roles or guild

slate swan
#

command?

#

or on_message

hoary gust
#

@slate swan not cmd nor on_msg

maiden fable
#

Or task

hoary gust
#

@maiden fable maybe

slate swan
#

task is for repetition

slate swan
maiden fable
lone aurora
#

well its working now but umm

waxen granite
#

channelList= self.ytData[guild]['ytchannels'] channelList.append(channellink)
Dict obj has not attribute append

lone aurora
hoary gust
#

I am trying to make a youtube notifier, like whenever someone uploads a video it will send a msg but which event will it use to send that I mean how can I makee it msg at that time @slate swan

lone aurora
waxen granite
#

embed = embed

lone aurora
#

oh

#

icic thankoo

slate swan
slate swan
#

to append to a dict you can just use dict['key'] = 'value' no?

waxen granite
#

What does dict stands here according to my code?

granite prawn
#
  File "main.py", line 55, in on_raw_reaction_remove
    await member.remove_roles(role)
AttributeError: 'User' object has no attribute 'remove_roles'

how does it happen, i got the variable member with a client.fetch_user

slate swan
thorny current
#

Some problem here

slate swan
thorny current
granite prawn
slate swan
#

not afaik
get the guild then the member from the guild
you need intents

waxen granite
hoary gust
#

Guys is there any module that can search for videos using the channel id in YouTube

waxen granite
#

But not that guildone

granite prawn
#

member = await client.get_guild(885320179251290152).get_user(payload.user_id)
since i only want it to work in one server it should work?

hoary gust
#

Guys is there any module that can search for videos using the channel id in YouTube

stiff nexus
#

how do i get the guilds total emoji limit??

stiff nexus
slate swan
slate swan
#

doesnt say anything in the docs

stiff nexus
#

then?

slate swan
#

then just multiply the limit by 2 and you get the total limit?

reef shell
#

If i add slash commands to my bot will it be autimatically registered in the existing servers that my bot is already in?

waxen granite
thorny current
#

The value thingy didn't got

waxen granite
#

how doi get the names of the members as a list from a msg reactions?

hoary gust
#

@waxen granite how will I get the videos I am getting mad lol

waxen granite
slate swan
slate swan
hoary gust
#

@slate swan can u help me with the api

#

I am very much confused

#

How to use it to get the videos with the channel id

slate swan
#

You just need to register an API key on developer page of google and make requests using it

#

Idk if any wrapper exists or not

hoary gust
#

@slate swan ok but how

hoary gust
slate swan
#

Read the docs I shared and find the proper endpoint.
Prepare the data it asks for and send it along the request.
Send the authorization token in headers like {'Authorization': 'Bearer oauth_key'}

hoary gust
#

Ah I am getting confused

slate swan
#

blobpain Some API stuff, you need to learn rest apis and stuff to understand this

#

I recommend continue finding some wrapper

hoary gust
#

@slate swan request module will work here?

slate swan
#

aiohttp

#

if in a discord bot

#

else any http wrapper works

hoary gust
#

@slate swan I am searching this for my discord bot so what should I use

#

Request or aiohttp

#

?????????????????????

slate swan
#

Aiohttp

waxen granite
#

How to count role position according to role hierarchy?

hoary gust
#

Aiohttp will make request to the api ?@slate swan

slate swan
#

!d discord.Role.position

unkempt canyonBOT
#

The position of the role. This number is usually positive. The bottom role has a position of 0.

slate swan
waxen granite
slate swan
#

it won't work like ```py
aiohttp.get_youtube...

hoary gust
#

Ok

#

@slate swan so how?

#

How can I make it search for youtube vids 🤯

slate swan
#

does anyone know how i would go about making a user phone command in discord.py? i allready have my own userphone but it uses dictionarys and if two people do the function to call or ring at the same time it does a error where the data changed while it was changing

#

I can't explain whole API stuff rn notlikeblob
You can search on google how to make requests and use api

hoary gust
#

O_o

slate swan
#

!e ```py
x = [1, 2, 4]
x.reverse()
print(x)

unkempt canyonBOT
#

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

[4, 2, 1]
slate swan
#

!e

x = [1,2,3]
print(x[::-1])
unkempt canyonBOT
#

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

[3, 2, 1]
slate swan
#

And then index it

#

You can't internally change the position

granite prawn
#
@client.event
async def on_raw_reaction_remove(payload):
  member = client.get_guild(payload.guild_id)
  member = member.get_member(payload.user_id)
  print(type(member)

why does it print None

slate swan
#

!d discord.on_raw_reaction_remove

unkempt canyonBOT
#

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

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

ok ill google how to enable it

slate swan
waxen granite
#

***how doi get the names of the members as a list from a msg reactions?***

granite prawn
#

but yea i did put it

#

how to enable intents.reactions tho

waxen granite
granite prawn
slate swan
#

intents = discord.Intents.default()
intents.reactions = True
client = commands.Bot(command_prefix = get_prefix, intents=intents)

#

remove the get_prefix

waxen granite
granite prawn
#

tysm

waxen granite
#

Before client/bot

granite prawn
#

ill try it

slate swan
#

does anyone know how i would go about making a user phone command in discord.py? i allready have my own userphone but it uses dictionarys and if two people do the function to call or ring at the same time it does a error where the data changed while it was changing

granite prawn
#

its still a nonetype

#

whyyyyy

#

wait forgot something again

low latch
#

@slate swan

slate swan
#

how can i change on my bot presence?

#

hi guys does anyone know how to link a python program back to discord framework

#

or where to learn

low latch
#

What do you mean by "link a Python program back to Discord framework"

granite prawn
#

ok i did the changes and its still nonetype

slate swan
#

i mean like i basically have my program do what i need it to do and now when it sucessful does what it needs to do i want to to ping me in discord in my server

low latch
#

Use a Discord API wrapper

willow vine
#

I want to store a message object in a database, can someone help me out as to how to do that

granite prawn
steep estuary
#

whats the problem here

little ether
steep estuary
#

:/

#

how i can stop this problem?

maiden fable
#

Of?

steep estuary
#

i want that people can dm the bot :/

maiden fable
#

!e

import time
import asyncio as time
time.sleep(1) 
steep estuary
#

i have a command >dmuser [user id] [msg] and if someone reply my bot in dm i got the reply in embed but yesterday i made a giveaway gunction after that this is not working :/

slate swan
#

client.wait_for("message") needs intents.presences = True?

steep estuary
#

how ?

steep estuary
#

this is code

maiden fable
steep estuary
#

??

slate swan
steep estuary
#

oo not that this is code

maiden fable
slate swan
steep estuary
#

error

slate swan
#

it works if there is intents.all()

slate swan
boreal ravine
slate swan
#

!d discord.Intents.messages

unkempt canyonBOT
slate swan
#

It'll be enabled by default though iirc

steep estuary
maiden fable
steep estuary
#

but i want to check the msg guild

slate swan
steep estuary
slate swan
#

how do i set a custom attribute of discord.Guild as something like a dict? because thats the only way i think i can possibly store the urls of a music bot

maiden fable
boreal ravine
slate swan
maiden fable
#

!d discord.Message.guild

unkempt canyonBOT
slate swan
boreal ravine
#

o

unkempt canyonBOT
slate swan
#

thats on_message

boreal ravine
#

@steep estuary u said id ur putting a string where ur supposed to put the id

maiden fable
#

No lol

boreal ravine
#

very

maiden fable
#

Yea

boreal ravine
#

id

steep estuary
#

than ?

maiden fable
#

That would never be true

steep estuary
#

what should i use

boreal ravine
#

paste the server id ig?

maiden fable
#

Wait, nvm

#

Eh, I think I'mma just go cz my net is being an ass. Cya!

boreal ravine
#

use the guild id

steep estuary
#

it will also check the server's id?

boreal ravine
#

you cant check a server id with a string

steep estuary
boreal ravine
steep estuary
boreal ravine
#

if message.guild.id == id:

steep estuary
boreal ravine
#

show me?

unkempt canyonBOT
boreal ravine
steep estuary
slate swan
boreal ravine
steep estuary
slate swan
#

idk

valid perch
#

if message.guild is none it means its in a dm

steep estuary
boreal ravine
steep estuary
#

k

boreal ravine
valid perch
#

if message.guild and message.guild.id == LegendServer

#

That means it wont error if its in dms

hoary gust
#

Ah anyone here who know how to make a youtube notifier

steep estuary
#

@boreal ravine

boreal ravine
#

hm

steep estuary
#

everything was working perfect

#

but i made yesterday a giveaway function

#

after that some of my old commands are not working

steep estuary
#

again @boreal ravine

steep estuary
hoary gust
#

Nonetype

#

Error

valid perch
#

Well, i mean. I guess im saying it again. If its None, it generally means the message is in dms

#

And so you want to check for it first

slate swan
#

can someone please help me

hoary gust
#

@slate swan post ur question

valid perch
#

Thats what that does yep.

slate swan
hoary gust
#

Ah anyone here who know how to make a youtube notifier

#

@slate swan what is ur music bot using?

boreal ravine
#

Mine uses discord utils

hoary gust
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

I cannot help

boreal ravine
#

what? lmfao

valid perch
slate swan
#

oh

valid perch
#

Better to just put it on bot

hoary gust
#

@valid perch u r helping him to break the tos of yt bud by helping him in his bot

slate swan
#

it works with me but

#

it keep spamming like "while True"

#

@client.listen()
async def on_message(message):
if message.guild.id == 864528215036002314:
await message.channel.send("test")

valid perch
boreal ravine
slate swan
valid perch
slate swan
hoary gust
slate swan
# hoary gust <@456226577798135808> post ur question

does anyone know how i would go about making a user phone command in discord.py? i allready have my own userphone but it uses dictionarys and if two people do the function to call or ring at the same time it does a error where the data changed while it was changing

hoary gust
#

Do as u want bud

#

@slate swan don't ping me bud just post the question no need to reply

slate swan
#

ok

#

can u help tho?

steep estuary
#

oo it worked

wispy sequoia
#
@client.command()
async def templates(ctx):
    try:
        res = requests.get("https://api.imgflip.com/get_memes")
        if res.status_code == 200:
            data = res.json()

        embed = discord.Embed(color=0x000000, title="Templates")

        for i in (data['data']['memes']):
            memeId = i['id']
            memeName = i['name']
            memeLink = i['url']
            embed.add_field(
                name=memeName, value=f"`Image:` {memeLink} - `ID:` {memeId}", inline=False)

        await ctx.send(embed=embed)
    except:
        print("Error")```

It's actually printing Error, what did I do wrong?
slate swan
wispy sequoia
#

it worked till I added "id"

slate swan
#

does it have a id key in the dict?

wispy sequoia
#

example

#

see I've removed memeId and it works again

slate swan
#

there might be too many fields

wispy sequoia
#

there are too many

#

but still

slate swan
#

i think the max is 24

wispy sequoia
#

lemme check

#

25

slate swan
#

well

#

try do print(len(embed)) before sending the embed

#

and tell me the output it gives

wispy sequoia
#

ok

wispy sequoia
slate swan
#

well the max characters you can have in a embed is 6000 so that will be the reasonf or error

velvet crest
#

How can i set what action(ie disable it or somthn like that) to take place upon my view (Select menu etc) getting timed out ... ? (dpy 2.0)

wispy sequoia
#

how to make embed pages?

#

like dank memer does

willow vine
#

how do i store a message object in a file or database so that i can call it anytime

willow vine
#

that stores string

#

i want to store the entire message object

wispy sequoia
#

with media too?

willow vine
#

everything

wispy sequoia
#

for media

#

message.attachments

willow vine
#

yeah i know how to access stuff in the message object

#

what i want is the entire message stored

#

reactions, id, channel id, guild

#

everything

wispy sequoia
#

message.guild

#

?

willow vine
#

yeah but doing the thing separately is a drag

#

I want to call the entire message later and use it

wispy sequoia
#

well I'm not that experienced

#

maybe?

hasty loom
#

is there something like on vc join event?

steep estuary
#

how to edit msges

slate swan
hasty loom
slate swan
#

what is problem?

steep estuary
#

i want to edit this

hasty loom
#

just do that

steep estuary
slate swan
#

why is not working pls help me

hasty loom
hasty loom
slate swan
#

i do on my discord server verify and is not working

hasty loom
#

also consider renaming client to bot if you are using bot constructor and not discord.Client

slate swan
#

me?

hasty loom
#

yes

hasty loom
slate swan
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 167, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 40, in setaichannel
    await c.execute("UPDATE data SET datan = ? WHERE rowid = 2", (str(channel.id)))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiosqlite3/cursor.py", line 130, in execute
    res = yield from self._execute(self._cursor.execute, sql, parameters)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiosqlite3/cursor.py", line 56, in _execute
    res = yield from self._conn.async_execute(func, *args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiosqlite3/connection.py", line 137, in async_execute
    return (yield from self._execute(func, *args, **kwargs))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiosqlite3/connection.py", line 126, in _execute
    future = yield from self._loop.run_in_executor(
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 18 supplied.
hasty loom
steep estuary
#

k

slate swan
#

what is problem?

hasty loom
#

you dont have a bot variable

slate swan
#

how can i create bot variable im new to python

steep estuary
#

i think now it will work for sure advance tysm @hasty loom 🙂

hasty loom
slate swan
hasty loom
sacred oriole
#

Hi, is a API available for compiling LaTeX?

slate swan
#

i have it

slate swan
boreal ravine
#

e

boreal ravine
#

no spoonfeeding

steep estuary
hasty loom
# slate swan

then why are you doing bot.command() if your variable name is client?

boreal ravine
#

maybe he copied the command?

steep estuary
boreal ravine
hasty loom
#

which is why i told him to learn python before trying to make a bot lol

boreal ravine
#

hm

steep estuary
boreal ravine
dusky robin
#

await ctx.channel.send("Hello, World!", components = [
Select(
placeholder = "Select something!",
options = [
SelectOption(label = "A", value = "A"),
SelectOption(label = "B", value = "B")
]
)
]
)

    event = await client.wait_for("select_option")
    print(event.component)

Why it returns None?

boreal ravine
#

I don't use 2.0 yet so idrk

wispy sequoia
#
@client.command()
async def test(ctx):
    embed = discord.Embed(color=0x000000)
    # dsInvite = await ctx.channel.create_invite()
    embed.set_thumbnail(url=f"{ctx.author.avatar_url}")
    embed.add_field(name="Author", value=f"<@!{ctx.author.id}>", inline=False)
    embed.add_field(name="Channel", value=f"<#{ctx.channel.id}>", inline=False)
    embed.add_field(name="Server", value=f"{ctx.guild}", inline=False)
    # embed.add_field(name="Server invite", value=f"{dsInvite}", inline=False)
    embed.add_field(name="Message", value=f"{ctx}", inline=False)
    await ctx.reply(embed=embed, mention_author=False)```
I want it to send also the message content but it doesn't
wispy sequoia
#

doesn't even work

stark bobcat
#

did anyone make a music command

wispy sequoia
#

I have join and leave

#

but play it's difficult

stark bobcat
#

hm

#

i m trying to make play

wispy sequoia
#

I tried use ffmpeg

stark bobcat
#

but the one i made

wispy sequoia
#

and youtube_dl

stark bobcat
#

downloads the video then plays

#

and downloading video takes lots of time

wispy sequoia
#

Ik

slate swan
wispy sequoia
#

ooh

wispy sequoia
#

I'm wondering

#

does it create a new invite everytime I run the command?

slate swan
#

yup

wispy sequoia
#

I don't wanna spam server log of invites

#

how to make it only once

#

I read that basic is infinite so I need it one time only

slate swan
#

just take the first one from guild.invites?

#

probably add a check for how much time is left for the invite and if there isnt one, make a new one

slate swan
wispy sequoia
stark bobcat
#

is it possible for a bot to steam?

slate swan
#

o okie

slate swan
stark bobcat
#

in vc

slate swan
#

stream* and no

stark bobcat
#

oh

stark bobcat
slate swan
#

np

wispy sequoia
slate swan
#

i see

wispy sequoia
#

well

#

this test command it's meant to be a real-time log

#

like

#

test

#

and the bot logs every message sent after the command

slate swan
wispy sequoia
#

lol

#

Ik it's strange

#

I need logs for some chats

#

example

#

owner is offline and ppl starts send nsfw and shi

#

the chat gets logged

stark bobcat
#

@slate swan

slate swan
boreal ravine
stark bobcat
#

i gave url argument

#

and still

boreal ravine
#

is it in a cog

wispy sequoia
#
@client.command()
async def send_dm(ctx, member: commands.MemberConverter, *, content):
    channel = await member.create_dm()
    embed = discord.Embed(color=0x000000)
    # dsInvite = await ctx.channel.create_invite()
    embed.set_thumbnail(url=f"{ctx.author.avatar_url}")
    embed.add_field(name="Author", value=f"<@!{ctx.author.id}>", inline=False)
    embed.add_field(name="Channel", value=f"<#{ctx.channel.id}>", inline=False)
    embed.add_field(name="Server", value=f"{ctx.guild}", inline=False)
    # embed.add_field(name="Server invite", value=f"{dsInvite}", inline=False)
    embed.add_field(
        name="Message", value=f"{content}", inline=False)
    await channel.send(embed=embed)```
This command actually works, if I do `>send_dm {user} hello!` the bot actually sends the user the entire details, but I want it to log every message gets sent after I run the command
wispy sequoia
stark bobcat
# boreal ravine show command
@bot.command()
    async def dyt(self, ctx, *, url):
        """Plays from a url (almost anything youtube_dl supports)"""

        async with ctx.typing():
            player = await YTDLSource.from_url(url, loop=self.bot.loop)
            ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)

        await ctx.send(f'Now playing: {player.title}')```
boreal ravine
stark bobcat
boreal ravine
stark bobcat
#

wym

wispy sequoia
stark bobcat
#

no intendation error

boreal ravine
#

By default if you remove the color kwarg it's black

wispy sequoia
#

man I don't really care about color

boreal ravine
boreal ravine
stark bobcat
boreal ravine
#

works fine w/ me lol

stark bobcat
#

but how do i fix

stark bobcat
boreal ravine
#

I dont know I dont use the example

stark bobcat
#

oh

#

okay

slate swan
wispy sequoia
#

should I use Cog?

boreal ravine
#

why ask us that?

stark bobcat
wispy sequoia
#

Cog.listener

boreal ravine
#

thats on message in a cog

stark bobcat
#

still does not work

boreal ravine
stark bobcat
#

okay thanks i will check it

#

@boreal ravine

#

i used discord utils

boreal ravine
#

install pynacl

boreal ravine
stark bobcat
boreal ravine
stark bobcat
cold violet
#

I get the error but the code works fine. Error occurs when user leaves Temp VC (and the temp vc deletes itself)

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 782, in on_voice_state_update
    if after.channel.id != None:
AttributeError: 'NoneType' object has no attribute 'id'```

Code below
```py
#Temp VC
@bot.event
async def on_voice_state_update(member, before, after):
    with open("/home/runner/EBOT/info/temp_vc_ch_id.json", "r") as f:
      file = json.load(f)
    chnl_id = file[str(member.guild.id)]
    chnl = int(chnl_id)

    with open("/home/runner/EBOT/info/temp_vc_category_id.json", "r") as f2:
      file2 = json.load(f2)
    category_id = file2[str(member.guild.id)]
    category = int(category_id)
    
    if after.channel.id != None:   
      if after.channel.id == 868642724239278090:
                guild = bot.get_guild(830981882890944512)
                maincategory = discord.utils.get(
                    guild.categories, id=868642690777120789)
                
                arrowvc= discord.utils.get(guild.channels, name='╰──┈┄┈┈┈────➣')
                await arrowvc.delete()

                channel2 = await guild.create_voice_channel(name=f" {member.display_name}'s VC", category=maincategory)
                await channel2.set_permissions(guild.default_role, connect=False, view_channel=True)
                await channel2.set_permissions(member, connect=True, stream=True, view_channel=True, use_voice_activation=True)

                arrowvc2 = await guild.create_voice_channel(name="╰──┈┄┈┈┈────➣", category=maincategory)
                await arrowvc2.set_permissions(guild.default_role, view_channel=True, connect=False)

                await member.move_to(channel2)

                def check(x, y, z):
                    return len(channel2.members) == 0
                await bot.wait_for('voice_state_update', check=check)
                await channel2.delete()
                
      elif after.channel.id == chnl:
          guild = bot.get_guild(member.guild.id)
          maincategory = discord.utils.get(guild.categories, id=category)

          channel2 = await guild.create_voice_channel(name=f" {member.display_name}'s VC", category=maincategory)

          await channel2.set_permissions(guild.default_role, connect=False, view_channel=True)

          await channel2.set_permissions(member, connect=True, stream=True, view_channel=True, use_voice_activation=True)

          await member.move_to(channel2)

          def check(x, y, z):
            return len(channel2.members) == 0
          await bot.wait_for('voice_state_update', check=check)
          await channel2.delete()
slate swan
#

Well, I'd guess the channel is no longer existing; so the after.channel object is simply None

steep estuary
#

how to edit a embed?

#

anyone?

orchid raptor
#

Hello, how can I get the photo link inside the embed?

willow vine
#

await message.edit(embed=Embed)

#

here Embed is the changed version

eager hollow
#

why are some commands in my cog working while some commands are commandnotFoundException

slate swan
#

how to add it in embeds??????

#

buttons

steep estuary
void mortar
#

how i can get the message content from audit logs, i tried to do it but i couldn't, can someone help me with that please

errant snow
#

which library should I go for now d.py is ded

boreal ravine
errant snow
#

somewhat related to d.py. Is pycord a good choice?

#

oh hahha

#

i dont want to rewrite tons of code so yeah i guess i can try pycord

boreal ravine
slate swan
slate swan
#

@boreal ravine

boreal ravine
steep estuary
#

why my embed is not editing

#

i am trying to edit my embed

#

but nothing is happening

#

anyone here plz hlp :/

floral crypt
#
        if payload.message_id == msg_id:

            if str(payload.emoji) == ':soyfonSugerencia:':
                await payload.member.send('Envía tu sugerencia, recuerda que todas las sugerencias deben ser serias, en caso contrario podrás ser sancionado, muchas gracias. Escribe `cancelar` para salir.')
                await mensaje_sugerencias.remove_reaction(':soyfonSugerencia:', payload.member)
                def check(m):
                    return m.guild is not None and m.author == payload.member
                message1 = await bot.wait_for('message', check=check)
                if message1.content.lower() == 'cancelar':
                    await payload.member.send('Sugerencia cancelada.')
                    return
                else:
                    with open("sugerencias.txt") as read_file:
                        executed = int(read_file.readline().strip())
                    titulo_sugerencia = f'Sugerencia #{executed}'
                    executed += 1
                    descripcion_sugerencia = message1.content
                    embed_sugerencia = discord.Embed(title=titulo_sugerencia, description=descripcion_sugerencia, color=0xb522ba)
                    embed_sugerencia.set_footer(text=payload.member, icon_url=payload.member.avatar_url)
                    mensaje_sugerencia = await canal_sugerencias.send(embed=embed_sugerencia)
                    await mensaje_sugerencia.add_reaction('\N{UPWARDS BLACK ARROW}\ufe0f')
                    await mensaje_sugerencia.add_reaction('\N{DOWNWARDS BLACK ARROW}\ufe0f')
                    await payload.member.send('Sugerencia enviada.')
                    with open("sugerencias.txt", "w") as write_file:
                        write_file.write(str(executed))
                        write_file.close()
steep estuary
#

why this embed is not editing embed have a timer but the timer is not running

floral crypt
#

Ok so this is supposed to get the person who reacted to the message, then remove the reaction and dm him, after he answers, the answer is sent to a channel

#

the problem is that when he says something before answering bot's dm

#

its sent the thing said on the server

steep estuary
#

no one replying :/

vagrant brook
#

-1 < endtime < endtime + 1 seems invalid

#

and meaningless

#

endtime is always smaller than endtime + 1

steep estuary
#

no

#

it is working when i am trying to edit a message

#

but embed is not editing

floral crypt
#

because

#

you are doing

steep estuary
floral crypt
#

await await ctx.send(embed=embedStart).edit(embed=embedStart)

high flame
steep estuary
#

i want to edit

floral crypt
#

this makes no sense

steep estuary
#

no

#

i m not doing this

floral crypt
#

yes

steep estuary
vagrant brook
#

Well it's actually meaningless

steep estuary
#

hmm

floral crypt
vagrant brook
#

Because endtime isn't automatically modified

floral crypt
#

check this

steep estuary
#

but it worked in msg

floral crypt
#

man look at this

steep estuary
#

k

#

so wht i should do?

floral crypt
#

StartAnnounce is await ctx.send(embed=embedStart)

steep estuary
#

wht should i do?

floral crypt
#

so if you do await StartAnnounce

#

this will mean await await ctx.send(embed=embedStart)

steep estuary
#

ya that i understood

vagrant brook
floral crypt
#

ok so fix it

steep estuary
#

how?

steep estuary
vagrant brook
#

I mean

floral crypt
#

ok so

vagrant brook
#

embedStart

floral crypt
#

but i mean

#

you arent editing anything

#

its the same content

vagrant brook
#

yes

steep estuary
#

how i can edit that embed?

steep estuary
vagrant brook
#

edit embedStart's content first

floral crypt
#

yes

#

look

steep estuary
#

the endtime is changing

vagrant brook
#

endtime changes

steep estuary
#

:/

vagrant brook
#

But embedStart doesn't change

floral crypt
#

yes

#

just the endtime

#

not the embed content

#

this is always the same

#

and please

steep estuary
#

i want to change this time

floral crypt
#

You cant do this

steep estuary
#

like a timer

floral crypt
#

you will be rate limited

#

API abuse

#

if you change it every second you will get ratelimited

steep estuary
#

means i cannot add a timer in a embed?

vagrant brook
#

!e

a = 1
b = f"{a}"

print(b)

a = 2
print(b)
unkempt canyonBOT
#

@vagrant brook :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 1
floral crypt
#

sadly, no

steep estuary
#

ok

vagrant brook
#

Make a 5 seconds delay

floral crypt
#

Well

#

you can but u will have problems

kindred epoch
#

Is there a safe way of making a calculator?

slate swan
steep estuary
#

k

#

so i think i should use message only 😦

floral crypt
#

and please, next time, dont post a photo, post text

#

thanks

steep estuary
#

k

#

🙂

boreal ravine
slate swan
#

bro normal embed

#

ik

boreal ravine
#

Maybe don't use a 3rd party lib just use pycord or something?

slate swan
#

no i dont

boreal ravine
#

u are

slate swan
#

pls

#

in decription

#

?

boreal ravine
#

Add the button to the embed

slate swan
#

then

boreal ravine
#

It isn't that confusing

floral crypt
#

You have to use 2.0

boreal ravine
#

Yes

slate swan
#

just clear my doubt once

boreal ravine
#

What

serene lynx
#

Is this a permissions issue or not? cs 2021-09-09T10:41:31.663374+00:00 app[worker.1]: 403 Forbidden (error code: 60003): Two factor is required for this operation 2021-09-09T10:41:31.806759+00:00 app[worker.1]: (<class 'discord.errors.Forbidden'>, Forbidden('403 Forbidden (error code: 60003): Two factor is required for this operation'), <traceback object at 0x7f9c90c10040>

slate swan
#

anyone know how to make python bot for discord thats gonna count down from 99999999 to 0 lol

kindred epoch
#

Or a 3rd party lib that supports d.py with it

#

Lib in pins has all that

steep estuary
# floral crypt You have to use 2.0
StartAnnounce = await ctx.send(f":loudspeaker:  Giveaway has been Started by {ctx.author.mention} and Will End After {endtime} Seconds :partying_face:")
            while -1 < endtime < endtime+1:
                if GiveawayActive ==True:
                    await asyncio.sleep(0.7)
                    await StartAnnounce.edit(content=f":loudspeaker:  Giveaway has been Started by {ctx.author.mention} and Will End After {endtime} Seconds :partying_face:")
                    endtime -= 1

should i use this ?

floral crypt
#

this is still wrong

steep estuary
#

but this is working perfect

floral crypt
#

StartAnnounce = await ctx.send(f":loudspeaker: Giveaway has been Started by {ctx.author.mention} and Will End After {endtime} Seconds :partying_face:")

#

await StartAnnounce

#

you are doing await await

steep estuary
#

oo

boreal ravine
steep estuary
slate swan
boreal ravine
slate swan
floral crypt
#

weell

#

leave it like this

steep estuary
#
StartAnnounce = ctx.send(f":loudspeaker:  Giveaway has been Started by {ctx.author.mention} and Will End After {endtime} Seconds :partying_face:")
                    await StartAnnounce.edit(content=f":loudspeaker:  Giveaway has been Started by {ctx.author.mention} and Will End After {endtime} Seconds :partying_face:")

this?

slate swan
#

why do u think i came here

floral crypt
#

no no

steep estuary
#

:/

floral crypt
#

leave it like before

floral crypt
steep estuary
floral crypt
#

Ok so use it ig

#

but it wont have the timer

steep estuary
#

but u told i am using await await :/

floral crypt
#

yes but leave it

#

If its working

steep estuary
#

k

#

:) ty

floral crypt
#

np

floral crypt
steep estuary
boreal ravine
flat solstice
#
def check(reaction, user):
                return user == ctx.author and str(reaction.emoji) in {"❎", "✅"}

onfirmation = await ctx.reply(f"You are about to ban {len(targets)} members. Do you want to add a reason for this ban? If **yes** react with ✅ and if **no** react with ❎")
await confirmation.add_reaction("✅")
await confirmation.add_reaction("❎")

try:
    reaction, user = await self.bot.wait_for('reaction_add', timeout = 60.0, check = check)
    if str(reaction.emoji) == "✅":
        reason_event = await self.bot.wait_for('message')
        reason = reason_event.content
    else:
        reason = "Unspecified"
except asyncio.TimeoutError:
    confirmation.edit(content = "The time to add a reaction timed out so the defualt reason of `Unspecified` will be used.")
    reason = "Unspecified"

confirmation.edit(content = f"You are about to ban {len(targets)} members. Do you want to select how mnay days of the members messages get deleted? If **yes** react with ✅ and if **no** react with ❎")
try:
    reaction, user = await self.bot.wait_for('reaction_add', timeout = 60.0, check = check)
    if str(reaction.emoji) == "✅":
        days_event = await self.bot.wait_for('message')
        delete_days = days_event.content
    else:
        reason = "Unspecified"
except asyncio.TimeoutError:
    confirmation.edit(content = "The time to add a reaction timed out so the defualt of `1` will be used.")
    delete_days = 1
for user in targets:
    await user.ban(reason = reason, delete_message_days = delete_days)```So I have this command which partly works. The bot will listen for the first msg event (the reason) but for some reason once it has received a reason input it doesn't then edit the msg to ask about the delete days and i'm not sure why. I'm also not sure if I'm doing the right check.
abstract salmon
#

yoo guys how would I go about making a bot that could collect pictures or text if the command is sent

floral raptor
#

guys

#

what is an web hook

kindred epoch
#

Not a string

maiden fable
kindred epoch
#

If they react with ❌ then just put none

flat solstice
boreal ravine
kindred epoch
#

No, I'm talking about if they react with ❌ then delete_message_days would raise an error

#

Or something idk

#

Lemme check

flat solstice
#

oh yeah i see where you mean now

slate swan
#
client.command_prefix = commands.when_mentioned_or("!")
px = client.command_prefix
print(px)
``` Gives this: `<function when_mentioned_or.<locals>.inner at 0x7f5b68a341f0>` But I want it to just give `!`. Please help!
hasty iron
#

commands.when_mentioned_or("!") returns a function

#

do px()

#

and it will return the prefix

valid niche
#

because you're not assigning a string literal but a function

#

so it stores the function and not a literal string

#

that's how that works

#

also one thing you are doing incorrectly @slate swan

#

a discord.Client doesn't have a command_prefix, it doesn't have commands

#

so client.command_prefix should not be possible

#

bot.command_prefix should

hasty iron
#

they could have a Bot named client

valid niche
hasty iron
#

thats what most people do

valid niche
hasty iron
#

no not really

dapper cobalt
#

It doesn't matter what your instance is as long as you know you won't define it again. I sometimes make my instance "bz" since it's short and I won't repeat it.

hoary gust
#

@dapper cobalt can u plz help me a bit

dapper cobalt
#

I can't help much since I'm on my phone on a yacht.

hoary gust
dapper cobalt
hoary gust
#

i want to get the invite link of a server but how can i use this

inv = await ctx.channel.create_invite(max_uses=1)

like

inv = await guild.create_invite(max_uses=1)

the problem is that i have fetched the guild but i need to get a channel to make the invite but how can i get the channel

valid niche
#

@hasty iron @dapper cobalt have you ever heard of consistent naming to make it clear to your future self and anyone else seeing your code what exactly is going on?

#

PEP 8

#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

dapper cobalt
hasty iron
#

Bot is a subclass of Client so does it really matter

#

and most of the time you can see if they're using Bot or Client

dapper cobalt
#

Choose a random channel from the guild's channels using random.choice() and try to create an invite for it.

valid niche
#

oh and this discord is about helping people and teaching them things. Teaching them bad habbits is like the most counter productive thing

hoary gust
dapper cobalt
#

Create an invite for a randomly chosen channel in the guild's channels.

dapper cobalt
#

random.choice(guild.text_channels)

hoary gust
#
for channel in guild.channel:
    random.choose(channel)
dapper cobalt
#

Oh you don't even know how to use random. Well I suggest you learn it first.

hoary gust
dapper cobalt
#

for x in range(500)

hoary gust
dapper cobalt
#

That's considered spam tho, and against the ToS.

#

Well we can't really help you according to rule 5.

shell wing
#
@bot.command()
async def giveaway(ctx, *args):
       output = ''
       embed = discord.Embed(
        title=" ![giveaway](https://cdn.discordapp.com/emojis/822749894137479179.webp?size=128 "giveaway") Giveaway Donations ![giveaway](https://cdn.discordapp.com/emojis/822749894137479179.webp?size=128 "giveaway")",
        description=output,
        color=0xff0000
    )
       embed.add_field(name="**Time**", value=f"{args[0]}")
       embed.add_field(name="**Requirements**:", value=f"{args[1]}", inline = "False")
       embed.add_field(name="**Winners**:", value=f"{args[2]}", inline = "False")
       embed.add_field(name="**Price**:", value=f"{args[3]}", inline = "False")
       embed.add_field(name="**Message**:", value=f"{args[4]}", inline = "False")
       await ctx.send(embed=embed)
       await ctx.message.delete()
``` so the bot takes every word after sapce as a new arg i want to make a symbol so that the bot only takes a arg after that symbol
#

how do i do that ?

flat solstice
#

Hi so I have this command here: https://srcb.in/a2g8FdweCt which works for the most part however this msg edit py confirmation.edit(content = f"You are about to ban {len(targets)} members.\n\nDo you want to select how mnay days of the members messages get deleted? **yes** = ✅ and **no** = ❎")doesn't seem to be happening despite the bot waiting for the reactions and taking the response to be used later

hasty iron
#

and stuff like that

shell wing
wispy sequoia
#
@client.command(aliases=["nick"])
@has_permissions(manage_nicknames=True)
async def nickname(ctx, member: commands.MemberConverter, nickname):
    await member.edit(nick=nickname)
    await ctx.reply(f"\u2705 Successfully edited the nickname to `{nickname}`")```

what's wrong?
tough lance
#

Use typehint discord.Member for member arg

wispy sequoia
#

still

hasty iron
#

its the same thing

#

discord.Member uses commands.MemberConverter

wispy sequoia
#

exactly

#

did I do smth wrong?

#

bc it's not working

tough lance
#

Any error?

wispy sequoia
#

no

#

it just doesn't work

#

heeeeelp

#

oof

maiden fable
#

!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/stable/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.update "discord.Permissions.update").
wispy sequoia
#

oh

#

it doesn't work

#

helllllppppp

flat solstice
#

is this the correct way to delete a msg that the bot was waiting on?py try: reaction, user = await self.bot.wait_for('reaction_add', timeout = 60.0, check = check) if str(reaction.emoji) == "✅": reason_event = await self.bot.wait_for('message') reason = reason_event.content await confirmation.remove_reaction("✅", ctx.author) await reason_event.delete(5)bc I got this errorpy TypeError: delete() takes 1 positional argument but 2 were given

wispy sequoia
#

oof

steep estuary
#

help

#

how i can delete the command after use

#

likei used

#

>kick somebody

#

than how i can delete it

#

after a delay

slate swan
#

ctx.author.delete

#

I believe

steep estuary
#

hmmm

#

k

flat solstice
slate swan
#

I was close

steep estuary
slate swan
#

The authors

wispy sequoia
flat solstice
steep estuary
maiden fable
steep estuary
#

this is deleting the msg

wispy sequoia
steep estuary
#

which i edited

flat solstice
wispy sequoia
#
@client.command(aliases=["nick"])
@has_permissions(manage_nicknames=True)
async def nickname(ctx, member: commands.MemberConverter, nickname):
    await member.edit(nick=nickname)
    await ctx.reply(f"\u2705 Successfully edited the nickname to `{nickname}`")```
help it's not working
slate swan
#

someone explain how do i like
when i send !cd it starts counting down how do i delete the "!cd"

wispy sequoia
slate swan
#

o ok thanks

wispy sequoia
steep estuary
slate swan
maiden fable
slate swan
steep estuary
#

??

slate swan
#

It works

maiden fable
#

Breh

slate swan
#

I’m not wrong it works fine

steep estuary
#

aa imma confused :/

slate swan
#

._.

#

same bruh

steep estuary
#

k

wispy sequoia
#
@client.command(aliases=["nick"])
@has_permissions(manage_nicknames=True)
async def nickname(ctx, member: commands.MemberConverter, nickname):
    await member.edit(nick=nickname)
    await ctx.reply(f"\u2705 Successfully edited the nickname to `{nickname}`")```
helpppppppppppppppppppp
slate swan
#
@client.command()
async def join(ctx):
    channel = ctx.author.voice.channel
    await channel.connect()
@client.command()
async def leave(ctx):
    await ctx.voice_client.disconnect()
#

any idea why this isn't working? (no errors)

slate swan
wispy sequoia
# slate swan any idea why this isn't working? (no errors)
@client.command(aliases=["connect", "come"])
async def join(ctx):
    try:
        channel = ctx.author.voice.channel
        embed = discord.Embed(color=0x000000)
        embed.add_field(
            name="\u2705 Success!", value=f"Successfully connected to `{channel}`.", inline=False)
        await channel.connect()
        await ctx.guild.change_voice_state(channel=channel, self_mute=False, self_deaf=True)
        await ctx.send(embed=embed)
    except:
        embed = discord.Embed(color=0x000000)
        embed.add_field(
            name="\u26d4 Error!", value="An error occurred. [Maybe you're not connected to a voice channel]", inline=False)
        await ctx.send(embed=embed)


@client.command(aliases=["disconnect", "fuckoff"])
async def leave(ctx):
    try:
        channel = ctx.voice_client.channel
        await ctx.voice_client.disconnect()
        embed = discord.Embed(color=0x000000)
        embed.add_field(
            name="\u2705 Success!", value=f"Successfully disconnected from `{channel}`.", inline=False)
        await ctx.send(embed=embed)
    except:
        embed = discord.Embed(color=0x000000)
        embed.add_field(
            name="\u26d4 Error!", value="An error occurred. [Maybe you're not connected to a voice channel]", inline=False)
        await ctx.send(embed=embed)```
get this from my bot
steep estuary
#

and how i can delete that

slate swan
#

IAM IN A VOICE CHANNEL!

wispy sequoia
#

oof

#

oh

#

pip install discord[voice]

#

in terminal

slate swan
#

ctx.message.delete("!cd")

slate swan
wispy sequoia
#

chill

slate swan
#

sorry for caps

wispy sequoia
#

restart your editor

#

it has installed a thing

#

maybe it works now

slate swan
#

nope

wispy sequoia
#

it works fine for me

slate swan
#

let me give it an ID instead of ctx.author.voice.channel

wispy sequoia
#
@client.command(aliases=["nick"])
@has_permissions(manage_nicknames=True)
async def nickname(ctx, member: commands.MemberConverter, nickname):
    await member.edit(nick=nickname)
    await ctx.reply(f"\u2705 Successfully edited the nickname to `{nickname}`")```
helpppppppppppppppppppp
valid niche
wispy sequoia
#

it's the same

valid niche
#

it's just discord.Member as the typehint and the library internally calls the converter

wispy sequoia
#

commands.MemberConverter is more useful

#

it detects an user by their id, username#discriminator and ping

valid niche
#

discord.Member is a typehint

#

and as i just said, the library interally calls the converter

slate swan
#

I did this and it still doesn't work...

@client.command(aliases=["connect", "come"])
async def join(ctx):
    try:
        guild = client.get_guild(756504534897000528)
        channel = guild.get_channel(879332800656986152)
        embed = discord.Embed(color=0x000000)
        embed.add_field(
            name="\u2705 Success!", value=f"Successfully connected to `{channel}`.", inline=False)
        await channel.connect()
        await ctx.guild.change_voice_state(channel=channel, self_mute=False, self_deaf=True)
        await ctx.send(embed=embed)
    except:
        embed = discord.Embed(color=0x000000)
        embed.add_field(
            name="\u26d4 Error!", value="An error occurred. [Maybe you're not connected to a voice channel]", inline=False)
        await ctx.send(embed=embed)
wispy sequoia
#

Idk man

slate swan
#

Urgh

spring flax
#

type hinting to discord.Member does just that

wispy sequoia
spring flax
#

code?

wispy sequoia
#

not working

slate swan
#

firstly
@commands.has_permissions

spring flax
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/stable/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/stable/api.html#discord.Permissions "discord.Permissions").

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