#discord-bots

1 messages · Page 102 of 1

short silo
#

wand might be what you are looking for

slate swan
#

I think pil should work

short silo
#

whatever u prefer

robust fulcrum
#

What do override mean?
And how would it make making bot easy?

white citrus
#
    @nextcord.slash_command(name="userinfo", description="Shows you a user info of a user!")    
    @custom_check.has_moderation_and_admin_role_interaction()
    @custom_check.If_User_on_UserBlacklist_Slash()
    @cooldowns.cooldown(1, 25, bucket=cooldowns.SlashBucket.guild)
    async def userinfo(self, interaction: nextcord.Interaction,
                       _member: nextcord.Member = SlashOption(name="member", description="Please select a member", required=False)):
        
        member = _member or interaction.user

        wait = nextcord.Embed(description=f" Please wait. I'm just gathering all the information for you {config.DiscordLoad}", colour=config.red)


        await interaction.response.send_message(embed=wait)

            
            
        de = pytz.timezone('Europe/Berlin')
        


        @nextcord.ui.button(label="Show all Roles", style=nextcord.ButtonStyle.blurple)
        async def show_member_roles(interaction: nextcord.Interaction):
            embed_roles = nextcord.Embed(description=member.roles)
            await interaction.edit_original_message(embed=embed_roles)  
        
        button = await show_member_roles(interaction)
        await self.universal_log_embed_slash(interaction, _member=_member)        
        await interaction.edit_original_message(embed=userinfo, view=button)```

He is not sending the button, why?
unkempt canyonBOT
naive briar
#

interaction always comes first

slate swan
cerulean depot
#

is it somehow possible to mention a role in the footer of an embed?

slate swan
#

it doesn't work in titles

naive briar
#

!d discord.Embed - Markdowns don't work in embed titles. Use the url argument if you want to put a hyperlink in the title

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, 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.

x == y Checks if two embeds are equal.

New in version 2.0...
cerulean depot
#

what catgal just said

uncut comet
#
    valorant = app_commands.Group(name="valorant", description="Valorant Commands")
    #@app_commands.command(description='Valorant Commands')
    #async def valorant(self, ctx):
    #    await ctx.send("WIP val commands")
    @valorant.command(description='Log in with your Riot acoount')
    #@valorant.describe(username='Input username', password='Input password')
    # @dynamic_cooldown(cooldown_5s)
    async def login(self, interaction: Interaction, username: str, password: str) -> None:

        response = ResponseLanguage(interaction.command.name, interaction.locale)

i am trying to make sub commands for app_commands but now they arent appearing when i sync the commands and try to type them out am i mission something? when i print out the sync it isnt in the list

cerulean depot
#

should work like that

naive briar
#

You have to defer the interaction if it takes longer than 3 seconds

white citrus
#

I want it to display the roles one below the other like:

@role1
@role2

Etc

naive briar
#

ctx.defer?

sick birch
#

hmph

#

!d discord.InteractionResponse.defer

unkempt canyonBOT
#

await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.

This is only supported with the following interaction types...
sick birch
#

There

white citrus
#
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 390, in _scheduled_task
    await item.callback(interaction)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\information\cog.py", line 197, in button_callback
    embed_roles = nextcord.Embed(description=f"{member.roles.join()}\n")
AttributeError: 'list' object has no attribute 'join'
            embed_roles = nextcord.Embed(description=f"{member.roles.join()}\n")
            await interaction.response.send_message(embed=embed_roles, ephemeral=True)  ```
unkempt canyonBOT
#

Joining Iterables

If you want to display a list (or some other iterable), you can write:

colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
    output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '

However, the separator is still added to the last element, and it is relatively slow.

A better solution is to use str.join.

colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'

An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.

integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
white citrus
#

I use it

naive briar
# white citrus I use it

You certainly did not. If you want to join a list of something, you have to use "".join, but you're trying to call it from a list

#

!e

print("\n".join(("Role 1", "Role 2")))
unkempt canyonBOT
#

@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | Role 1
002 | Role 2
white citrus
#

but Ignoring exception in view <View timeout=180.0 children=1> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Show all Roles' emoji=None row=None>: Traceback (most recent call last): File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 390, in _scheduled_task await item.callback(interaction) File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\information\cog.py", line 197, in button_callback embed_roles = nextcord.Embed(description="\n".join(member.roles)) TypeError: sequence item 0: expected str instance, Role found

naive briar
slate swan
#
        if reason == 'Apply To Be A Staff!':
            channel = await interaction.guild.create_text_channel(name=f"{interaction.user.display_name} ┃ Ticket", topic=f"{interaction.user.id}")
            msg = await interaction.response.send_message(f"**__Ticket Created Successfully__** {channel.mention}", ephemeral=True)
            embed = discord.Embed(title=f"{interaction.user} Created A Ticket!", description="Click The Button Below To Close The Ticket!")
            embed.add_field(name="סיבה:", value=f"> `{reason}`")
            await channel.set_permissions(interaction.guild.default_role, view_channel=False)
            await channel.set_permissions(interaction.user, view_channel=True)
            interaction.guild.get_role(1010395040385876029): discord.PermissionOverwrite(read_messages=True)
            await channel.send(f"{interaction.user.mention} <@&1010395040385876029>", embed=embed)```


File "c:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 584
interaction.guild.get_role(1010395040385876029): discord.PermissionOverwrite(read_messages=True)
^
SyntaxError: illegal target for annotation

#

what do i change it to then

primal token
#

remove the colon

slate swan
#

colon??

#

:

#

?

primal token
#

Yes

slate swan
primal token
#

And why are you calling Guild.get_role without making a reference?

slate swan
#

oh

#

like how do i do it

primal token
slate swan
#

like

brittle briar
#

Anyone know how to use requests to generate accounts on sites?

slate swan
#

i want that that role will be able to see that channel

primal token
brittle briar
#

Just a simple account creation

primal token
#

If it doesnt have documentation for the API endpoints you can probably just make an account and check the payload and the endpoint iirc

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

primal token
#

I doubt you can do anything malicious, e.g creating many accounts for spam

brittle briar
#

It’s just a quality of life thing

primal token
#

Most endpoints for making accounts have a short ratelimit and some ban with IP and its allot of info you would need to create for so much accounts

#

but iirc some sites dont like the automation of the creation of accounts

slate swan
#

Hey!

I'm making a disocrd bot and i want to add a feature that:

On /suggest they have a True or False statement asking if the suggestion is anonymous.

Example:

#

ticket system

brittle briar
#

Add to the ctx, anonymous: discord.Option(str, choices=[True, False], required=true)

quick gust
#

dont think he was answering you

brittle briar
#

I was responding to api

slate swan
#

OHH

#

what do i do

#

yes yes

#

likeee its not the whole code

#

Hey!

I want to make a /generate command that generates a KeyAuth code for a one of the products i own..

How would i do something like that?

#

OH

#

what about it lol

#

shareX

primal token
slate swan
#

np

slate swan
primal token
slate swan
slate swan
#

no

slate swan
#

i did just as they told in documentation but still im getting error

vocal snow
#

im guessing you forgot to import it?

slate swan
#

lol

#

i forgot to import

brittle briar
#

That’s what I put and works for me

slate swan
#

i got it now ty

slate swan
brittle briar
#

Ah alright thank you

primal token
#

!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:

slate swan
primal token
#

You'll also avoid further issues with namespaces

slate swan
#

namespace ?

primal token
#

A set of names

slate swan
#

ok

primal token
#

In computing, a namespace is a set of signs (names) that are used to identify and refer to objects of various kinds

slate swan
#

hey how do i set up intents

naive briar
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

naive briar
#

Th- they have different names...

white citrus
#

what is streaming in voice channel for an activity.type?

pliant lily
#

Hi!
I'm trying to make a modal for a ticket system. I successfully created the modal and a command to open it with a button.
But, a problem I have is that I have to make a slash command in order to make the button appear (not a problem there), but whenever I stop the bot then launch it again, if I try to use the button again from the previous message, it doesn't work.
What i'm trying to do is to send a message via the button making the button appear, then, if the bot has an update or have to restart, the users can still use the button to make a ticket.

I tried explaining the best way I could, ask me if you didn't understand.
Here's my code:

class Questionnaire(discord.ui.Modal, title="Créez votre ticket !"):
    nature = ui.TextInput(label="La nature de votre ticket", required=True, style=discord.TextStyle.short)
    explication = ui.TextInput(label="Votre explication", required=True, style=discord.TextStyle.long)

    async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.send_message(f"Merci ! Votre ticket viens d'être envoyé aux modérateurs!")

    async def on_error(self, interaction: discord.Interaction, error: Exception) -> None:
        await interaction.response.send_message("Quelque chose s'est produit... Impossible d'envoyer le ticket")

        traceback.print_tb(error.__traceback__)


@bot.hybrid_command(name="create_ticket")
async def create_ticket(ctx):
    button = Button(label="Créer un ticket", style=discord.ButtonStyle.blurple)
    view = View()
    view.add_item(button)

    async def button_callback(interaction):
        await interaction.response.send_modal(Questionnaire())

    button.callback = button_callback
    await ctx.send(view=view)

How can I do to make the modal open permanently, whatever if the bot restarted or not?

slate swan
#

is there a way to only purge a give users messages?

honest shoal
#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
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 [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
honest shoal
#

You need a check

#

An example is mentioned in the docs

honest shoal
#

When you restart the bot

pliant lily
honest shoal
honest shoal
#

Which library

naive briar
#

Your bot is an instance of the discord.Intents

warped mirage
#

Guys

#

in an embed, how can i add an image ? like a cdn.. discord link

slate swan
#

how do i delete the sent response in 5 seconds?

warped mirage
#

like at the bottom

naive briar
unkempt canyonBOT
#

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

This function returns the class instance to allow for fluent-style chaining.
warped mirage
grand willow
warped mirage
grand willow
warped mirage
#

im using a slash command

grand willow
#

embed.set_image() ig

warped mirage
grand willow
#

Theres no need for the *,

warped mirage
#

oh

slate swan
#

what is the asterisk for?

naive briar
# warped mirage how?

You can call that from an embed you're making, like so:

embed = discord.Embed(...)
embed.set_image(url="https://some.image/foo.png")
buoyant quail
#

Can webhooks reply to message?

tough lance
#
Ignoring exception in view <DeleteView timeout=60 children=2> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Take Single' emoji=None row=None>:
Traceback (most recent call last):
  File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/ui/view.py", line 370, in _scheduled_task
    await item.callback(interaction)
TypeError: one() takes 2 positional arguments but 3 were given
#
@discord.ui.button(label="Take Single", style=discord.ButtonStyle.green)
    async def one(self, inter):
        await self.bot.remove_cards(self.user, self.card, self.q)
        await inter.response.send_message(f"Deleted a single duplicate of selected card ({self.card}) from user's inventory.", view=None)
slate swan
#

button argument is missing

warped mirage
tough lance
slate swan
honest shoal
buoyant quail
#

k

#

thanks

north escarp
#
lol_role = discord.utils.get(ctx.message.guild.roles, name = 'Lol')
await member.add_roles(mute_role)```
how do I change this code so that the role is assigned to the author of command ?
glad cradle
north escarp
glad cradle
#

you can do this but remember to respond to the interaction

north escarp
glad cradle
#

a message can't be ephemeral

#

only interaction message can be ephemeral

primal token
# glad cradle a message can't be ephemeral

No, a message can be ephemeral only when responding to an interaction

https://support.discord.com/hc/en-us/articles/1500000580222-Ephemeral-Messages-FAQ

Q: When can bots send me ephemeral messages?

Bots can only send you this kind of message when you use a Slash Command. If the bot you're using hasn't implemented Slash Commands, they'll have to DM you instead.

this isnt completely correct either

#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
primal token
#

!d discord.Interaction.response

unkempt canyonBOT
#

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

primal token
#

Not exactly

glad cradle
#

and bots can send ephemeral message with user and message command too not only slash command, in general all interaction based things

primal token
#

message can be ephemeral only when responding to an interaction

glad cradle
#

Bots can only send you this kind of message when you use a Slash Command. If the bot you're using hasn't implemented Slash Commands, they'll have to DM you instead.

primal token
#

this isnt completely correct either

wicked atlas
#

Respond to the interaction, instead of just sending a message to the channel the interaction happened in, then you can use the ephemeral kwarg

await interaction.response.send_message(...)

Don't mind the arguments over wording, this happens a lot here :)

glad cradle
glad cradle
#

a message can be ephemeral also if you're not responding to an interaction, you can send a interaction followup with an ephemeral message too pithink pithink pithink

primal token
#

People make wrappers written in different languages, it's quite easy

wicked atlas
#

Do you mean programming languages, or actual languages?

primal token
wicked atlas
#

Webhook send methods do have the ephemeral kwarg

primal token
#

!d discord.Interaction.followup

unkempt canyonBOT
wicked atlas
#

ephemeral (bool) –

Indicates if the message should only be visible to the user. This is only available to WebhookType.application webhooks. If a view is sent with an ephemeral message and it has no timeout set then the timeout is set to 15 minutes.

New in version 2.0.

primal token
#

I wonder how they send ephemeral messages

wicked atlas
primal token
wicked atlas
glad cradle
primal token
#

Well then, since it depends on an interaction id to follow up a message with a webhook it would still be considered as responding to a specific interaction

glad cradle
wicked atlas
primal token
#

Question, what's the width of an interactions token?

white citrus
#

How can i check if a user is in my server

wicked atlas
#

Not sure if it's a static size though

hushed galleon
primal token
primal token
#

Maybe they depend on interaction type

wicked atlas
#

They don't really have anything documented on discord tokens for things like bots, webhooks, interactions, etc.

hushed galleon
#

^ tokens are merely a string we have to remember to make api requests

#

only sometimes does it come with extra information, like bot tokens having their application id inside them (was it app id or something else?)

sick birch
#

you just need to know where to pass them really

primal token
hushed galleon
#

well what more would you want from a token? currently they dont carry any information inside them, and whatever you would need to know about it is already part of the interaction payload it came with

primal token
#

The structure can be handy for something like parsing or/and identifying many tokens

merry walrus
#

After responding to an interaction, how can I delete the message sent?

hushed galleon
#

ah right

#

was that in the discord documentation? i gave it a quick glance but didnt find that diagram

#

i know there's one for snowflakes

hushed galleon
north escarp
#
    @commands.slash_command(name = 'verify', description=": /verify")
    async def __clearser__(self, interaction: discord.Interaction):

        view = MyView(interaction)
        embed = discord.Embed(description= f'**...**', colour=0xF1C40F)
        await interaction.response.send_message(embed=embed, view=view, delete_after=60)
        view = await view.wait()
        verify = discord.utils.get(interaction.response.guild.roles, name = 'Verified')
        await interaction.user.add_roles(verify)```
why does the code not work and does not issue a role ?
wicked atlas
slate swan
#

Traceback (most recent call last):
File "main.py", line 12, in <module>
import discord
File "/home/container/.local/lib/python3.8/site-packages/discord/init.py", line 25, in <module>
from .client import Client
File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 53, in <module>
from .webhook import Webhook
File "/home/container/.local/lib/python3.8/site-packages/discord/webhook/init.py", line 11, in <module>
from .async_ import *
File "/home/container/.local/lib/python3.8/site-packages/discord/webhook/async_.py", line 41, in <module>
from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/container/.local/lib/python3.8/site-packages/discord/channel.py)

north escarp
#
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 113, in wrapped
    ret = await coro(arg)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 762, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\reg.py", line 30, in __verified__
    view = MyView(interaction)
TypeError: __init__() missing 1 required positional argument: 'member'

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

Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 755, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 312, in invoke
    await injected(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 119, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: __init__() missing 1 required positional argument: 'member'```
@wicked atlas message ERROR
slate swan
wicked atlas
north escarp
#

That is, I wrote the command I got the role

wicked atlas
slate swan
#

yes

slate swan
wicked atlas
#

I'd guess somehow your install got messed up

slate swan
primal token
#

They discuss how the tokens are made but half of the process is missing

north escarp
#

@wicked atlas thanks man

slate swan
#
class ReName(discord.ui.Modal):
    def __init__(self):
        super().__init__("Ticket Rename")

        self.name = discord.ui.TextInput(
            label="New Ticket Name",
            min_length=2,
            max_length=25
        )
        self.add_item(self.name)

    async def callback(self, interaction: discord.Interaction) -> None:
        channel=interaction.channel
        await channel.edit(name=self.name.value)
        await interaction.response.send_message(f"שיניתי את השם של הטיקט ל: `{self.name.value}`")



class StaffTicket(discord.ui.View):
    def __init__(self):
       super().__init__(timeout=None)

    @discord.ui.button(label="rename", custom_id="staff_ticket:rename")
    async def rename(self, interaction: discord.Interaction, button: discord.ui.Button):
        if interaction.user.guild_permissions.administrator:
            modal=ReName()
            await interaction.response.send_modal(modal)
        else:
            return
    ```

[2022-10-07 23:50:35] [ERROR ] discord.ui.view: Ignoring exception in view <StaffTicket timeout=900.0 children=2> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='rename' emoji=None row=None>
Traceback (most recent call last):
File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\discord\ui\view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "c:\Users\PC\Desktop\AlonDaPro Bot\main.py", line 229, in rename
modal=ReName()
File "c:\Users\PC\Desktop\AlonDaPro Bot\main.py", line 206, in init
super().init("Ticket Rename")
TypeError: init() takes 1 positional argument but 2 were given```

hushed galleon
slate swan
#

ohhh ill try thanks!

hushed galleon
#

oh and for modals the method is called on_submit rather than callback

slate swan
#

ohhh okay

#

works!

#

thank you sm!

hushed galleon
slate swan
#

thank you sm!

slate swan
# hushed galleon if you ever forget you can reference the example on the documentation https://di...
    @discord.ui.button(label="Transcript", custom_id="staff_ticket:transcript")
    async def transcript(self, interaction: discord.Interaction, button: discord.ui.Button):
      channel=interaction.channel
      messages=await interaction.channel.history(limit=None, oldest_first=True).flatten()
      content=[message.content for message in messages]
      final= ""
      for msg in contents:
        msg=msg = "\n"
        final=final=msg
      with open('transcript.txt', 'm') as f:
          f.write(final)
      await interaction.response.send_message(file=discord.File(r'transcript.txt'), ephemeral=True)```
do you have any example for this? its not working
hushed galleon
#

whats not working about it? the history() call?

slate swan
#

its says

#

AttributeError: 'async_generator' object has no attribute 'flatten'

hushed galleon
slate swan
#

oh.

#

what do i do in the "..."

#

StaffTicket?"

hushed galleon
#

same thing you wrote in your history()

slate swan
#

ohh okay

#

i will try now

hushed galleon
#

you should also use an in-memory file like StringIO BytesIO instead of writing to a file on disk

slate swan
#

[2022-10-08 00:09:39] [ERROR ] discord.client: Ignoring exception in on_command_error Traceback (most recent call last): File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\discord\client.py", line 409, in _run_event await coro(*args, **kwargs) File "c:\Users\PC\Desktop\AlonDaPro Bot\main.py", line 155, in on_command_error raise error discord.ext.commands.errors.CommandNotFound: Command "tickets" is not found [2022-10-08 00:09:48] [ERROR ] discord.ui.view: Ignoring exception in view <StaffTicket timeout=900.0 children=2> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Transcript' emoji=None row=None> Traceback (most recent call last): File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\discord\ui\view.py", line 425, in _scheduled_task await item.callback(interaction) File "c:\Users\PC\Desktop\AlonDaPro Bot\main.py", line 240, in transcript for msg in contents: TypeError: 'function' object is not iterable

hushed galleon
#

your list is named content but the for-loop says contents

slate swan
#

ohhh

#

yeppp shows white now

hushed galleon
#

you might as well do async for message in channel.history(): content = message.content and then then write each line to the file

hushed galleon
#

like, to replace the middle half of your code

slate swan
#
    @discord.ui.button(label="Transcript", custom_id="staff_ticket:transcript")
    async def transcript(self, interaction: discord.Interaction, button: discord.ui.Button):
      channel=interaction.channel
      messages = [msg async for msg in channel.history(limit=None, oldest_first=True)]
      contents=[message.content for message in messages]
      final= ""
      for msg in contents:
        msg=msg +  "\n"
        final=final+msg
      with open('transcript.txt', 'msg') as f:
        f = open.BytesIO()
        f.seek(0)
      await interaction.response.send_message(discord_file = discord.File(f, filename='transcript.txt'), ephemeral=True)```
hushed galleon
hushed galleon
#

uh, you've completely mixed up writing to disk with open() and BytesIO

slate swan
#

oh

hushed galleon
#
  1. make the in-memory file
  2. write your content to the file
  3. set the file pointer back to the start
  4. use it in discord.File to upload the message
slate swan
#

i dont know how

hushed galleon
#

also you wrote msg=msg = "\n" and final=final=msg, but i think you meant to add the strings together with + instead

slate swan
#

oh oops

#
    @discord.ui.button(label="Transcript", custom_id="staff_ticket:transcript")
    async def transcript(self, interaction: discord.Interaction, button: discord.ui.Button):
      channel=interaction.channel
      messages = [msg async for msg in channel.history(limit=None, oldest_first=True)]
      contents=[message.content for message in messages]
      final= ""
      for msg in contents:
        msg=msg +  "\n"
        final=final+msg
      with open('transcript.txt', 'msg') as f:
        f = open.BytesIO()
        f.seek(0)
      await interaction.response.send_message(discord_file = discord.File(f, filename='transcript.txt'), ephemeral=True)```
hushed galleon
#

its just those last 4 lines you need to fix

hushed galleon
mental hollow
#

Why is if message.guild.id == MY_SERVER_ID: raising an AttributeError: 'NoneType' object has no attribute 'id'

hushed galleon
#

it means message.guild is None, which usually occurs when the message is in a DM

mental hollow
#

Thanks!

#

Should I just add an else statement which returns, to avoid getting this error in the future?

hushed galleon
#

i would do the opposite, so instead of this ```py
if guild.id == 1234:

code

else:
returnyou would write thispy
if guild.id != 1234:
return

code``` (its known as a "guard clause" which saves indentation, makes your code a bit prettier)

#

well i mean with checking if guild is None but the idea is the same

mental hollow
hushed galleon
#

nah the point is removing the else statement

#

but either way the none check will fix your error

spark saddle
mental hollow
spark saddle
#

I Badly need to learn.

spark saddle
hushed galleon
#

giving a role can be done with await Member.add_roles(<role object>), you just need to figure out which member and role you're adding

#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

Hey @rich oxide!

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

rich oxide
#

Can i have help i cant fix dis error

#

Traceback (most recent call last):
File "main.py", line 10, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'

rich oxide
sick birch
#

Then it's commands.Bot given you've done from discord.ext import commands

rich oxide
#

from keep_alive import keep_alive
import discord
import discord.ext
import os
from discord_slash import SlashCommand
import requests

indigo pilot
#

Hey does anyone know why im getting this error

[2022-10-07 19:15:52] [ERROR   ] discord.ext.tasks: Unhandled exception in internal background task 'minecraft_count'.
Traceback (most recent call last):
  File "C:\Users\kaelm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 239, in _loop
    await self.coro(*args, **kwargs)
  File "C:\Users\kaelm\PycharmProjects\358564063833227264\utilsBot\cogs\events\minecraftPlayerCount.py", line 49, in minecraft_count
    await channelVar.edit(name=f"🔴 Server offline")
AttributeError: 'NoneType' object has no attribute 'edit'```
#

When i start my bot, i get a error saying guild is none, when i jsk reload that error magicly fixes itself and i get that

#
        guildVar = self.bot.get_guild(serverID)
        print(guildVar)
        channelVar = guildVar.get_channel(channel)```
#

channel is a int, and the channel 10000% exists

primal token
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.

Changed in version 2.0: `channel_id` parameter is now positional-only.
primal token
#

Return type Optional[abc.GuildChannel]

#

It's a cache lookup and can return None if the channel isnt in cache

indigo pilot
#

what do i use then

primal token
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
primal token
#

!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/latest/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/latest/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/latest/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.

New in version 1.2.

Changed in version 2.0: `channel_id` parameter is now positional-only.
primal token
#

make a check that checks if the channel is in cache if not you make an HTTP request

indigo pilot
#

thats what i tried first

indigo pilot
#

ive never done that in my life

primal token
#

It's just checking datatypes?

indigo pilot
#

not sure what you mean, all im doing is trying to get a channel, id from config, then edit the name, inside a loop

primal token
#
channelvar = self.bot.get_channel(id) or await self.bot.fetch_channel(id)

thats all

indigo pilot
#

yea that dosnt work

#

same error

primal token
#

Can you show your code?

indigo pilot
#
# Imports
import json
from time import perf_counter
import requests
from discord.ext import commands

from discord.ext import tasks

configjson = open("config.json")
# config should be file name, () gotta be var above
config = json.load(configjson)
serverID = int(config['bot']["serverID"])
minecraftIP = config['minecraft']['serverAddress']
channel = config['channels']['minecraft']['playerCount']
mainColor = config['brandingColors']["mainColor"]
errorColor = config['brandingColors']["errorColor"]
successColor = config['brandingColors']["successColor"]

messages = config['messages']
configjson.close()


# Cog subclass
class MinecraftPlayerCount(commands.Cog):
    def __init__(self, bot):
        self.bot = (
            bot  # Allows us to use the bot outside of the __init__ function
        )

    async def cog_load(self):
        self.minecraft_count.start()

    async def cog_unload(self):
        self.minecraft_count.cancel()

    @tasks.loop(minutes=5)
    async def minecraft_count(self):
        print(124)

        server = requests.get(f"https://api.mcsrvstat.us/2/{minecraftIP}")
        server = server.json()
        print(serverID)
        guildVar = self.bot.get_guild(serverID)
        print(guildVar)
        channelVar = guildVar.get_channel(channel)


        if server['online'] == False:
            await channelVar.edit(name=f"🔴 Server offline")
        else:
            await channelVar.edit(name=f"🟢 Players online: {str(server['players']['online'])}")




# Sets up the cog
async def setup(bot):
    await bot.add_cog(MinecraftPlayerCount(bot))```
#

prob should of used a paste bin

#

but im tired

primal token
#

you never tried what i showed you :))

indigo pilot
#

no i tried that first lol

#

that was my 3rd try after trying featch and get

#

with bot

primal token
#

Do you mind testing my method and if it gets an error send it

indigo pilot
indigo pilot
primal token
#

You never used the code i sent.

primal token
indigo pilot
#

?? the whole or statement?

primal token
#

it's an expression

slate swan
#

yes, with the or part lol

#

🗿 imagine confusing it without literal "or"

primal token
#

nice pfp sarth

indigo pilot
#

or use fetch

slate swan
#

tyty

indigo pilot
#

loops are so homosexual, so many weird things u gotta do lmao

#

but thanks

primal token
#

bro what

#

The funny thing is this isnt the first time I've heard someone call loops homosexual

indigo pilot
#

they are

you cant set bot status for some reason, to get a channel its gay

#

and i could go on if i didnt have a headake

primal token
#

skill issue

#

jk

slate swan
#

adding an await bot.wait_until_ready() fixes most of the cache and request related issues :p

#

your get_channel prob didn't work because cache wasn't ready

primal token
#

and also just saw, you shouldnt be using requests

#

!pypi aiohttp | use this @indigo pilot

unkempt canyonBOT
primal token
#

and in your if statement dont check values but check identity

#

and why are you turning something into a string if an f string already does that, please refactor all of that😭

indigo pilot
#

and no it dosnt

#

i know that for a fact since i got a error saying it should be a int !

#

so unless my python is just magicly broke 😭

indigo pilot
primal token
primal token
unkempt canyonBOT
#

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

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

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

primal token
#

Python will convert it to a string for you.

indigo pilot
#

weird

primal token
indigo pilot
primal token
#

I think you get issues with everything but it's not the things problem, no offense

sick birch
indigo pilot
#

so its fine lul

primal token
#

It's still slow

indigo pilot
#

that 2ms of time in the loop that runs every 5m wont be noticeable lmao

primal token
#

Thats still good practice, why use a class over literal syntax?

indigo pilot
#

ik it is, but it didnt work and str fixed it so

#

and wym

primal token
#

"saying it wont matter" wont make you any better, most developers should care about time complexity and how much time something can add to run time

primal token
indigo pilot
#

welp maybe i did, str has fixed it, dosnt matter

primal token
#

we're just helping you, if you dont want to learn or get better because it works that's your issue and you should reconsider it

sick birch
#

Not all cases require consideration of time complexity or runtime effects, unless it's like really bad

primal token
#

It would depend on the application, most of the time you should care, of course, but most of the time it's just micro optimizations but they can and will stack up, eitheir way python shouldnt be a consideration if your main goal is speed, depending on the application

dull terrace
#

End up spending hours and hours doing basically nothing

#

Did this a few months ago froggy_chill

untold iron
#

Hey there, i have a little command that invites a user to a channel, however i want to be able to mention the user. I have the user invited saved as a variable. However if i want to mention the user i need to split it by its name and its discriminator. How can i split my user variable so i can input it into the name = 'Mannequin', discriminator = '8586' section

#

Because right now i have to specific the user to mention literally

#

How can i fill in ```name = 'Mannequin', discriminator = '8586'

wicked atlas
#

user.name and user.discriminator I believe

untold iron
#

This returns the error discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: get() takes 1 positional argument but 3 were given

wicked atlas
#

You still need to pass them as kwargs

#
name = user.name, discriminator = user.discriminator
#

Actually, why are you doing that? You already have the user object.

#

Or Member object I should say

untold iron
#

the user variable, why cant i just mention the user tag ?

wicked atlas
#

?

vocal snow
wicked atlas
#

Good question indeed

kindred epoch
#
await ctx.send(f"{"Channel" if channel else "Role"} has been updated to {"{}".format(channel.mention) if channel else "{}".format(role.name)}.")

Why am i getting invalid syntax on the period on this line?

vocal snow
#

And why are you interchangedly using .format and f string

kindred epoch
#

good point, always forget about that

#

thanks

slate swan
#

is it okey if i use my git page for this

slate swan
limber pagoda
#

u can use time.sleep or await asyncio.sleep

#

then check if the member is in a voice channel

#

for pycord/discord.py, i believe discord.Member has an attribute/function for this

limber pagoda
limber pagoda
#

if yes u can just use while True or discord.ext.tasks

slate swan
#

Installed discord.py using pip install discord.py and it says:
Import “discord” could not be resolved

slate swan
#

use tasks

slate swan
limber pagoda
#

so make a function

slate swan
#
@tasks.loop(seconds=300)
async def some_task():
....
slate swan
#

pass it to the function

#

or even better just use an event listener for when ppl disconnect from that vc

#

and check if the vc is empty then do whatever. no reason to use a tasks for that

#

nvm doesn't exist wtf.

slate swan
#

how do i get these in my bot's profile

slate swan
#

would this work?

        def check(member, before, after):
            return member == member.author and before.channel is None and after.channel == new

        try:
            await bot.wait_for("voice_state_update", check=check, timeout=300)
        except TimeoutError:
            await new.delete()
            return
slate swan
slate swan
#

how would i define ctx

pastel basin
#

Can we name functions? Or they can't be changed?

#
@client.event
async def on_ready():
    print("Bot is online!")```
#
@client.event
async def ready():
    print("Bot is online!")
``` Both will do the same thing?
#

I mean we are pretty much defining it... so can't we define it in our on way?

rugged shadow
#

If you want another name, use @client.listen("ready")

#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").

Example...
pastel basin
#

Thanks @rugged shadow

rugged shadow
#

np

pastel basin
#
import discord
from discord.ext import commands

client = commands.Bot(command_prefix="/", intents=discord.Intents.all())

@client.event
async def on_message(message):
    if message.content == "Hello".lower():
        await message.channel.send("Hey!")


client.run()
#

What's the problem here?

rugged shadow
#

"Hello".lower() will always be "hello"

pastel basin
#

Because of this block of code, my bot won't listen to other events too.

rugged shadow
pastel basin
rugged shadow
#

place await client.process_commands(message) at the end of your handler

pastel basin
#

like if someone types hello or HELLO or HeLlo

#

Bot will reply

rugged shadow
#

it checks if the message content is exactly "hello"

#

make the content lowercase

pastel basin
#

i ll try thank you

rugged shadow
#

np

pastel basin
#

ur pfp ruined my day\night

rugged shadow
#

i am the wise mystical tree

primal token
rugged shadow
#

noid we already solved it

primal token
#

Does that have any relation to my question?

rugged shadow
#

your question was my question

slate swan
#

Im able to run my bot on my local machine but on server it's givin me this error

slate swan
#

is there a way to import the file snake from main.py?

#

possibly without using from . import

primal token
#

iirc from games import snake

pastel finch
#

discord bot made on repl.it not working. it was working fine some months ago

rugged shadow
#

ratelimit

slate swan
#

how to update an embed field with button?

pastel finch
#

this is the code

pastel finch
rugged shadow
slate swan
rugged shadow
#

problems like these are why you should never use replit

pastel finch
stable path
#

My run token isn’t working even though I know it’s the right token.

slate swan
stable path
#

client.run('example.token')

rugged shadow
stable path
slate swan
#

@rugged shadow can you help me too dude?

rugged shadow
pastel finch
rugged shadow
rugged shadow
rugged shadow
#

and if nothing else works, regenerate the token

naive briar
stable path
#

I’ll regenerate it again before I show my code.

slate swan
shrewd apex
unkempt canyonBOT
#

clear_fields()```
Removes all fields from this embed.

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

Changed in version 2.0: This function now returns the class instance.
shrewd apex
#

and add field

#

then edit

pastel finch
slate swan
#

i want to keep other fields

rugged shadow
robust fulcrum
#

Guys can anyone suggest me a python package idea
I want to make a python package that help in coding discord bots easy

shrewd apex
slate swan
#

it's like when someone presses the button a embed field will be edited

shrewd apex
#

and readd them

rugged shadow
naive briar
unkempt canyonBOT
#

remove_field(index)```
Removes a field at a specified index.

If the index is invalid or out of bounds then the error is silently swallowed.

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

Note

When deleting a field by index, the index of the other fields shift to fill the gap just like a regular list.

Changed in version 2.0: This function now returns the class instance.
slate swan
rugged shadow
shrewd apex
stable path
rugged shadow
#

oh for gods sake

robust fulcrum
stable path
#

Which I find funny cause it’s worked just fine before.

rugged shadow
#

the one time i didnt ask "what do you mean by doesnt work" it's a syntax error

shrewd apex
#

help ppl who are too lazy to learn oop or monkey patch views

naive briar
unkempt canyonBOT
#

set_field_at(index, *, name, value, inline=True)```
Modifies a field to the embed object.

The index must point to a valid pre-existing field. Can only be up to 25 fields.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#
@ui.button(label='Upvote', style=discord.ButtonStyle.red)
    async def Upvote(self, interaction: discord.Interaction, button: discord.ui.Button):
        #update the embed field of the original message    
rugged shadow
slate swan
#

i just want to update the embed field nothing more

shrewd apex
slate swan
stable path
#

I feel like it’s catching the . In the token for some reason.

shrewd apex
#

yeah use what catgal send

slate swan
shrewd apex
robust fulcrum
slate swan
#

that's what i am asking

stable path
robust fulcrum
#

Ok

stable path
#

That’s just an example token.

shrewd apex
#

!d discord.Message.embeds

unkempt canyonBOT
slate swan
# shrewd apex u have the message object right
class menu(ui.View):
    def __init__(self):
        super().__init__()
        self.value = None
    users = []
    @ui.button(label='Upvote', style=discord.ButtonStyle.red)
    async def Upvote(self, interaction: discord.Interaction, button: discord.ui.Button):
        #update the embed

        self.users.append(interaction.user.id)
        await interaction.response.edit_message(embed=Embed.set_field_at(1,name="test",value="stt"), view=self)
        

class SuggestionChannel(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.hybrid_command(name="suggest",description="give your suggestion in the server.")
    @commands.has_permissions(manage_messages=True)
    @app_commands.describe(suggestion="Your Suggestion")
    async def suggestion(self, ctx: Context, suggestion: str) -> None:
        member = ctx.author
        message = ctx.channel
        embedx = Embed(color=0x00ff00,timestamp=ctx.message.created_at)
        embedx.set_author(name=f"{member.name}#{member.discriminator}",icon_url=member.display_avatar,url=cfxurl)
        embedx.set_thumbnail(url=random.choice(thumbnail))
        embedx.add_field(name=f"**Username:**",value=member.mention,inline=False)
        embedx.add_field(name=f"**Suggested:**",value=suggestion,inline=False)

        view = menu()
        await message.send(embed=embedx,view=view)```
shrewd apex
#

use this to acess the embed

robust fulcrum
slate swan
shrewd apex
#

pass in the message object to the view

#

so u can update

rugged shadow
#

you unindented your if statement

#

mobile tings

slate swan
stable path
rugged shadow
#

) in the "th person to say that" whatever

stable path
#

Mobile skill issue.

#

Thanks.

rugged shadow
#

skill issue frfr

#

npnp frfr istg

stable path
#

Just got tunnel vision you know.

shrewd apex
#
class Vote(discord.ui.View):
    def __init__(self , timeout):
        super().__init__(timeout=timeout)

    @ui.button(label="Vote")
    async def(self, interaction, _):
        embed = (await interaction.original_response()).embeds[0]
        embed.set_field_at(n, name=somename, value=somevalue)
        await interaction.response.edit_message(embed=embed)
stable path
#

Stare at something long enough and you will never find the solution without an outside look.

naive briar
shrewd apex
#

interaction.message can also be used

sweet ore
#

Where do y'all host your bots? Is there any free good site? I don't wanna pay because there's no profit, I'm making a bot just for fun.

slate swan
#

🥲

#

no wonder it's not working

sweet ore
shrewd apex
#

bro don't copy paste

slate swan
#

i don't bro

shrewd apex
#

its pseudo code at best i made

slate swan
#

i just don't understand the concept of buttons and stuff man i am still learning it

shrewd apex
#

👍

#

u can make views and buttons without oop also

slate swan
#

still doesn't work tho 😢

shrewd apex
#

whats the error?

slate swan
#

just says interaction didn't respond

#

for me it never shows any error

#

this interaction failed

robust fulcrum
#

What do views and interactions manager in discord.py?

shrewd apex
#

u have an error handler?

#

also u are running with bot.run?

#

since that has an internal logger

slate swan
#
async def main():
    await load()
    await client.start("Oxo")
asyncio.run(main())```
shrewd apex
slate swan
#

what do you mean

shrewd apex
#

i forgot __ for init thats prolly why :p so it was only __init before ;-;

slate swan
#

i only used the button function

naive briar
shrewd apex
shrewd apex
slate swan
#

that'd print nothing

shrewd apex
naive briar
shrewd apex
#

wait wait can u show ur current code

slate swan
#

i didn't copy the entire class

shrewd apex
#

lmao

slate swan
#
class menu(ui.View):
    def __init__(self):
        super().__init__()
        self.value = None
    
    @ui.button(label='Upvote', style=discord.ButtonStyle.red)
    async def Upvote(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = (await interaction.original_response()).embeds[0]
        embed.set_field_at(0, name="test", value="test")
        await interaction.response.edit_message(embed=embed)```
#

it's failing to get py embed = (await interaction.original_response()).embeds[0]

shrewd apex
#

just use interaction.message.embeds[0]

#

also the embed must have a field

slate swan
#

it has 2 fields

#

im trying to edit the first one

shrewd apex
#

add a print after each line for debug purpose

slate swan
#
embed = (await interaction.message.embeds[0])```?
shrewd apex
#

no remove the await

slate swan
shrewd apex
#

and the '('

slate swan
#

done

shrewd apex
#

run

slate swan
#

let me try now

shrewd apex
#

👍

slate swan
#

thanks man

slate swan
#

anyone got command recommendations?

stable path
#

How would I get my bot to recognize when a specific person sends a message?

unkempt canyonBOT
#

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

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/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/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
stable path
#

I have an idea of how I want to set it up but I’m unsure of the library function I need to call.

stable path
slate swan
slate swan
#

if u want to check who is mentioned in the message use message.mentions it will return the list of mentions in the message

stable path
#

The idea is for example if I type a message everytime I type a message it responds.

stable path
#

I’ll figure out the rest from there.

slate swan
#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
slate swan
robust fulcrum
#

Guys i want to make a views and interactions manager library
What should It do?

slate swan
#

no offense, but i don't think it's a place to ask for that

robust fulcrum
stable path
#

Thank you.

#

For me I have difficulty knowing the exact library commands I can use and run for certain results but I have a decent base knowledge of python.

slate swan
#

that's good

stable path
#

I learned coding from JCAC.

slate swan
#

is that a yt channel?

stable path
#

Joint Cyber Analytics Course.

slate swan
#

o

stable path
#

I only had 2 days to learn the very basics of python.

slate swan
#

i learnt from yt

stable path
slate swan
#

i didn't even learnt the basics i just started with dpy people used to make fun of me for very simple bugs

#

i learnt the basics along the way lol

slate swan
#

i forgot a lot of functions

#

but now i am trying to learn "em all back

#

i was a dark sht developer got my acc suspended quite a lot of times

stable path
#

I’ve written poker, blackjack, and dice before on a linux bash shell.

slate swan
#

in fact this is my 6 or 7 account

stable path
#

I did it for fun in my spare time while going through JCAC.

slate swan
#

that's amazing man

stable path
#

JCAC is a course that condenses a 2 year cyber security degree into 8 months or less.

rugged shadow
stable path
#

Has a 50% fail rate.

rugged shadow
#

what's a dark sht developer

slate swan
#

but now i don't do that stuff just trying to be positive now

rugged shadow
#

450 dafuq

stable path
rugged shadow
#

that's an interaction not a message

#

in your case it would be await msg.message.edit

#

wait hold on

#

!d discord.Interaction.message

unkempt canyonBOT
rugged shadow
#

ohhh

#

!d discord.Interaction.response

unkempt canyonBOT
#

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

rugged shadow
#

store the result of send_message into a variable and call edit on that

#

call someone else to help you i gotta do something rq

#

ah nvm

#

show your full command code

stable path
#

Got a syntax error and I am confused what I did wrong specifically.

#

The error is in the random set.

naive briar
rugged shadow
#

what is msg?

slate swan
#

@bot.command()
@commands.has_permissions(administrator=True)
async def saym(ctx, *, saymessage):
    await ctx.channel.purge(limit=1)
    if saymessage is None:
        return await ctx.send("בבקשה תרשום הודעה.")
    else:
        await ctx.send(saymessage)```
if i say nothing just like !saym it shows error and its not sending בבקשה תרשום הודעה.
stable path
#

As soon as I read that I remembered.

#

That’s how it actually works.

#

Thanks.

rugged shadow
#

then it should have worked though

slate swan
#

@bot.command()
@commands.has_permissions(administrator=True)
async def saym(ctx, *, saymessage):
    await ctx.channel.purge(limit=1)
    if saymessage is None:
        return await ctx.send("בבקשה תרשום הודעה.")
    else:
        await ctx.send(saymessage)```
if i say nothing just like !saym it shows error and its not sending בבקשה תרשום הודעה.
rugged shadow
#

then idk what's going on, i'm not a discord.py expert

#

sorry

naive briar
#

Use ctx.edit to edit the respond instead

slate swan
naive briar
slate swan
#

then can i do smt w that?

naive briar
# slate swan then can i do smt w that?

You have to give it a default value to make it optional, like:

async def saym(ctx, *, saymessage: str = None):

If saymessage isn't provided, the value of it will be None

slate swan
#

Thanks! i will try

naive briar
#

If your interaction has to take over 3 seconds to respond, you have to defer it

#

Perhaps

#

Put it on top of your function

#

On top means on top, right before your check definition

await ctx.defer()
def check(m):
    ...
#

You didn't send a message, so you can't get a message from it, and I said use ctx.edit to edit the response, not replace ctx.respond with it

#

Try it

stable path
#

I made a coin flip out of it.

naive briar
#

You didn't define new_game_ug. For the love of God, read the error

stable path
#

With that in mind I wrote Rock Paper Scissors as well but it doesn’t respond to paper or scissors.

limber bison
stable path
#

Its the if statement that has the error.

stable path
#

Although if I want the bot to perform as I envision it in the future then I will need to use a database.

winged coral
# stable path

The or statement isn't doing what you think it's doing

#

!e
print("a" or "b" or "c")

unkempt canyonBOT
#

@winged coral :white_check_mark: Your 3.11 eval job has completed with return code 0.

a
stable path
#

Hmm it’s stopping in the first one.

#

I have an idea then.

#

!e
print("a") or ("b") or ("c")

unkempt canyonBOT
#

@stable path :white_check_mark: Your 3.11 eval job has completed with return code 0.

a
winged coral
#

Just use in

#

And pass a tuple

stable path
#

I’ve never heard of a tuple but I know it’s a type of sequence.

#

So I think user what you are getting at.

#

I see*

#

Ill look it up and learn the difference.

#

Ok so it uses parentheses instead of brackets.

stable path
#

if message.content.startswith(in scissors):

#

I mean clearly that wouldn’t work.

nova hill
#

Hey i am wondering how would i get all the permissions somoene has when the person executes a slash command of the bot

naive briar
unkempt canyonBOT
#

property guild_permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").

This does take into consideration guild ownership, the administrator implication, and whether the member is timed out.

Changed in version 2.0: Member timeouts are taken into consideration.
slate swan
#
class AddUser(discord.ui.Modal):
    def __init__(self, channel):
       super().__init__(title="Add User To A Ticket", timeout=300)
       self.channel = channel

       self.user = discord.ui.TextInput(
        label="User ID",
        min_length=2,
        max_length=30,
        required=True,
        placeholder="User ID"
       )
       self.add_item(self.user)

    async def on_submit(self, interaction: discord.Interaction) -> None:
       user = interaction.guild.get_member_id
       if user is None:
          return await interaction.send(f"The ID Is Not Correct, Make Sure The User Is In This Guild!")
       overwrite = discord.PermissionOverwrite()
       overwrite.read_messages = True
       await self.channel.set_permissions(user, overwrite=overwrite)
       await interaction.send(f"{user.mention} Has Been Added To The Ticket!")

class StaffTicket(discord.ui.View):
    def __init__(self):
       super().__init__(timeout=None)

    @discord.ui.button(label="Add User", style=discord.ButtonStyle.green, custom_id="staff_ticket:green")
    async def add_user(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_modal(AddUser(interaction.channel))```


```ValueError: target parameter must be either Member or Role

naive briar
unkempt canyonBOT
#

class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.

This object must be inherited to create a modal popup window within discord.

New in version 2.0.

Examples...
slate swan
#

ill try

#

wait i dont understand how @naive briar

#

Oh

#

i do i will try

errant citrus
slate swan
#
class AddUser(discord.ui.Modal):
    def __init__(self, channel):
       super().__init__(title="Add User To A Ticket", timeout=300)
       self.channel = channel

       self.user = discord.ui.TextInput(
        label="User ID",
        min_length=2,
        max_length=30,
        required=True,
        placeholder="User ID"
       )
       self.add_item(self.user)

    async def on_submit(self, interaction: discord.Interaction) -> None:
       user = interaction.guild.get_member_id
       if user is None:
          return await interaction.send(f"The ID Is Not Correct, Make Sure The User Is In This Guild!")
       overwrite = discord.PermissionOverwrite()
       overwrite.read_messages = True
       await self.channel.set_permissions(user, overwrite=overwrite)
       await interaction.send(f"{user.mention} Has Been Added To The Ticket!")

class StaffTicket(discord.ui.View):
    def __init__(self):
       super().__init__(timeout=None)

    @discord.ui.button(label="Add User", style=discord.ButtonStyle.green, custom_id="staff_ticket:green")
    async def add_user(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_modal(AddUser(interaction.channel))```


```ValueError: target parameter must be either Member or Role

naive briar
unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") to do this...
slate swan
#

Ohh

#

Not ID?\

#

!d discord.VoiceChannel.members

unkempt canyonBOT
slate swan
slate swan
naive briar
#

Just pass interaction.user to it

slate swan
#

ill try now thanks!

slate swan
# naive briar Just pass `interaction.user` to it

async def on_submit(self, interaction: discord.Interaction) -> None:
user = interaction.user
if user is None:
return await interaction.send(f"The ID Is Not Correct, Make Sure The User Is In This Guild!")
overwrite = discord.PermissionOverwrite()
overwrite.read_messages = True
await self.channel.set_permissions(user, overwrite=overwrite)
await interaction.response.send_message(f"{user.mention} Has Been Added To The Ticket!")

#

its adding me and now the one i want it to add

naive briar
#

What are you trying to do

slate swan
#

that if i put the id of the user it will add him to the ticket

naive briar
#

!d discord.Guild.get_member - Get the member with the submitted ID

unkempt canyonBOT
#

get_member(user_id, /)```
Returns a member with the given ID.

Changed in version 2.0: `user_id` parameter is now positional-only.
slate swan
#

instead of interaction.user?

#

interaction.get_member(user_id, /)

naive briar
#

!d discord.Interaction.guild - Get the guild before trying to get a member, and don't put \ in the get_member function arguments

unkempt canyonBOT
slate swan
#

oh okay

slate swan
#

its says that i need to put an id

#

but if i want to put any id?

naive briar
#

Then get the ID from the input you set?

slate swan
#

OH

naive briar
slate swan
# naive briar Show your code

`class AddUser(discord.ui.Modal):
def init(self, channel):
super().init(title="Add User To A Ticket", timeout=300)
self.channel = channel

   self.user = discord.ui.TextInput(
    label="User ID",
    min_length=2,
    max_length=30,
    required=True,
    placeholder="User ID",
    custom_id="AddUser:staff_ticket"
   )
   self.add_item(self.user)

async def on_submit(self, interaction: discord.Interaction) -> None:
   user = interaction.guild.get_member("AddUser:staff_ticket")
   if user is None:
      return await interaction.response.send_message(f"The ID Is Not Correct, Make Sure The User Is In This Guild!")
   overwrite = discord.PermissionOverwrite()
   overwrite.read_messages = True
   await self.channel.set_permissions(user, overwrite=overwrite)
   await interaction.response.send_message(f"{user.mention} Has Been Added To The Ticket!")

`

naive briar
slate swan
#

Oh

#

how then

naive briar
#

Just get from the TextInput you just set

slate swan
#

like

naive briar
#

!d discord.TextInput.value

slate swan
#

self.user?

unkempt canyonBOT
slate swan
#

@naive briar like

#

value="sdasi"

#

user = interaction.guild.get_member("sdasi")

naive briar
#

What?

slate swan
#

i dont understnd how

naive briar
#

You know how to set class variables but don't know how to get them?

slate swan
#

no

naive briar
#

That's maybe why you should know about OOP before using dpy. So you basically just get the user you set and get the value from it

user = interaction.guild.get_member(self.user.value)
slate swan
#

i understand

#

thank you

naive briar
#

It's the input that the user enters

slate swan
#
class AddUser(discord.ui.Modal):
    def __init__(self, channel):
       super().__init__(title="Add User To A Ticket", timeout=300)
       self.channel = channel

       self.user = discord.ui.TextInput(
        label="User ID",
        min_length=2,
        max_length=30,
        required=True,
        placeholder="User ID"
       )
       self.add_item(self.user)

    async def on_submit(self, interaction: discord.Interaction) -> None:
       user = interaction.guild.get_member(self.user.value)
       if user is None:
          return await interaction.response.send_message(f"The ID Is Not Correct, Make Sure The User Is In This Guild!")
       overwrite = discord.PermissionOverwrite()
       overwrite.read_messages = True
       await self.channel.set_permissions(user, overwrite=overwrite)
       await interaction.response.send_message(f"{user.mention} Has Been Added To The Ticket!")```
#

thats what i did for now

ember nest
#

Who here is good at making bots maybe help me some to make my bot better

#

How to know more functions or learn better about discord bots

#

All I know to do for now is chatting bot

slate swan
#

!d discord the docs tells you about all the functions and classds

ember nest
nova hill
#

the docs tells you about all the functions and classes and you can use !d to search things up in the doc

nova hill
#

how can i detect if someone just left the discord server the bot is in?

naive briar
unkempt canyonBOT
#

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

If the guild or member could not be found in the internal cache this event will not be called, you may use [`on_raw_member_remove()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_member_remove "discord.on_raw_member_remove") instead.

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

ah ok thx

naive briar
#

What is activity

#

What is 1 min

#

!d discord.Member.bot - Just check if a member is bot or not

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.bot "discord.User.bot")
naive briar
#

That returns boolean

#

No

#

Check if the member is a bot or not before adding to activity

robust fulcrum
#

Guys i want to make a help library for discord.py
Can anyone suggest me any idea?

slate swan
#
class AddUser(discord.ui.Modal):
    def __init__(self, channel):
       super().__init__(title="Add User To A Ticket", timeout=300)
       self.channel = channel

       self.user = discord.ui.TextInput(
        label="User ID",
        min_length=2,
        max_length=30,
        required=True,
        placeholder="User ID"
       )
       self.add_item(self.user)

    async def on_submit(self, interaction: discord.Interaction) -> None:
       user = interaction.guild.get_member(self.user.value)
       if user is None:
          return await interaction.response.send_message(f"The ID Is Not Correct, Make Sure The User Is In This Guild!")
       overwrite = discord.PermissionOverwrite()
       overwrite.read_messages = True
       await self.channel.set_permissions(user, overwrite=overwrite)
       await interaction.response.send_message(f"{user.mention} Has Been Added To The Ticket!")```
but when u tap on the add user button and pastes an id its says  The ID Is Not Correct, Make Sure The User Is In This Guild!
drifting arrow
slate swan
#

and i want to it add everyone i want

#

If member.bot == True

#

Just use if member.bot == False:

#

You don't need statement for not

ember nest
#

Can someone help me what is the problem with embed.set_thumbail

ember nest
vocal snow
#

? Ok

ember nest
#

It's for !Profile command

vocal snow
#

That is not relevant

#

I'm saying url is a keyword only parameter

#

!d discord.Embed.set_thumbnail

unkempt canyonBOT
#

set_thumbnail(*, url)```
Sets the thumbnail for the embed content.

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

Changed in version 1.4: Passing `None` removes the thumbnail.
vocal snow
#

See

ember nest
#

So

#

embed.set_thumbnail(user.display_avatar, url)

vocal snow
#

No what

#

url=user.display_avatar

ember nest
#

embed.set_thumbnail(url = user.display_avatar)

#

?

vocal snow
#

Yes

ember nest
#

Oh yeah it worked thanks

restive dagger
#

I maked a discord python test bot but error

grand willow
restive dagger
#

``Traceback (most recent call last):

My bot

File "main.py", line 13, in sadutes client runt 10937501855114877821 File: /home/runner/My-bot/veny/1tb/python3,8/site-packages/discord/client.py", line 820, in

run

asyncto.runt runner())

File /nix/store/2vw751379pyyatw32c51bel-python3-3.1.12/1tb/python3.6/async/rm ers.py", line 44, in rui return loop.run until complete main)

File "/htx/store/2ymbw7513h3py yatw32cossibial-python3-3.8.12/11b/python3.8/asyncio/base

Jevents.py", line 616, in run_until_complete

tents

return future.result() File "/home/runner/My-bot/venv/lib/python3.3/site-packages/discord/client.py", line 617, in runner walt self startitolen, reconnect-recomect)

File "/home/runner/Hy-bot/veny/lib/python3.3/site-packages/scord/client.py", line 745, in

awalt self. Login/ token) File "/home/rummer/My-bot/venv/lib/python3.5/site-packages/card/client.py", line 577. Un login

raise TypeError(expected token to be a str, received (token_class___{r} \mstead!}\

TypeError: expected taken to be a str. received class int> Instead

=in``

#
  • more that I could not copy
#

(Im a mobile dev)

robust fulcrum
#

Guys i want to make a help library for discord.py
Can anyone suggest me any idea?
Pls anyone suggest

slate swan
#

wth why do u have python 3.3, 3.5 and 3.6

restive dagger
#

Cuz

#

I use a code hosting site and the python section of the site comes preinstalled with all that

restive dagger
robust fulcrum
restive dagger
#

Can someone help me??

rare echo
robust fulcrum
rare echo
#

why a library of all things?

#

if you dont need an ease of life library already, why make one for no reason?

vocal snow
#

^ no point creating a solution to a problem that doesn't exist

rare echo
#

role no exist

#

youre trying to mention a role but what is the role

naive briar
#

!d discord.Guild.get_role - get_role will return None if the role isn't exist

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
pastel basin
#
@client.command()
async def help(ctx, member: discord.Member=None):
    if member == None:
        member = ctx.author
    
    pfp = member.display_avatar

    help_embed = discord.Embed(title=f"{pfp} **Command List**", decription="Here\'s the list of commands!", colour=discord.Colour.orange)
    help_embed.add_field(name=":game_die:**Games**", value='blackjack')
    help_embed.add_field(name=":wrench:**Utility**", value="ping")

    await ctx.send(embed=help_embed)
#
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.```
I don't have any command called `help`.
#

And if

@client.command()
async def aid(ctx, member: discord.Member=None):
    if member == None:
        member = ctx.author
    
    pfp = member.display_avatar

    help_embed = discord.Embed(title=f"{pfp} **Command List**", decription="Here\'s the list of commands!", colour=discord.Colour.orange)
    help_embed.add_field(name=":game_die:**Games**", value='blackjack')
    help_embed.add_field(name=":wrench:**Utility**", value="ping")

    await ctx.send(embed=help_embed)
``` Then I get this error:
```raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Embed.__init__() got 
an unexpected keyword argument 'decription'```
pastel basin
#

Whoops..

#

My mistake, Sorry!

#

And what about this?

#
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.```
shrewd apex
pastel basin
#

I don't have any.

#

I will check again.

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

pastel basin
#

@shrewd apex

shrewd apex
pastel basin
#

How to remove it

shrewd apex
#

to remove it use bot.remove_command('help')

pastel basin
#

Alright Thanks!

#

Speaking of inbuilt commands, how many are there?

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Expected discord.Colour, int, or None but received method instead.
slate swan
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'

#
@bot.command()
async def mute(ctx, member:discord.Member, time, *, reason):
  time = humanfriendly.parse_timespan(time)
  await member.edit(timed_out_until=discord.utils.utcnow()+datetime.timedelta(seconds=time))
  await ctx.send(f"{member.mention} Has Been Muted For {reason}")

pastel basin
#

Oh

#

My bad again

#

@naive briar How can I show the pfp of author?

#

It shows the link.

naive briar
pastel basin
#

In title.

restive dagger
#

Someone pls help me

naive briar
pastel basin
naive briar
pastel basin
#

Top left.

naive briar
#

!d discord.Embed.set_author

unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

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

Set the icon_url

pastel basin
#

Ohkay, thank you.

slate swan
#

await member.edit(timed_out_until=discord.utils.utcnow()+timedelta.datetime(seconds=time))

#

ay yo, I'm struggling with converting GMT iso timestamp into utc unix timestamp so I can use it like:
<t:1665237600:R>

#

so I need either convert the timezones or add 2 hours to the unix timestamp

#

how do I do that

naive briar
#

!d datetime.timedelta

unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
robust fulcrum
#

Guys how can I make a discord.py interactions and views manager library?

slate swan
#

works tysm

slate swan
#

can someone helpme with add role \ remove role command??

restive dagger
#

s someone help mee pls

#

Some ONE HELP ME I maked a discord python test bot but error

tight obsidian
#

Hello @restive dagger, please don't ping anyone even if you need help

#

only ping moderators if something needs to be moderated

restive dagger
#

Ok

tight obsidian
restive dagger
#

I claimed one but I was send here cuz my problem has to do with a discord bot

tight obsidian
#

it's fine to ask any Python questions in help channels

#

just make sure to read the bot's message about how to ask your question

pastel basin
#

I wanna make first 2 lines of my embad like this. Please help!

#

Code so far

@client.command()
async def help(ctx, member: discord.Member=None):
    if member == None:
        member = ctx.author
    
    pfp = member.display_avatar

    help_embed = discord.Embed(title=f"{pfp} **Command List**", description="Here\'s the list of commands!", colour=discord.Colour.orange())
    help_embed.add_field(name=":game_die:**Games**", value='`blackjack`')
    help_embed.add_field(name="\n:wrench:**Utility**", value=" `ping`", inline=False)

    await ctx.send(embed=help_embed)
naive briar
#

I said use the set_author

pastel basin
#

pfp = set_author_avatar?

naive briar
#

No, it's the embed's function

#

Like add_field

pastel basin
#

oh okay

naive briar
#

!d discord.Embed.set_author

unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

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

Wait I get it now

#

I did set_atuhor

#

but still showed url

naive briar
#

Can you show the code for that

pastel basin
#

This was my code

#
pfp = member.display_avatar.url

    help_embed = discord.Embed(description="Here\'s the list of commands!", colour=discord.Colour.orange())
    
    help_embed.set_author(name="**Command List**, icon_url=pfp")
    ```
pastel basin
#

oh ye

#

my bad bad

robust fulcrum
#

Guys how can I make a discord.py interactions and views manager library?

pastel basin
#

forogt comma

#

i mean quotes

#

Working now

#

feels stupid i always make silly mistakes

robust fulcrum
vocal snow
sweet ore
#

Why you shouldn't host your bot on replit+uptime robot\cronjob?

#

Any cons?

slate swan
#

Hello guys how do i add proxy in my discord bot

sweet ore
#

Alright.

sweet ore
#
  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
    Ah I hate this...
#

Well I will buy a good service later, for now I am making my bot for "fun" only...

sick birch
#

If a bot is just for fun it most likely doesn’t need hosting

sweet ore
#

Yes, But my ping is high.

#

I'm using router not lan cable and router is far away...

#

Anyhow, VS Code is more safe.

#

Thanks @sick birch !

sweet ore
#

For instance... If someone has 20k coins, when the bots run next time... the files will be overwritten and his 20k coins will be 0?

sick birch
#

You can’t create files with your bot, or any changes will go back to how they were before

sweet ore
#

Replit 👎 then.

vocal snow
#

replit does have a simple key-value storage feature

#

but I would still recommend against it for a motley of other reasons

limber pagoda
meager chasm
edgy plinth
#
if content_word == "test" and message.author.id in Admins: 
          map = Update(Faction)
          await message.channel.send("{} SHUT THE FUCK UP!",file = discord.File(map).format(message.author.mention))

Im trying to send an image to discord and it wont like it

white citrus
#
            button = nextcord.ui.Button(label="Show all Roles", style=nextcord.ButtonStyle.blurple)

            async def button_callback(interaction):
                embed_roles = nextcord.Embed(title="Roles", description="\n".join(reversed([f'> {r.mention}' for r in filter(lambda role: not role.is_default(), member.roles)])))

                await interaction.response.send_message(embed=embed_roles, ephemeral=True)  
            
            button.callback = button_callback
            
            view = nextcord.ui.View()
            view.add_item(button)```

How can one write here a on_timeout?
vocal snow
#

set button.disabled to True and edit the message with the new view

vocal snow
#

you can save the Image to an io.BytesIO buffer and pass that to File