#discord-bots

1 messages · Page 799 of 1

velvet tinsel
#

chill pithink

cold sonnet
#
  File "c:\botok\Clanbot\cogs\cogbirthday.py", line 71, in callback
    await interaction.message.edit(content="Your birthday is...", view=View(Day(value, newOptions[0:15]), Day(value, newOptions[-(days-15):])))
  File "c:\botok\Clanbot\cogs\cogbirthday.py", line 76, in __init__
    self.options = options
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ui\select.py", line 180, in options
    self._underlying.options = value
AttributeError: 'Day' object has no attribute '_underlying'
```bro now I'm getting harassed by the lib
velvet tinsel
#

no I fucking won't

#

I'll just be off discord

bold surge
#

godamn

velvet tinsel
#

I won't even remember what I code xD

cold sonnet
#

wait

#

it's the view init

#

god fricking damn it dave

velvet tinsel
#

lmfao

#

I remember doing some stuff with django because it kept erroring on migrations

#

idk what I did but it worked so, I'm not complaining

cold sonnet
#

now this'll be insane

#

Your birthday is the 26st/nd/rd/th of March.

kindred epoch
cold sonnet
#

birthday reminder

kindred epoch
#

ok and where are you storing the dates?

spark wigeon
#

imageine he says txt

flat solstice
#

So I have this commandpy #@commands.check_any(commands.has_permissions(manage_guild = True), commands.has_permissions(manage_messages = True)) @commands.guild_only() @commands.command(description = f"Lets you toggle a role as mentionable or not. Command will show the current state if no state is given.") async def mentionable(self, ctx, role: discord.Role, mentionable: Optional[bool]): if mentionable is None: await ctx.send(f"{role.mention} is {'pingable' if role.mentionable is True else 'not pingable'}") else: if mentionable is True: await role.edit(reason = f"{ctx.author} made {role.name} pingable.", mentionable = mentionable) else: await role.edit(reason = f"{ctx.author} made {role.name} not pingable.", mentionable = mentionable)which is producing this errorpy ERROR:cogs.error_handler:Forbidden: 403 Forbidden (error code: 50013): Missing Permissions (In mentionable) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/moderation.py", line 179, in mentionable await role.edit(reason = f"{ctx.author} made {role.name} pingable.", mentionable = mentionable) File "/usr/local/lib/python3.8/dist-packages/discord/role.py", line 349, in edit data = await self._state.http.edit_role(self.guild.id, self.id, reason=reason, **payload) File "/usr/local/lib/python3.8/dist-packages/discord/http.py", line 248, in request raise Forbidden(r, data)when both I and the bot have administrator permissions

spark wigeon
#

is that modmail source

kindred epoch
#

maybe make a new role for testing and try it on that

slate swan
#
NameError: name 'guild' is not defined
#
emb.set_footer(text="© Все права защищены The Greatest", icon_url = guild.icon_url)
#

Help please

kindred epoch
#

full code?

flat solstice
kindred epoch
slate swan
#

🐑

spark wigeon
#

how to handle this exception?

discord.ext.commands.errors.MemberNotFound: Member "<@&938899544333254768>" not found.
slate swan
#

Ok...🐑

flat solstice
kindred epoch
cold sonnet
#

asked the month before

#

I finally did it

spark wigeon
kindred epoch
patent lark
kindred epoch
#

thats what you use to handle command errors

spark wigeon
#

but this one works for no user mention, how do i create on for invalid user mention

    except AttributeError:
        error_em = discord.Embed(title=f"Error Using That Command", colour=0xFFFFFF)
        error_em.add_field(name="Error:", value=f"No User Mention", inline=False)
        error_em.set_footer(text="https://github.com/zoaq1")
        await ctx.message.channel.send(f"{ctx.message.author.mention}", embed=error_em)```
patent lark
#

!d disnake.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.10)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
patent lark
#

this is the correct tag @kindred epoch

spark wigeon
#

what would go where "exception" is

kindred epoch
slate swan
#

how do I create a loop so that the code asks a question in the console and takes the answer?

hard trail
#

How would I make a bot respond to an event that like sends what the user has said. For example if I type Hello I want the bot to send "You said Hello"

patent lark
#

you could use on_message or wait_for()

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
patent lark
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
kindred epoch
slate swan
patent lark
#

simply use input

#

you dont need a loop to ask a simple question

kindred epoch
#

🤷‍♂️

patent lark
#

a loop is very un-needed

slate swan
#

What is difference between bot.command and client.command?

kindred epoch
slate swan
#

Hmmmm

spark wigeon
#

here is mine, mine is client.command because thats what i defined it as client = commands.Bot(command_prefix="t!",help_command=None,intents=intents)

kindred epoch
#

best practice is to define your commands.Bot as bot and not client

spark wigeon
slim ibex
#

best practice is to subclass the bot 🗿

kindred epoch
#

🗿 true

flat solstice
# kindred epoch hm

so after looking at my bots perms it has the admin toggled on but the manage roles toggled off, I would assume that admin overrides manage roles but should I update my bots OAuth?

kindred epoch
flat solstice
#

guess it's like one of my other commands, that ones just not responding at all with zero errors so at least mentionable is responding

kindred epoch
#

whats the command code maybe i can help

hard trail
#

Because the last time I did it the bot malfuctioned and spammed

distant pike
#

yo i keep getting the error ModuleNotFoundError: No module named 'discord_components' not too sure why, been trying to fix it (py 3.9.10 in vsc)

neat tartan
patent lark
#

yep

#

if message.author is bot.user: return

neat tartan
#

bot.command should naturally do that for you aswell but its always good to double check and make sure

flat solstice
# kindred epoch whats the command code maybe i can help
#@commands.check_any(commands.has_permissions(manage_guild = True), commands.has_permissions(manage_messages = True))
@commands.guild_only()
@commands.command(description = f"Lets you toggle a role as mentionable or not. Command will show the current state if no state is given.")
async def mentionable(self, ctx, role: discord.Role, mentionable: Optional[bool]):
    if mentionable is None:
        await ctx.send(f"{role.mention} is {'pingable' if role.mentionable is True else 'not pingable'}")
    else:
        if mentionable is True:
            await role.edit(reason = f"{ctx.author} made {role.name} pingable.", mentionable = mentionable)
        else:
            await role.edit(reason = f"{ctx.author} made {role.name} not pingable.", mentionable = mentionable)```
slate swan
#

which function can be to sent a message

hard trail
#

It keeps sending this message

#

You said <Message id=938924529584074753 channel=<TextChannel id=874847853888036949 name='・general' position=6 nsfw=False news=False category_id=874847853888036947> type=<MessageType.default: 0> author=<Member id=775381954564587560 name='AGT Kizi' discriminator='7078' bot=False nick='AGT KIzi' guild=<Guild id=874847853888036946 name='Test Server' shard_id=0 chunked=False member_count=7>> flags=<MessageFlags value=0>>

kindred epoch
random lark
#

why is not work ? ```py
@client.event
async def on_ready():
print("send id")
x=input()
user = client.get_user(x)
await user.send('hii')

hard trail
#
async def on_message(msg):
  if msg.author == bot:
    ...
  else:
    await msg.channel.send(f"You said {msg}")```
#

I feel really dumb

#

But I can't get it

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

flat solstice
# kindred epoch i meant the commands which are not responding lul

oop, it's this one. it's being registered in my help command at least and I can invoke it in jishaku and it works fine but as soon as I run it it just doesn't respond py @commands.has_permissions(administrator = True) @commands.guild_only() @commands.command(description = "Sets the bad words that aren't allowed to be said on the server.") async def badwords(self, ctx, *, words: str): print(f"\nInput: {words}") guild = 448405740797952010 if ctx.guild is None else ctx.guild.id data = await self.bot.get_data(guild) words = [w[1:] if w[0] == " " else w for w in words.split(",")] bad_words = set(words) if data[28] is None else set(data[28] + words) print(f"Bad Words: {bad_words}") async with self.bot.pool.acquire() as conn: await conn.execute("UPDATE data SET badwords=$1 WHERE guild=$2", [word for word in bad_words], guild,) await ctx.send(embed = discord.Embed(colour = ctx.author.colour, title= "Update: Bad Words List:", description = f"`{', '.join(data[28])}`."))

spark wigeon
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.message' has no attribute 'edit'

#

help

spark wigeon
#

pastebin cause this will count as spam

#

v

spark wigeon
spark wigeon
#

bruh fr is there something im missing

kindred epoch
hard trail
spark wigeon
spark wigeon
hard trail
#

Shouldn't it be like troll_message.edit

slate swan
#
import discord
import os

# Import load_dotenv function from dotenv module.
from dotenv import load_dotenv

# Loads the .env file that resides on the same level as the script.
load_dotenv()

# Grab the API token from the .env file.
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")

# Client Bot
#client = discord.Client()
client = discord.Client()



@client.event
async def on_ready(channel_id, title, url, desc, name, thumbnail, test):
    channel = client.get_channel(channel_id)
    embed=discord.Embed(title=title, url=url, description=desc, color=0xff0000)
    embed.set_author(name=name, url=url)
    embed.set_thumbnail(url=thumbnail)
    embed.add_field(name="test", value=test, inline=False)


    await channel.send(embed=embed)

    # Run the client on the server
    client.run(DISCORD_TOKEN)

What am i doing wrong. I would like to sent an embeded message to a channel

TypeError: 'coroutine' object is not callable

hard trail
#

Not message.edit

spark wigeon
#

how did i not notice that

flat solstice
hard trail
spark wigeon
spark wigeon
#

dont indent client.run

kindred epoch
#

besides importing and defining the client

#

thats all you have correct

slate swan
#

anyone know how to make an alias to a jishaku command

#

e.g prefix pull instead of prefix jsk pull

flat solstice
slate swan
kindred epoch
#

Nothing is wrong with that

#

It's just that the code is too old to run

#

And doing stuff in on_ready is really bad since it can be executed multiple times

slate swan
kindred epoch
slate swan
#

i have another function which iterates over data when there is a match i would like to call discord bot to send embeded message to a specific channel

kindred epoch
#

Ok, do you have the id of that channel?

slate swan
#

yes, I already got it working with on_ready but the program is not closing. After sent a message the function have to sent another one again

kindred epoch
#

Again as I said on_ready is not for sending messages.

slate swan
#

cant find in documentation what i should use

kindred epoch
#

Ok, I think you don't have the basics of setting up and making a disord bot down, so take a look at this help guide made by one of the helpers here https://vcokltfre.dev

A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.

rocky trench
#

Try coding yourself simple commands, each time a little harder

#

Cant find something? --> docs

#

Still can't find it? --> here

cloud dawn
#

docs doesn't really explain syntax.

spark wigeon
#

how to get ideas for bot commands

compact ruin
#
@client.command()
async def test(ctx):
for member in ctx.guild.members:
            member = member
            print(member)

Anyone know why this is not worken lemon_angrysad

reef trail
#

is there an event for when someone creates an invite?

cloud dawn
unkempt canyonBOT
#

disnake.on_invite_create(invite)```
Called when an [`Invite`](https://docs.disnake.dev/en/latest/api.html#disnake.Invite "disnake.Invite") is created. You must have the [`manage_channels`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_channels "disnake.Permissions.manage_channels") permission to receive this.

New in version 1.3.

Note

There is a rare possibility that the [`Invite.guild`](https://docs.disnake.dev/en/latest/api.html#disnake.Invite.guild "disnake.Invite.guild") and [`Invite.channel`](https://docs.disnake.dev/en/latest/api.html#disnake.Invite.channel "disnake.Invite.channel") attributes will be of [`Object`](https://docs.disnake.dev/en/latest/api.html#disnake.Object "disnake.Object") rather than the respective models.

This requires [`Intents.invites`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.invites "disnake.Intents.invites") to be enabled.
reef trail
#

i use dpy panda

compact ruin
reef trail
#

is it the same?

final iron
cloud dawn
unkempt canyonBOT
#

discord.on_invite_create(invite)```
Called when an [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") is created. You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to receive this.

New in version 1.3.

Note

There is a rare possibility that the [`Invite.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.guild "discord.Invite.guild") and [`Invite.channel`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.channel "discord.Invite.channel") attributes will be of [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object") rather than the respective models.

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

ah alright

cloud dawn
#

Exactly the same

reef trail
#

thanks panda

compact ruin
#

nvm i see it now

worn tapir
#

Is there a way to run some code right before the bot stops working? I want to log it when my bot turns off by writing the current time and date to another file. I have the writing part done, but can't find a way to execute code as the bot is being shut off.

compact ruin
#

nvm on my code the indent is fine

#

i just got the indent wrong on message

#

still not workin though lemon_angrysad

#

No errors either

#
@client.command()
async def test(ctx):
    for member in ctx.guild.members:
            member = member
            print(member)

This does not work lemon_angrysad

cloud dawn
#

indention is still inconsistent

compact ruin
#

lemon_angrysad Idk i paste it there and the lines shift so i just add the spaces in myself

neat tartan
#

What code editor are you using to write this in?

compact ruin
#

But when i run the code and try the command theres no error, there would be an error if it was indento problemo right?

#

Visual Code

spark wigeon
# kindred epoch its not try and except

u feel dumb rn py except AttributeError or discord.ext.commands.errors.MemberNotFound(f"@{member}"): error_em = discord.Embed(title=f"Error Using That Command", colour=0xFFFFFF) error_em.add_field(name="Error:", value=f"Invalid/No User Mention", inline=False) error_em.set_footer(text="https://github.com/zoaq1") await ctx.message.channel.send(f"{ctx.message.author.mention}", embed=error_em)

#

that works

final iron
slate swan
#

I've been trying to find ways to experiment with user input but can't really think of a way.

final iron
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
#

To work with user inputs in the first place

#

Hmm

#

Are there any examples of how this is used

sick birch
shrewd inlet
#

how do i add last fm commands to my bot?

#

like i wanna make a “nowplaying” command and a “set” command

sick birch
#

We don't help with music bots sorry

slate swan
sick birch
shrewd inlet
#

it just shows what you’re playing in last fm

sick birch
#

fm?

final iron
shrewd inlet
#

many bots have it

shrewd inlet
final iron
#

They're in the docs

sick birch
#

what's that

final iron
final iron
#

There are tons of murderers, doesn't mean its allowed

shrewd inlet
slate swan
sick birch
#

Ah

#

Do you have to integrate with their service through an API?

shrewd inlet
sick birch
#

Then you'll have to do that with aiohttp and is outside the scope of this channel

shrewd inlet
#

someone sent me a code but i wanna learn how to integrate it

compact ruin
shrewd inlet
#

example up here

compact ruin
sick birch
#

That code is disturbing to look at

final iron
#

I agree

#

Completely breaks pep8

#

No white space, bare exceptions, no spacing, lines that look over 79 characters, etc.

#

Also variable naming

#

Terrible variable naming and not using snake_case

shrewd inlet
#

damn

slate swan
#

@bot.command()
async def test(ctx, *, arg):
await ctx.send(arg)

#

Btw what is the * for

final iron
#

Probably the wrong way to explain it but it packs all the arguments in to arg

#

So

#
!test a b c d
#

arg will be a b c d

slate swan
#

Hmm

#

So what would happen if I removed *?

final iron
#

Then arg would only consume 1 argument

#

So

#
!test a b c d
#

arg will be a

slate swan
#

And it would ignore the rest. Ah.

#

Thanks lol

final iron
#

👍

slate swan
#

Also is args a variable?

final iron
#

iirc yes

slate swan
#

Thanks

spark wigeon
#

why doesnt the gif embed work?

slate swan
#

It'd end with .gif

#

If you clicked on it it'd not take you to the gif

slate swan
#

You need to download it. You'd get an MP4 instead of a GIF file.

#

So you have to then convert the MP4 to a GIF file and then post it.

spark wigeon
#

i got it

slate swan
#

Lemme send you a converted gif

spark wigeon
#

no

#

i just copied a mp4 url, not gif

#

i found the gif one

final iron
#

Why not use an embed?

kindred epoch
# rocky trench God no

? I said it tells you the basics, does he know what he needs to look at in the docs? No.

final iron
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

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

bool(b) Returns whether the embed has any data set.

New in version 2.0.

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/master/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.
spark wigeon
reef trail
#
@commands.Cog.listener(name="on_invite_create")
async def log_invites(self, ctx, invite):
    await self.bot.wait_until_ready()
    if ctx.guild is None:
        return 
    log_channel = self.bot.get_channel(938936724535509012)
    log_server = self.bot.get_guild(755722576445046806)
    if invite.guild.id == log_server.id:
        embed = discord.Embed(title="Invite Created", color=0x00ff00)
        embed.add_field(name="Invite Details", value=f"{invite.url}, {invite.created_at}, {invite.expires_at},\n{invite.max_age}, {invite.max_uses}, {invite.temporary},\n{invite.max_uses}, {invite.inviter}, {invite.uses}")
        await log_channel.send(embed=embed)


Ignoring exception in on_invite_create
Traceback(most recent call last):
  File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/client.py", line 351, in _run_event
  await coro(*args, **kwargs)
TypeError: log_invites() missing 1 required positional argument: 'invite'``` why is this happening?
final iron
slate swan
spark wigeon
#

"mustve been the wind"

slate swan
reef trail
#

they're talking about an actual embed

slate swan
#

It's about embed within embed

spark wigeon
#

but why do i need to embed it

slate swan
#

Lemme show an example

reef trail
#

you dont need to but it looks neater if it is

reef trail
#

this is what they're talking about

slate swan
#

Like this

#

For that, you use embed.set_image="insert URL"

reef trail
slate swan
#

Hmm

reef trail
#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

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

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
slate swan
slate swan
reef trail
slate swan
#

Btw I want to create a minigame where users can give inputs for questions and answers. And all the inputs are compiled somewhere and these are used for quizzes.

spark wigeon
#

anyway to make the command type seporators look better? Im just using a normal field atm

slate swan
#

...

spark wigeon
# slate swan ...

i know u think ur cool and all but this is a place to help others not be rude

slate swan
spark wigeon
#

anyway to separate the sections better? heres what im doing now:

@client.command()
async def help(ctx):
    help_em = discord.Embed(title=f"Here are my Commands:", colour=0xFFFFFF)
    help_em.add_field(name="Fun Commands"   , value="Commands to use when your bored or when you want to prank someone.", inline=False)
    help_em.add_field(name="t!troll"  , value="Trolls any user mentioned.", inline=True)
    help_em.add_field(name="t!avatar" , value="Gets any user's avatar.", inline=True)

    help_em.add_field(name="Utility Commands"   , value="Useful Utility that has many Useful Features", inline=False)
    help_em.add_field(name="t!ping"   , value="Displays my ping in MS.", inline=True)
    help_em.add_field(name="t!stats"  , value="Displays Stats about this Server.", inline=True)

    help_em.add_field(name="Other Commands"   , value="Misc. Commands, or just uncatergorized Commands.", inline=False)
    help_em.add_field(name="t!help"   , value="A List of Useful Commands.", inline=True)
    help_em.add_field(name="t!invite"   , value="Sends a URL You can use to Invite me to a Server.", inline=True)
    help_em.add_field(name="t!source"   , value="Sends a URL to see my Source Code.", inline=True)

    help_em.set_footer(text="https://github.com/zoaq1")

    await ctx.message.channel.send(f"{ctx.message.author.mention}", embed=help_em)
final iron
#

Instead, subclass it

left crater
#

can i send a video link without having the link at the top like this

sick birch
#

You'd have to send it as an attachment rather than send the link

left crater
#

but i have like 500 links lmao

fickle bloom
#
@ client.command()
# @has_permissions(administrator=True)
async def RoulleteAt(ctx, user: discord.User):
    channel = client.get_channel(hitagi)
    blankChannel = discord.utils.get(ctx.guild.text_channels, name=None)
    userId = user.id
    targetMember = discord.Guild.get_member(user.id)
    await ctx.send(targetMember)
#

in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: get_member() missing 1 required positional argument: 'user_id'

#

How come this doesn't work? I tried user_id like 15 ways

#

ctx.send with user.id returns properly

slim ibex
#

!d discord.Guild.get_member

unkempt canyonBOT
final iron
left crater
#

i guess im fucked

fickle bloom
#

am I missing something?

slim ibex
#

change

final iron
#

Variables and functions should be in snake_case

slim ibex
#

targetMember = discord.Guild.get_member(user.id) to target_member = ctx.guild.get_member(user.id)

final iron
#

Using other wise in this context is bad practice

fickle bloom
#

ah, the issue is I can't send the user to the channel can I?

#

ctx.send won't work on discord.Guild.get_members output

#

No issue after removing ctx.send

fickle bloom
slim ibex
#

you should use the ctx instead of the whole discord.Guild.get_member

fickle bloom
#

we want an admin to use the mention of a user to be able to play a game with that user

#

I already have the game working from ctx of a user firing it

#

but we want to @ someone into the game

slim ibex
#

user.mention??

fickle bloom
#

from ctx?

#

i.e. this? test_var = ctx.discord.User.mention()

slim ibex
#

no, since the user is a param, you can refrence it like that

#

no

#

yoiu dont need to use the whole function name like that

#

test_var = user.mention

final iron
fickle bloom
#

ah duh facepalm

#

I didn't think to use user.mention

#

I'm using user.id for no reason then

fickle bloom
slim ibex
#

he's kidding

#

atleast i think so 🗿

fickle bloom
#
@ client.command()
# @has_permissions(administrator=True)
async def RoulleteAt(ctx, user: discord.User):
    channel = client.get_channel(hitagi)
    blank_channel = discord.utils.get(ctx.guild.text_channels, name=None)
    target_member = user.mention
    # await ctx.send(target_member)
#

So, all we need now is to be able to move target_member to another channel. And I think I can figure that out pretty easily from the API

#

thanks all

slim ibex
#

np

#

juust remember snake case

final iron
slim ibex
#

RoulleteAt to roullete_at

fickle bloom
#

python interpreter doesn't like anything non snake_case?

final iron
#

Always remember, discord.py is heavily object oriented

slim ibex
#

it doesn't matter, but its pep8 styling

fickle bloom
#

What are the performance differences, because the user is running that command

final iron
slim ibex
#

you should follow it

fickle bloom
#

and roullete_at is a lot uglier than RouletteAt

slim ibex
#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

final iron
#

Pep8 is the style guide of python

fickle bloom
#

Ah, like eslint

#

Is there prettier/pep8 extension for vscode?

#

I'd assume so

trim fulcrum
#

how do i make it where someone makes there status a certain word or sentence it sends a message

final iron
fickle bloom
final iron
#

What do you mean enforce rules?

fickle bloom
#

in strict mode that is

final iron
#

I'm not aware of anything like that

fickle bloom
#

it enforces standards like casing, tabing etc

final iron
fickle bloom
#

thanks

#

thumbs_up help means a lot

trim fulcrum
#

how do i make it where someone makes there status a certain word or sentence it sends a message

final iron
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

• nickname

• roles

• pending...
final iron
#

That's for status

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
final iron
#

That's for the message

#

@trim fulcrum

sick birch
trim fulcrum
fickle bloom
#

ok, I now have target_member properly set, and it properly returns the user.

How can I disconnect this user? Or move them to a blank channel like I was before using ctx?

await ctx.author.move_to(blankChannel)

What's the equivalent to this but for a user mention?

fickle bloom
sick birch
fickle bloom
#

I think it's important to have this for new users tbh

#

it helped me a ton years ago in react

sick birch
#

Agreed

#

But I don't know if it's possible to enforce this in python since it's quite different from Node projects

trim fulcrum
sick birch
#

Yes, on_member_update is what you need

fickle bloom
#
async def roulette_at(ctx, user: discord.User):
    channel = client.get_channel(hitagi)
    blank_channel = discord.utils.get(ctx.guild.text_channels, name=None)
    target_member = user.mention
    

    # await target_member.disconnect()

Looking to do something like this comment

sick birch
fickle bloom
#

str' object has no attribute 'move_to'

sick birch
#

what's the type of target_member?

#

Oh it's a string

fickle bloom
#

do I need id?

sick birch
#

And how exactly did you get target_member?

fickle bloom
#

async def roulette_at(ctx, user: discord.User):
target_member = user.mention

sick birch
#

ID yes, but the actual instance object would be preferable

fickle bloom
#

from Discord.user props

sick birch
#

typehint to discord.Member

#

then you can just do, member.move_to(None)

#

When possible you should always try to pass around objects rather than strings or IDs since it makes things much more easier and efficient to work with

fickle bloom
#
async def roulette_at(ctx, user: discord.Member):
    channel = client.get_channel(hitagi)
    blank_channel = discord.utils.get(ctx.guild.text_channels, name=None)
    await ctx.send(user)
    user.move_to(blank_channel)
sick birch
#

Don't think that'd work

fickle bloom
#

Did setting var = object convert to a string?

sick birch
#

Just pass in None to move_to

fickle bloom
#

or is discord.Member not an object?

#

Ok, let me try

sick birch
#

also you don't need the channel and blank_channel variables

#

If done right this can be done in 2 lines

fickle bloom
#

channel is used for channel.send

#

we use it to send to different channels depending on where we want the spam lol

#

I have some vars at the top with each channel ID

sick birch
fickle bloom
#

we don't want it sending the message to the channel the command was executed in

sick birch
#

🤔 In that case sure

fickle bloom
#

the replies are very large

#

😆

#

it's for a dumb game, and it replies with large paragraphs

sick birch
#

Ah okay then make sure you do channel.send() rather than ctx.send()

#

Since right now it looks like you're using ctx.send()

fickle bloom
#

ah, just for testing to make sure I could get the user object

#

that's all, thank you though

#

I think I can finish this now

sick birch
#

One last thing, just rename your user to member as it's a discord.Member not a discord.User, not important but just consistency and to avoid confusing yourself

spark wigeon
#

how do you guys come up with command ideas

final iron
sick birch
#

Personally I don't, haven't made a bot in, oh, a very long time haha

spark wigeon
sick birch
#

!d discord.Message.reactions

unkempt canyonBOT
final iron
sick birch
#

Anytime

neat tartan
# final iron Steal them

Lol, discord bots are so saturated with the same base level commands and there really hasnt been much diversity outaide of specific bots designed for particular servers like python bot here or some special dnd bots that link to other dnd websites

final iron
#

Discord bot space is pretty bland right now

neat tartan
#

Main reason im learning it is to get more used to apis for web dev lol. Its also a fun little project i can pick and choose what it does for me and my friends private server

final iron
#

I think discord adding views and selects was nice

zenith basin
#

how do cogs with slash cmd

sick birch
neat tartan
#

I dont think its much of an issue with what discord allows. Bots pretty much have access to whatever is needed to make them work. Anything for specific features would just have to come from some other sort of python classes and then translated to fit the discord api

#

My funny random monkey picture command uses the google api to get the result and converts it to a url to embed into the message for discord. 90% of that functions code is working with the google api lol

#

Setup correctly discord could probably work as a frontend for something like a note based webapp. Its kinda redundant given discord naturally could be used like that...

sick birch
#

True, but for many people discord bots are an excellent way to get acquainted with python or learn more about different aspects of programming

neat tartan
#

Fair enough

sick birch
#

If you're making a discord bot not for the purpose of learning, there are plenty of tools that get the job done

#

It's a win-win regardless of your intentions

fervent shoal
#

do i need to import something for embed

sick birch
#

That's odd, it's not even picking up its own message?

#

That's not a slash command, that's a regular message

neat tartan
fervent shoal
#

should this work

sick birch
#

Which fork are you using?

#

I see

#

That should still just be a regular message

neat tartan
timid wagon
#

Since that's a slash command, I would recommend using ctx.response.send_message

frank tartan
#
@client.event
async def on_message_delete(message):
    logChanID = db(f"logChan-{message.guild.id}")
        
    if logChanID == "None":
      return

    logChan = client.get_channel(logChanID)
        
    msgCHAN = message.channel.mention
    embed = discord.Embed(title=f"Deleted Message",description=f"{message.content}", color=0xFF0000)
    embed.add_field(name=f"Channel", value=f"{msgCHAN}")
    embed.set_author(name=message.author)
    embed.set_footer(text="View audit log for more information.")
    await logChan.send(embed=embed)

that is my code

Ignoring exception in on_message_delete
Traceback (most recent call last):
  File "/home/runner/Database-testing/venv/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 57, in on_message_delete
    logChanID = db(f"logChan-{message.guild.id}")
TypeError: 'Database' object is not callable

thats my error message
im using replit db

fervent shoal
#

why is the thing not colored, it was before ( the white text)

timid wagon
sick birch
timid wagon
frank tartan
timid wagon
#

And then passing that object to member.add_roles

fervent shoal
final iron
sick birch
timid wagon
#

Does the message have any reactions?

sick birch
#

also much more reliable and easier to work with (provided you use the right defaults)

trim fulcrum
fervent shoal
trim fulcrum
#

now what do i do @sick birch

final iron
#

Can you not fetch a role?

spark wigeon
#

getting this error discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.message' has no attribute 'delete' while using this await message.delete() even tho my import is this from discord import *

fervent shoal
#

i do not follow

#

at all

sick birch
final iron
#

Pep8 says that's a nono

timid wagon
#

Please just import discord

sick birch
#

Convolutes the namespace, just like what it's doing right now

spark wigeon
spark wigeon
timid wagon
#

;-;

sick birch
#

then you won't be able to fix your issue

timid wagon
#

It's only going to make things difficult for you, like this case

vocal snow
final iron
sick birch
#

It's looking for a module in discord named message rather than a variable

timid wagon
final iron
#

Since it's a class it uses Pascal case

neat tartan
timid wagon
#

Aight guys I think they got it

final iron
#

I.e ThisIsAClass

fervent shoal
#

3 pings same thing

#

lol, i did get it tho

sick birch
#

Classes will always use PascalCase

#

Worth assuming all classes in discord.py are named the same

final iron
#

Yup. Just look at discord.User, discord.Member, commands.Bot

#

I'm just adding discord and commands to make it more clear

fervent shoal
#

should i do await.embed

final iron
#

No

#

It's a class, not a coro

fervent shoal
#

cuz rn it only bans, doesnt show embed

timid wagon
#

Probably because you're not sending the embed

final iron
#

await ctx.send(embed=embed)

fervent shoal
#

oh

slate swan
#

You have to predefine the embed

timid wagon
#

More like, predefining the embed is good practice

#

And I assume they understood they didn't pass it as an argument

fervent shoal
timid wagon
#

Yep

slate swan
#

Like

embed1=discord.Embed(title="write title here", description="insert description here")

await ctx.send(embed=embed1)```
#

I wrote the var as embed1 to make the last line more clear

fervent shoal
trim fulcrum
#

how do i make it where someone makes there status a certain word or sentence it sends a message

sick birch
fervent shoal
#

line 49
await ctx.send embed = discord.Embed(title=f"{member} has been banned")

timid wagon
#

You've specified the discord.Member class in the f-string. Not your member argument.

fervent shoal
#

so is it capitaliziation

timid wagon
#

The difference between lowercase and uppercase, yes

sick birch
fervent shoal
#

unless im blind

timid wagon
#

In the embed you've defined

fervent shoal
#

thats discord.Embed

timid wagon
#

The syntax highlighting matches what you have typehinted for the function

timid wagon
#

It's right next to that

slate swan
#

Don't capitalise it

timid wagon
#

Member is the discord.py class, member is your argument.

slate swan
# fervent shoal

You need to use an instance of the object, not the object itself

timid wagon
#

If it really confuses you to that degree, please don't directly import Member

fervent shoal
sick birch
#

Would be less confusing if you didn't from discord import Member, and just used discord.Member

frank tartan
#
@client.event
async def on_message_delete(message):
    logChanID = db(f"logChan-{message.guild.id}")
        
    if logChanID == "None":
      return

    logChan = client.get_channel(logChanID)
        
    msgCHAN = message.channel.mention
    embed = discord.Embed(title=f"Deleted Message",description=f"{message.content}", color=0xFF0000)
    embed.add_field(name=f"Channel", value=f"{msgCHAN}")
    embed.set_author(name=message.author)
    embed.set_footer(text="View audit log for more information.")
    await logChan.send(embed=embed)

that is my code

Ignoring exception in on_message_delete
Traceback (most recent call last):
  File "/home/runner/Database-testing/venv/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 57, in on_message_delete
    logChanID = db(f"logChan-{message.guild.id}")
TypeError: 'Database' object is not callable

thats my error message
im using replit db

bold surge
sick birch
#

Looks like it's deprecated

bold surge
#

😔 f

neat tartan
slate swan
#

Why you even gotta friend a bot in the first place

bold surge
#

why not tho

#

¯_(ツ)_/¯

slate swan
sick birch
fervent shoal
#

these errors

slate swan
#

how can i learn programming language

sick birch
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

neat tartan
sick birch
#

Don't have to, if you don't get yourself confused and don't mind the namespace a little bit more filled up it really doesn't make a difference

#

But if you want to you can easily change it with some nifty Find & Replace

bold surge
timid wagon
#

Or Ctrl+Shift+H for the entire directory - if you have cogs

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_emojis_update(self, guild, before, after):

        async for t in guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.emoji_delete):

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            with open(enable_path, "r") as f:
                enabled = json.load(f)

            if not str(guild.id) in enabled:
                return

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(t.user.id) in whitelisted[str(guild.id)]:
                return

            remove_emoji = [r for r in before if r not in after]

            for em2 in remove_emoji:
                before_emoji = await em2.read()
                try:
                    if remove_emoji:
                        await guild.ban(t.user, reason="Anti-Nuke: Deleting Emojis")
                        try:
                            emoji_display = await guild.create_custom_emoji(name=em2.name, image=before_emoji)
                            try:
                                if str(guild.id) in config_channel:
                                    log_channel = self.angel.get_channel(int(channel_id))
                                    embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**EMOJI LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{t.user}`\nID: `{t.user.id}`\nPing: {t.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member deleted a emoji!\n\n**__BEFORE__**\n\nEmoji Name: `{em2.name}`\nID: `{em2.id}`\n\n**__AFTER__**\n\nEmoji Name: `{emoji_display.name}`\nID: `{emoji_display.id}`\nEmoji: {emoji_display}\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Emoji has been replaced! (If asset was found!)", color=discord.Color.from_rgb(black1, black2, black3))
                                    await log_channel.send(embed=embed)
                            except:
                                pass
                        except:
                            pass
                except:
                    continue

        async for i in guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.emoji_create):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(guild.id)]:
                return

            add_emoji = [r for r in after if r not in before]

            for em1 in add_emoji:
                if add_emoji:
                    await guild.ban(i.user, reason="Anti-Nuke: Creating Emojis")
                    await em1.delete()
neat tartan
dry kelp
#

why is this code blocking?

#

i mean not continuing

#

if a emoji is created to delete the emoji

bold surge
#

this again :I

sick birch
dry kelp
#

it happens when the channel is not foung in the guild id

dry kelp
sick birch
#

JSON causes all sorts of annoying issues like this, I really do suggest you use something more robust like a database

dry kelp
#

Robin i will keep using json for now.. thanks tho

#

do you know how can i pass the code if the channel is not found in the guild.id?

#

that would be great

sick birch
#
if channel not in guildID:
  pass
dry kelp
#

that's why i keep using try:except pass

#

is not really workin

neat tartan
sick birch
sick birch
#

Registering one cog would register all the commands within, and it allows you to hot-reload your bot (have code changes take effect without turning off and on the bot)

timid wagon
dry kelp
#
            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            if str(channel_id) not in config_channel[str(guild.id)]:
                pass
dry kelp
#

reason why im trying to pass that

#

basically it shouldn't send the logs

timid wagon
#

You should probably get a NoneType if there is no channel under that guild

#

So you can check for that accordingly and pass the case

neat tartan
dry kelp
#

it wont send the error because

#

the 2nd part won't run

#

cuz the channel is not found in the first code

trim fulcrum
dry kelp
#

line 72 is blockage

#

it won't continue if the channel is not found in the 1st code like i said

#

so i gotta pass that

#

somehow

#

anyone know how to fix that?

dry kelp
#

robin what should i use? pout

#

if the channel is found

#

it works

#

i can't fucking understand this shit anymore

neat tartan
#

How are you currently trying to grab the channel because that line would be wher the issue actually is

dry kelp
#

so imma tell what's going again

#

if the channel is not found the code won't continue (it will not delete the emoji when is created) and is going to be stuck in that loop.. that's why i'm trying to pass it if the channel is not found basically pass the channel and not send the logs

#
            for em2 in remove_emoji:
                before_emoji = await em2.read()
                try:
                    if remove_emoji:
                        await guild.ban(t.user, reason="Anti-Nuke: Deleting Emojis")
                        try:
                            emoji_display = await guild.create_custom_emoji(name=em2.name, image=before_emoji)
                            try:
                                if str(channel_id) not in config_channel[str(guild.id)]:
                                    if str(guild.id) in config_channel:
                                        log_channel = self.angel.get_channel(int(channel_id))
                                        embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**EMOJI LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{t.user}`\nID: `{t.user.id}`\nPing: {t.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member deleted a emoji!\n\n**__BEFORE__**\n\nEmoji Name: `{em2.name}`\nID: `{em2.id}`\n\n**__AFTER__**\n\nEmoji Name: `{emoji_display.name}`\nID: `{emoji_display.id}`\nEmoji: {emoji_display}\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Emoji has been replaced! (If asset was found!)", color=discord.Color.from_rgb(black1, black2, black3))
                                        await log_channel.send(embed=embed)
                                pass
                            except:
                                pass
                        except:
                            pass
                except:
                    continue
#

should i try this? even tho doesn't make ah lot of sense

vocal snow
#

What's with all the bare excepts lol

dry kelp
#

i gotta try multiple things

#

maybe the emoji asset fails so i gotta except that

#

another try is to get the log channel

vocal snow
#

It's just suppressing every single exception though

dry kelp
#

and the main try is to continue

#

na they're different things

vocal snow
#

Sure. But that's not good design

dry kelp
#

it looks bad on discord tbh

#

i will try to see if that pass actually does smth

#

brb

#

ofc not

pallid mango
#

hey does anyone have a vanityroles bot? like say a user puts my vanity link in their status the bot auto gives them a role

dry kelp
#
            for em2 in remove_emoji:
                before_emoji = await em2.read()
                try:
                    if remove_emoji:
                        await guild.ban(t.user, reason="Anti-Nuke: Deleting Emojis")
                        try:
                            emoji_display = await guild.create_custom_emoji(name=em2.name, image=before_emoji)
                            try:
                                if str(channel_id) in config_channel[str(guild.id)] and str(guild.id) in config_channel:
                                    log_channel = self.angel.get_channel(int(channel_id))
                                    embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**EMOJI LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{t.user}`\nID: `{t.user.id}`\nPing: {t.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member deleted a emoji!\n\n**__BEFORE__**\n\nEmoji Name: `{em2.name}`\nID: `{em2.id}`\n\n**__AFTER__**\n\nEmoji Name: `{emoji_display.name}`\nID: `{emoji_display.id}`\nEmoji: {emoji_display}\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Emoji has been replaced! (If asset was found!)", color=discord.Color.from_rgb(black1, black2, black3))
                                    await log_channel.send(embed=embed)
                            except:
                                pass
                        except:
                            pass
                except:
                    continue
#

makes more sense checking both things

#

is a wrong check

#

awesome

sick birch
pallid mango
#

i dont know how to 😦

frank tartan
#
@client.event
async def on_message_delete(message):
    logChanID = db(f"logChan-{message.guild.id}")
        
    if logChanID == "None":
      return

    logChan = client.get_channel(logChanID)
        
    msgCHAN = message.channel.mention
    embed = discord.Embed(title=f"Deleted Message",description=f"{message.content}", color=0xFF0000)
    embed.add_field(name=f"Channel", value=f"{msgCHAN}")
    embed.set_author(name=message.author)
    embed.set_footer(text="View audit log for more information.")
    await logChan.send(embed=embed)

that is my code

Ignoring exception in on_message_delete
Traceback (most recent call last):
  File "/home/runner/Database-testing/venv/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 57, in on_message_delete
    logChanID = db(f"logChan-{message.guild.id}")
TypeError: 'Database' object is not callable

thats my error message
im using replit db

dry kelp
#

now even if the channel is added it won't do anything

#

like it won't continue

sick birch
unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

• nickname

• roles

• pending...
pallid mango
#

hold up

#

CRAP

#

i forgot to remove my vanity

#
@client.event
async def on_member_update(before, after):
    if str(before.status) == "":
        if str(after.status) == "":
            guild = client.get_guild(932840827212931123)
            role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
            await after.add_roles(role)```
#

there

dry kelp
#
            for em2 in remove_emoji:
                before_emoji = await em2.read()
                try:
                    if remove_emoji:
                        await guild.ban(t.user, reason="Anti-Nuke: Deleting Emojis")
                        emoji_display = await guild.create_custom_emoji(name=em2.name, image=before_emoji)
                        if str(guild.id) in config_channel:
                            log_channel = self.angel.get_channel(int(channel_id))
                            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**EMOJI LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{t.user}`\nID: `{t.user.id}`\nPing: {t.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member deleted a emoji!\n\n**__BEFORE__**\n\nEmoji Name: `{em2.name}`\nID: `{em2.id}`\n\n**__AFTER__**\n\nEmoji Name: `{emoji_display.name}`\nID: `{emoji_display.id}`\nEmoji: {emoji_display}\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Emoji has been replaced! (If asset was found!)", color=discord.Color.from_rgb(black1, black2, black3))
                            await log_channel.send(embed=embed)
                except:
                    continue
sick birch
#

Don't worry yourself with what it was before

#

as long as it has the vanity after you should be good

pallid mango
#

?

#

oh i see

sick birch
#

It doesn't matter what the user's status was before

#

Also make sure remove the role once the user removes the vanity from their status, it's the same thing except in reverse

pallid mango
#
@client.event
async def on_member_update(before, after):
    if str(after.status) == "":
        guild = client.get_guild(932840827212931123)
        role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
        await after.add_roles(role)```
#

oh

sick birch
#

and maybe instead of == you can use in for greater flexibility: that way,
this status would give them the role:

join discord.gg/somelink!
dry kelp
#

@sick birch how can i check if the guild id or channel is not in the json

#

n to continue otherwise

pallid mango
#
@client.event
async def on_member_update(before, after):
    if str(after.status) in "":
        if str(before.status) in "":
          guild = client.get_guild(932840827212931123)
          role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
          await after.add_roles(role)```
#

like this?

final iron
#

Why are you using json in the first place

#

It's not a database

sick birch
#

Like I mentioned before if channelID not in guildID: continue

pallid mango
#

oof

sick birch
#

crap

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_emojis_update(self, guild, before, after):

        async for t in guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.emoji_delete):

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            if str(channel_id) not in config_channel[str(guild.id)]:
                continue
#

like this?

slim ibex
#

Use SQLite instead of json

sick birch
#
if vanity in after status:
  # give role
if vanity not in after status:
  # take away role
pallid mango
#

wut

frank tartan
#
@client.event
async def on_message_delete(message):
    logChanID = db(f"logChan-{message.guild.id}")
        
    if logChanID == "None":
      return

    logChan = client.get_channel(logChanID)
        
    msgCHAN = message.channel.mention
    embed = discord.Embed(title=f"Deleted Message",description=f"{message.content}", color=0xFF0000)
    embed.add_field(name=f"Channel", value=f"{msgCHAN}")
    embed.set_author(name=message.author)
    embed.set_footer(text="View audit log for more information.")
    await logChan.send(embed=embed)

that is my code

Ignoring exception in on_message_delete
Traceback (most recent call last):
  File "/home/runner/Database-testing/venv/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 57, in on_message_delete
    logChanID = db(f"logChan-{message.guild.id}")
TypeError: 'Database' object is not callable

thats my error message
im using replit db

pallid mango
#

im kinda new to coding so like could u try to dumb down even more pls

sick birch
#

That's psuedocode, I can't really simplify that any further

dry kelp
#

robin is still not working

sick birch
#

Not sure, it's stumped me at this point as well

pallid mango
sick birch
#

Inside the on_member_update event

slim ibex
sick birch
#

And yes discord.py is not necessarily a beginner library, you should have a pretty decent understanding of the language before proceeding as it will make things much easier for you to work with

final iron
#

I'm assuming you're not supposed to do that

slim ibex
#

You need a strong understanding of OOP and async programming

sick birch
#

for sure

#

Maybe not strong but at least intermediate

frank tartan
slim ibex
#

Not a key value db

sick birch
frank tartan
dry kelp
#

1 step closer @sick birch

#
                        if str(guild.id) in config_channel:
                            log_channel = self.angel.get_channel(int(channel_id))
                            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**EMOJI LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{t.user}`\nID: `{t.user.id}`\nPing: {t.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member deleted a emoji!\n\n**__BEFORE__**\n\nEmoji Name: `{em2.name}`\nID: `{em2.id}`\n\n**__AFTER__**\n\nEmoji Name: `{emoji_display.name}`\nID: `{emoji_display.id}`\nEmoji: {emoji_display}\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Emoji has been replaced! (If asset was found!)", color=discord.Color.from_rgb(black1, black2, black3))
                            await log_channel.send(embed=embed)
                        else:
                            continue
#

the continue does it's job here

#

but if the logs are off like no guild id

#

it won't work

frank tartan
# sick birch You access and set values using `[]`, not `()`

Ignoring exception in on_message_delete Traceback (most recent call last): File "/home/runner/Database-testing/venv/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event await coro(*args, **kwargs) File "main.py", line 69, in on_message_delete await logChan.send(embed=embed) AttributeError: 'NoneType' object has no attribute 'send'

I get that error now...

slim ibex
#

logChan is none

#

If it isn’t a channel ID, there is no way to send a message to it

final iron
#

Fix your variable names. They should be in snake_case

frank tartan
slim ibex
#

just follows pep8

frank tartan
slim ibex
#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

slim ibex
#

you don’t wanna build bad practices

frank tartan
frank tartan
slim ibex
#

that is JavaScript, c#, etc

#

well c# is mostly PascalCase I think

frank tartan
frank tartan
slim ibex
#

lmao what the fuck

final iron
slim ibex
#

I’m sorry but those teachers don’t know what they are doing

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

frank tartan
frank tartan
final iron
slim ibex
#

idk I’m not the school

frank tartan
dry kelp
final iron
#

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

#

Taken directly from the pep8 documentation

frank tartan
final iron
#

Is the id correct?

frank tartan
final iron
#

Are you using get or fetch?

frank tartan
final iron
#

Can you send the code?

frank tartan
# final iron Can you send the code?
@client.event
async def on_message_delete(message):
    logChanID = db[f"logChan-{message.guild.id}"]
        
    if logChanID == "None":
      return
    print(logChanID)
    logChan = client.get_channel(logChanID)
        
    msgCHAN = message.channel.mention
    embed = discord.Embed(title=f"Deleted Message",description=f"{message.content}", color=0xFF0000)
    embed.add_field(name=f"Channel", value=f"{msgCHAN}")
    embed.set_author(name=message.author)
    embed.set_footer(text="View audit log for more information.")
    await logChan.send(embed=embed)
final iron
#

Oh you're getting it from the database

#

Wait

frank tartan
frank tartan
final iron
#

logChan = client.get_channel(logChanID)

#

Are you using disnake?

frank tartan
final iron
#

Damn

frank tartan
final iron
#

Disnake has getch

#

So get gets the channel from the cache

#

If its not in the cache it returns None

#

Therefore if its None you need to fetch it

frank tartan
final iron
#

!d discord.ext.commands.Bot.fetch_channel

unkempt canyonBOT
#

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

Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID.

Note

This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.

New in version 1.2.
final iron
#

Make a check with an if statement. If get returns None use fetch

frank tartan
final iron
#

You can use is None but yes

#

Indentation is also funky

frank tartan
frank tartan
# final iron You can use `is None` but yes
Ignoring exception in on_message_delete
Traceback (most recent call last):
  File "/home/runner/Database-testing/venv/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 64, in on_message_delete
    logChan = await fetch_channel(logChanID)
NameError: name 'fetch_channel' is not defined
sick birch
#

pretty useful function to have ^

slim ibex
#

oh wait that’s smart

sick birch
#

Indeed, thought it was pretty cool when I was taking a peek inside

final iron
#

Thats what getch does

slate swan
#

is there a way i can delete the dropdown after its been interacted with once?

sick birch
#

!d discord.Interaction.delete_original_message

unkempt canyonBOT
#

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

Deletes the original interaction response message.

This is a lower level interface to [`InteractionMessage.delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.InteractionMessage.delete "discord.InteractionMessage.delete") in case you do not want to fetch the message and save an HTTP request.
frank tartan
slate swan
#

i want to delete it as soon as it has been interacted with

final iron
unkempt canyonBOT
#

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

Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID.

Note

This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.

New in version 1.2.
final iron
#

It would be self.bot.fetch_channel in a cog

frank tartan
final iron
#

...

#

You follow a lot of bad practices

sick birch
#

guild.fetch_channel() normally

frank tartan
final iron
#

bot.fetch_channel also works but using guild.fetch_channel is faster

final iron
sick birch
frank tartan
final iron
#

Less channels to go through with guild.fetch_channel

sick birch
#

That's get_channel, fetch_* all make API requests

final iron
#

I know it still makes an api request

sick birch
#

You mean server-side?

final iron
#

Yes

final iron
frank tartan
sick birch
#

Well still should just be O(1) since it's just doing a lookup, but obviously discord's backend is quite complex and difficult for non employees to measure

#

So I think for most purposes bot.fetch_channel may be just a very tiny amount slower, basically negligible

final iron
#

Just to note I'm going off what other people say

#

I haven't tested this myself

#

I know its going to make a very little difference I just want them to be informed

final iron
frank tartan
final iron
#

If you don't use cogs you cannot create different categories

sick birch
#

discord channel categories?

frank tartan
final iron
final iron
#

If you're not doing it in cogs you don't have a way to do that automatically

frank tartan
# final iron In a help command you create different categories i.e Fun, Utility, Economy
@client.command()
async def help(ctx):
  author = ctx.author

  
  async def fButtonReply(interaction):
    if interaction.user != ctx.author:
            await interaction.user.send("Hey! You can't do that!")
            return
    await message.edit(embed=fEmbed)
  
  async def iButtonReply(interaction):
    if interaction.user != ctx.author:
            await interaction.user.send("Hey! You can't do that!")
            return
    await message.edit(embed=iEmbed)
  
  async def eButtonReply(interaction):
    if interaction.user != ctx.author:
            await interaction.user.send("Hey! You can't do that!")
            return
    await message.edit(embed=Eembed)
  
  async def mButtonReply(interaction):
    if interaction.user != ctx.author:
            await interaction.user.send("Hey! You can't do that!")
            return
    await message.edit(embed=Membed)

  async def uButtonReply(interaction):
    if interaction.user != ctx.author:
            await interaction.user.send("Hey! You can't do that!")
            return
    await message.edit(embed=uEmbed)

  eButton.callback = eButtonReply
  fButton.callback = fButtonReply
  iButton.callback = iButtonReply
  uButton.callback = uButtonReply
  mButton.callback = mButtonReply
  

  view = View()
  view.add_item(eButton)
  view.add_item(fButton)
  view.add_item(iButton)
  view.add_item(uButton)
  view.add_item(mButton)

  message = await ctx.send(embed=Membed, view=view)
#
  Eembed=discord.Embed(title="Emojis", description="Uploads a bunch of selected emojis.")
  Eembed.add_field(name="Football Fusion", value=f"`{PREFIX}emoji ff` uploads ff emojis", inline=True)
  Eembed.add_field(name="NFL", value=f"`{PREFIX}emoji nfl` uploads nfl emojis", inline=True)
  Eembed.set_footer(text=f"Requested By: {author}") 

  iEmbed=discord.Embed(title="Emojis", description="Uploads a bunch of selected emojis.")
  iEmbed.add_field(name="Invite", value=f"`{PREFIX}invite`", inline=True)
  iEmbed.add_field(name="Ping", value=f"`{PREFIX}ping`", inline=True)
  iEmbed.add_field(name="Server Info", value=f"`{PREFIX}serverinfo`", inline=True)
  iEmbed.add_field(name="Member Count", value=f"`{PREFIX}membercount`", inline=True)
  iEmbed.add_field(name="Invite", value=f"`{PREFIX}cinvite` creates a invite.")
  iEmbed.set_footer(text=f"Requested By: {author}") 

  fEmbed=discord.Embed(title="Formating", description="Formating Text")
  fEmbed.add_field(name="Bolding", value=f"`{PREFIX}bold <text>` bolds the text", inline=True)
  fEmbed.add_field(name="italic", value=f"`{PREFIX}italic <text>` italics the text", inline=True)
  fEmbed.set_footer(text=f"Requested By: {author}")

  uEmbed=discord.Embed(title="Utilitie", description="Utilitie Commands")
  iEmbed.add_field(name="Purge", value=f"`{PREFIX}purge <# of messages>` deletes the specified amount of messages.", inline=True)
  uEmbed.add_field(name="dm", value=f"`{PREFIX}dm <@ user> <message>` dms the specified user with the specified message.", inline=True)
  uEmbed.add_field(name="allowDM", value=f"`{PREFIX}allowDM [enable/disable]` enables or disables the ability for people to dm you using the bot.", inline=True)
#
  Membed=discord.Embed(title="Help", description="Click the corosponding button.")
  Membed.add_field(name="Emojis", value="`😀 emojis`", inline=True)
  Membed.add_field(name="Formating", value="`💽 format`", inline=True)
  Membed.add_field(name="Info", value="`📜 info`", inline=True)
  Membed.add_field(name="Utilitie", value=f"`🔧 Utilitie`", inline=True)
  Membed.add_field(name="Menu", value="`❌ Menu`", inline=True)
  
  Membed.set_footer(text=f"Requested By: {author}")

  eButton = Button(label=':grinning: emojis', style=discord.ButtonStyle.green)
  fButton = Button(label=':minidisc: format')
  iButton = Button(label=':scroll: info', style=discord.ButtonStyle.primary)
  mButton = Button(label=':x: Menu', style=discord.ButtonStyle.red)
  uButton = Button(label=':wrench: Utilitie')
slim ibex
#

wtf

frank tartan
#

i did that with one of them

final iron
#

You're hard coding it

frank tartan
final iron
#

Every time you make a command you have to add it

final iron
#

It's a very bad idea

slim ibex
#

^

final iron
#

All I have to do is spend a couple of hours subclassing my help command(Only have to do it once) and then it's going to work no matter how many cogs/commands I add

slim ibex
#

put it in a view

#

and yeha subclass

slim ibex
#

!d discord.ext.commands.MinimalHelpCommand

unkempt canyonBOT
#

class discord.ext.commands.MinimalHelpCommand(*args, **kwargs)```
An implementation of a help command with minimal output.

This inherits from [`HelpCommand`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HelpCommand "discord.ext.commands.HelpCommand").
frank tartan
#

while i dont

final iron
#

1 time

#

I spend 3 hours 1 time and I never have to bother with it again

frank tartan
#

its not that hard

final iron
#

But you have to do it every time

#

Over and over and over again

frank tartan
final iron
#

Ask anyone. It's a terrible idea

final iron
#

It also creates spaghetti code

sick birch
#

Also subclassing help command makes it dynamic

frank tartan
final iron
#

That's my whole point

#

It's dynamic. Do it once and you never have to do it again

frank tartan
#

what?

#

its tasty

pallid mango
#
@client.event
async def on_member_update(before, after):
    if "discord.gg/" in str(after.status):
      guild = client.get_guild(932840827212931123)
      role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
      await after.add_roles(role)```
#

what am i doing wrong !!

neat pagoda
#

Is there anyway to stream a tab on a discord bot?

slate swan
pallid mango
#

oof

slate swan
unkempt canyonBOT
slate swan
#

use this

neat tartan
slate swan
pallid mango
#
@client.event
async def on_member_update(before, after):
    if "discord.gg/" in str(after.discord.Activity.name):
      guild = client.get_guild(932840827212931123)
      role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
      await after.add_roles(role)```
neat pagoda
#

like where you can watch videos in vc

#

I thought I recalled someone showing me a bot like that

slate swan
#

i dont mean like youtube, youtube together is a discord feature..

neat pagoda
#

ok

slate swan
#

would be the thing

slate swan
pallid mango
#
@client.event
async def on_member_update(before, after):
    if "discord.gg/" in str(after.Activity.name):
      guild = client.get_guild(932840827212931123)
      role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
      await after.add_roles(role)```
slate swan
#

notice that the a in activity is lower cased :0

pallid mango
#

oh

neat pagoda
pallid mango
#

okay now how do i make it take the role if it isnt in their status

slate swan
#

how do i delete a dropdown message after it has been interacted with?
do i delete them like normal messages or

nimble plume
#

I was making a afk command in which the afk syatus is set as a variable : ctx.author.mention
AFK = []
But sometimes it didnt take the @ like 4974972397493 is user id and @ivory jackal this is mention sometimes it store it as <8794749724434>

#

Help..

unkempt canyonBOT
slate swan
#

use this?

#

or message.mentions

#

🤣 why are u trying to delete it

slate swan
slate swan
slate swan
dusty onyx
#

!d discord.Member.mentioned_in

#

!d discord.Member.mentioned_in

unkempt canyonBOT
dusty onyx
#

!d discord.Member.mentioned_in

unkempt canyonBOT
slate swan
#

um?

#

#bot-commands

pallid mango
#
@client.event
async def on_member_update(before, after):
    if ".gg/" in str(after.activity.name):
      guild = client.get_guild(932840827212931123)
      role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
      await after.add_roles(role)```
slate swan
#

and paid

pallid mango
#

how do i make it take the role when i remove my vanity

slate swan
slate swan
slate swan
sick birch
# slate swan hey suggest me some free hosting sites

There aren't that many good free hosting, it's alright for smaller bots but you should decide on an industry standard hosts such as AWS or Google cloud hosting for when you might need to migrate in the future

pallid mango
sick birch
#

Or you can buy yourself a raspberry pi, bit of an initial investment but might pay off in the log run, you can also do other stuff with it

pliant gulch
#

Over time a raspberry pi would most likely end up costing more money than renting a cheap vps

slate swan
sick birch
#

do you have the guild object?

pliant gulch
#

You would need to do maintenance, pay electricity bills, wifi bills etc

sick birch
#

How'd you get the guild ID?

pliant gulch
#

Cost of scale is also there

sick birch
#

Definitely doesn't scale

sick birch
#

it's the same

slate swan
#

same thing..

#

and how do i import it

sick birch
#

the same way you would in disnake

slate swan
sick birch
#

well

slate swan
sick birch
#

disnake is a fork of discord.py, so many things are the same

slate swan
#

from discord.ext import tasks, commands

#

like this?

#

yea, would work

slate swan
#

why did they create a fork tho , what is the difference

sick birch
slate swan
#

so everyone should use disnake?

slate swan
sick birch
#

Not necessarily

#

There are other discord.py forks, and other libraries that are built from the ground up

slate swan
slate swan
#

so there are forks
disnake, nextcord, pycord, enhanced-dpy are some popular ones

#

oh

sick birch
#

I recommend base discord.py as I don't like any of the forks much, but it's personal preference

slate swan
#

interesting

sick birch
#

But don't take my word for it

#

Try the different ones and find out which you like best

slate swan
#

ill suggest disnake in general, but if you want to try something different hikari is a good choice too

#

i have tried both dpy and disnake , they both have awesome communities

pliant gulch
#

Discord.py is already semi out-dated now with the new features added at least. I wouldn't say the codebase is quite tidy either

sick birch
#

Nah i've looked at the code base, kind of weird in some place

#

agree with you on that one

#

but i haven't worked on discord bots in a little bit so there's that

vocal snow
slate swan
#

not really

#

they are and allot

sick birch
#

We all have had different experiences with those communities, if they've had an awesome experience, well, that's awesome!

slate swan
#

it aint toxic, they just expect a bit more from the library users :)

pliant gulch
sick birch
slate swan
#

they expect no beginners

slate swan
#

theyll always be someone that doesnt know

slate swan
sick birch
#

You should have a pretty decent understanding of python before you attempt discord.py, which is reflected on the community

#

Only makes things harder for you in the long run

#

all fetch_* message need to be awaited

#

all get_* message do not need to be awaited as they only do a cache lookup

#

You're on the right track, just you have them flipped

slate swan
#

they mean, you dont await get_s

#

and you need to await fetch_s

#

because its Messageable.fetch_message

#

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

its not a Guild method

distant pike
distant pike
distant pike
slate swan
#

also, its not recommended to use 3rd party libraries for components, just use the master branch or some fork

slate swan
distant pike
#

nope

slate swan
#

try pip install discord-components and see if it says requirement already satisfied

distant pike
maiden mortar
#

Hey there , i am trying to make a bot that does custom link preview for YouTube music links, it will post a link to that song on YouTube as well as Spotify , how do I go about it ,web scrapping or is there a better way to do it ?

slate swan
#

forks give you slash commands too....

#

anyways, did you try restarting your ide??

distant pike
slate swan
distant pike
#

i also tested it on pycharm and didnt work

slate swan
#

is it same as the python interpreter you installed the library in

distant pike
slate swan
#

i dont know either, because im a visual studio code user
try looking for something named configurations

#

also , try pip show discord-components in the ide's terminal

distant pike
# slate swan also , try `pip show discord-components` in the ide's terminal

Name: discord-components
Version: 2.1.2
Summary: An unofficial library for discord components.
Home-page: https://github.com/kiki7000/discord.py-components
Author: kiki7000
Author-email: devkiki7000@gmail.com
License: MIT License
Location: c:\python39\lib\site-packages
Requires: aiohttp, discord.py
Required-by:
PS C:\Users\Blake\Desktop\d.py bot>

GitHub

An unofficial third-party library of discord.py for discord components. - GitHub - kiki7000/discord.py-components: An unofficial third-party library of discord.py for discord components.

slate swan
#

mhm it means that its installed

slate swan
#

or visual studio? they are different

distant pike
#

yeah im using vsc

slate swan
distant pike
#

yup

slate swan
distant pike
#

still get the error

slate swan
#

same error?

distant pike
#

yup

#

the exact error is File "c:\Users\Blake\Desktop\d.py bot\main.py", line 4, in <module> from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType ModuleNotFoundError: No module named 'discord_components'

slate swan
distant pike
slate swan
#

hmm try using the web installation instead of installing it from ms store

distant pike
#

how would i get rid of the ms store version?

slate swan
#

it allows you to uninstall it..

distant pike
#

oh lmao

vocal snow
#

You need to pass a value to add_field

#

Are you sure you're passing a non-empty string

distant pike
boreal ravine
slate swan
distant pike
#

i did lol

distant pike
slate swan
#

since you uninstalled the previous installation, you would have to install things again

distant pike
#

i uninstalled and reinstalled d.py and still broken lol

slate swan
#

👀 click on the python 3.10.2 thing and see what options it shows

#

does it show more than 1 option?