#General Help

1 messages · Page 33 of 1

slow dome
#

probably

#

computer science

hardy pendant
#

Oh hmm

#

I only use python for fun

#

I am more invested in c++ and c#

slow dome
#

cython

#

ok please #general

#

this is not the channel for that

midnight horizon
#

but why we can't tho?

warped token
#

updating to the latest doesn't help too

slow dome
midnight horizon
#

hmmm

#

ima try it

fickle spruce
#

I dont get any roles

import discord
from discord.ext import commands
from datetime import datetime
from msilib.schema import Class
from os import times
from time import time
from unicodedata import name


class Shurtsdc99(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_raw_reatcion_add(self, payload):
        ourMessageID = 997623205076406342

        if ourMessageID == payload.message_id:
            member = payload.member
            guild = member.guild

            emoji = payload.emoji.name
            if emoji == '![Champ](https://cdn.discordapp.com/emojis/996497535017439323.webp?size=128 "Champ")':
                role = discord.utils.get(guild.roles, name="| Champ")
            elif emoji == '![Diamond](https://cdn.discordapp.com/emojis/996497522686169158.webp?size=128 "Diamond")':
                role = discord.utils.get(guild.roles, name="| Diamond")
            elif emoji == '![Platinum](https://cdn.discordapp.com/emojis/996497510556237845.webp?size=128 "Platinum")':
                role = discord.utils.get(guild.roles, name="| Platinum")
            elif emoji == '![Gold](https://cdn.discordapp.com/emojis/996497489978994698.webp?size=128 "Gold")':
                role = discord.utils.get(guild.roles, name="| Gold")
            elif emoji == '![Silver](https://cdn.discordapp.com/emojis/996497478826340443.webp?size=128 "Silver")':
                role = discord.utils.get(guild.roles, name="| Silver")
            elif emoji == '![Bronze](https://cdn.discordapp.com/emojis/996497459939381249.webp?size=128 "Bronze")':
                role = discord.utils.get(guild.roles, name="| Bronze")
            elif emoji == '![Copper](https://cdn.discordapp.com/emojis/996497444747616398.webp?size=128 "Copper")':
                role = discord.utils.get(guild.roles, name="| Copper")
            await member.add_roles(role)

    @commands.command(pass_context=True)
    async def bye(self, ctx):
        embed = discord.Embed(
            title="Rollen",
            description="Gib dir die Rolle die du willst",
            timestamp=datetime.now(),
            color=ctx.author.color
        )
        msg = await ctx.send(embed=embed)
        await msg.add_reaction('![Champ](https://cdn.discordapp.com/emojis/996497535017439323.webp?size=128 "Champ")')
        await msg.add_reaction('![Diamond](https://cdn.discordapp.com/emojis/996497522686169158.webp?size=128 "Diamond")')
        await msg.add_reaction('![Platinum](https://cdn.discordapp.com/emojis/996497510556237845.webp?size=128 "Platinum")')
        await msg.add_reaction('![Gold](https://cdn.discordapp.com/emojis/996497489978994698.webp?size=128 "Gold")')
        await msg.add_reaction('![Silver](https://cdn.discordapp.com/emojis/996497478826340443.webp?size=128 "Silver")')
        await msg.add_reaction('![Bronze](https://cdn.discordapp.com/emojis/996497459939381249.webp?size=128 "Bronze")')
        await msg.add_reaction('![Copper](https://cdn.discordapp.com/emojis/996497444747616398.webp?size=128 "Copper")')

def setup(bot):
    bot.add_cog(Shurtsdc99(bot))
wheat topaz
hoary moss
#

Having a bit of a crisis, bridge commands in cogs aren't working 😓

fickle spruce
hoary moss
languid hollow
#

So it's not rlly an issue but just optimisation of code

#

Does anyone have any recommendation on like not using discord.SelectOption all the time

#

mostly so it's easier to read and efficient in space

sudden path
languid hollow
#

I have been thinking of using lamba, but again there might be easier way of optimising it without using lamba (since I have no idea how to use it in this instance)

half marsh
languid hollow
#

I don't think you can use iterate in a list though?

#

you'd have to use lamba (not sure if I'm even spelling it correctly)

half marsh
languid hollow
#

ah those, right I'll try it out

languid hollow
#

after running it, um there's a problem where it

TypeError: issubclass() arg 1 must be a class

line 231, in <listcomp>
    options=[discord.Option(x) for x in fruits]
slender lintel
#

discord.SelectOption

languid hollow
#

yeah just saw the error

soft stone
#

With respect to my bot, why is ctx.guild.me.guild_permissions not equal to ctx.guild.self_role.permissions? (Or are they supposed to be equal, and I'm just doing something terribly wrong?) The only role my bot has is the one associated with its integration (and the one returned by ctx.guild.self_role), so I'm pretty sure these should be equivalent.

languid hollow
slender lintel
#

b!rtfm pyc discord.SelectOption

slender lintel
#

one sec

languid hollow
#

the label bit

slender lintel
#

yes

crimson coral
#

the hidden part: @ everyone is also considered a role

#

to illustrate this, if you completely reset @ everyone permissions in your guild (and ensure your bot role doesn't have admin), the values would now be the same

soft stone
#

Oooooooooh, I see. That makes sense, thanks!

crimson coral
#

allgood

misty glacier
#

How can I make that multiple messages that are in a list are deleted immediately?
Without for message in message because that is extremely slow
I want to delete the messages direct, simultaneously

midnight horizon
#

i think i found out a way to do it without this

#

you just need to insta delete the message after your code: ctx.message.delete()

#

also, may seem like a stupid question, but how do i timeout it?

blazing sable
#

if i have buttons assigned to one message, how do i send a second message after it and have the buttons of first message, for example, edit the text of the second?

half marsh
midnight horizon
#

ok guys, this may seem stupid

#

but how do i make a command

#

to reply balls when someone says ligma?

sudden path
#

on_measage event

potent rivet
#

this might be a dumb question but how do i get my bot to send a message like '#channel' where you can click the message and it takes you to the channel

#

like how when i say #faq you can click it and go to the channel

potent rivet
#

ty

#

should've known it'd use <>

solar berry
#

Does anyone know why my bot would randomly reboot by itself

#

By that I mean the "on_ready" gets triggered every once in a while

#

It shouldn't be a network issue as my other bots didn't reboot at the same time, running on the same machine

rapid tide
#

hi

#

i need help

#

@client.slash_command(name = 'Replit HackerPlan')
async def hackerplan(ctx, ,Username , Password):

#
async def hackerplan(ctx, ,Username , Password):```
#

how to make like input 3 things in a command?

fringe hatch
#

how can I use typing.Union in slash commands options?

fringe hatch
rapid tide
#

that

#

Email

#

Username

#

Password

#

@fringe hatch

fringe hatch
# rapid tide that

use

async def hackerplan(ctx, Email: str, Username: str, Password: str)
rapid tide
#

oh

#

thank u

rapid tide
#

how to make the command executableinonly 1 channel? @fringe hatch

#

like this

deep grail
boreal arch
lament nimbus
#

is there a way to make a command on cooldown only if its executed correctly?

#

for example i have a command
.hi and it takes member as a arg
if the user just does .hi without the member thing it still times out the command

#

i cant go on my pc but i used the thing with buckettypes

#

and i cant log into my replit 😭

slender lintel
lament nimbus
#

i have a ping in hete but i cant see it lol

#

tf

slender lintel
#

if your missing argument is handled by your error handler you put it there

lament nimbus
#

ooh there

#

jt wasnt loading

lament nimbus
#

does it need await?

slender lintel
lament nimbus
#

nice ty

slender lintel
#

not an API call or anything

lament nimbus
#
if member == None:
     ctx.command.reset_cooldown(ctx)
     return await ctx.reply("No member mentioned")

something like this then

#

thanks

slender lintel
#

use member is None

lament nimbus
#

isnt it the same?

slender lintel
#

if you use an IDE it will also tell you to change it to is None

lament nimbus
#

oh

#

vsc never told me abiut yhay

slender lintel
#

oh

lament nimbus
#

wow

#

thats strange

rapid tide
boreal arch
deep grail
hearty rainBOT
rapid tide
#

Thnks it worked!@boreal arch

fringe hatch
#

how can I fetch a guild's region using py-cord?

unique river
#

How to check the message if it mentioned a channel?

slender lintel
#

does anyone have issues with the bot just not responding to commands?

deep grail
misty glacier
#

Carlbot has a feature where you can add emojis from other servers to your own. how could you implement this in pycord?

misty glacier
#

I know there is create_custom_emoji but I have to get the emoji as an image somehow, don't I?

slender lintel
half marsh
slender lintel
#

i dont get it, all my other bots work but this one doesnt

half marsh
slender lintel
half marsh
#

Ok what about you try it first insteqd of ask to ask

slender lintel
#

i will

#

i hate the fact that that fixed it...

deep grail
slender lintel
half marsh
#

But im not sure tho

misty glacier
#

And then how do I test if it's an emoji?

solar berry
crimson coral
#

This isn't something you can really prevent, it's inevitable

#

Which is why you shouldn't rely on on_ready too much (and if you do, have checks in place to prevent duplicate executions)

deep grail
crimson coral
#

Uhhhh what does that do

deep grail
#

I believe it's supposed to be used for bot startup stuff

crimson coral
#

Hm I don't think pycord implemented async startup functions

untold tinsel
#

u mean the version of pycord that it uses from discord's hook?

crimson coral
#

You could just use tasks if you want something to run on startup

deep grail
#

It's basically on_ready but it only triggers once

crimson coral
#

Hmm yep we don't have that to my knowledge

deep grail
#

It would probably be a good thing to implement here as well so that people don't use on ready for stuff that should only execute once

crimson coral
#

Throw it in #suggestions using the /suggest command or open a request on the repo

deep grail
#

Yeah I think I'll do that

untold tinsel
#

by setup hook

deep grail
#

No, i didn't understand ur question

smoky path
#

Hello, i am trying to get a list with with every guild name and ID that the bot is in. but for some reasons the guild name is always "None" (except one for some reason)
my code:

print(bot.guilds)

What i get:

[<Guild id=461592141521485824 name=None shard_id=None chunked=False member_count=None>,
<Guild id=837590922610737162 name='Rainbow Six [DE] | BOT Test' shard_id=None chunked=True member_count=19>]```
837590922610737162  Is a small guild with a view Channels and almost 30 Members
461592141521485824  Is a big guild with over 41000 Members and 200 Voice Channels
any solutions to fix this issue?
crimson coral
#

Have you overridden intents?

smoky path
crimson coral
#

When defining your main bot object, did you set intents=...

smoky path
#

No

crimson coral
#

Hmmm

#

And you always get the same output even after restarting?

smoky path
#
@bot.event
async def on_ready():
    print(
        f"""{Gray()}
Bot Loggedin as: {Red()}{bot.user.name}
{Gray()}Bot is in {Red()}{len(bot.guilds)} Server/s
{Gray()}Prefix: {Red()}{data['prefix']}
{Gray()}Bot is running since: {Red()}{time.strftime('%H:%M %d.%m.%Y')}


{Gray()}Logs:
"""
    )
    try:
        # guild = bot.get_guild(837590922610737162)
        # memberList = guild.members
        print(bot.guilds)
    except Exception as err:
        print(err)```
smoky path
#

Any ideas@crimson coral?

crimson coral
#

Hmmm I can't really see why this would be happening unless you disabled the guilds intent, but you haven't

#

What pycord version are you on?

smoky path
smoky path
crimson coral
#

Wait so how many guilds are showing up as none

smoky path
#

I tryed other versions too even discord.py same result

smoky path
crimson coral
#

How large?

#

Like how many members

smoky path
#

with over 41000 Members and 200 Voice Channels

crimson coral
#

Hmm that shouldn't be causing any problems...

#

What if you print it outside of on_ready?

#

Like in a command or something

smoky path
#

Then it works.... but for some features we need this to run in on ready

crimson coral
#

That's probably the issue

smoky path
crimson coral
#

You need to do it after on_ready because the cache isn't complete fast enough

#

Either that or maybe await asyncio.sleep for a couple seconds

#

Before trying to operate on the guild

smoky path
#

Oh that could be the reason... i'll try doing that

smoky path
crimson coral
#

All good

slender lintel
#
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
    ret = await coro(arg)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 877, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "d:\Code\t2e-alpha\cogs\marketplace.py", line 216, in buy
    await ctx.defer()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 556, in defer
    await self._locked_response(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 956, in _locked_response
    await coro
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 211, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
``` how can `ctx` be Unknown interaction
#

fixed nvm

#

how to make a command only be executed by a owner?

midnight horizon
#

guys, i got a problem

#

here is my code:

slender lintel
midnight horizon
#
@bot.slash_command(name='reset')
async def test(ctx : commands.Context):
    #ONLY FOR TESTING PURPOSES. DO NOT ABUSE THIS COMMAND
    if ctx.message.author.id == 397437604880187403 or ctx.guild.id == 397437910888218635:
        mPrint("WARN", "RESTARTING BOT")
        await ctx.respond("WARNING, DO NOT ABUSE THIS COMMAND...\nplease wait...")
        os.system(f"bot.py RESTART {ctx.guild.id} {ctx.channel.id} {ctx.message.id}")
        sys.exit()
    else:
        await ctx.respond("You are not allowed to use this command.")
        return```
#

i get this problem line 267, in test if ctx.message.author.id == 397437604880187403 or ctx.guild.id == 397437910888218635: AttributeError: 'NoneType' object has no attribute 'author'

#

it says my message has no author

slender lintel
#

async def test(ctx : commands.Context):

#

its commands.ApplicationContext

midnight horizon
#

ok, lemme test it

slender lintel
midnight horizon
crimson coral
#

It's whoever owns the bot

slender lintel
midnight horizon
midnight horizon
crimson coral
#

But you can override it by setting owner_id when defining bot

midnight horizon
#

lemme just

#

yoink

slender lintel
#

its discord.ApplicationContext

#

sorry

#

how to make a message send everytime someone joins?

upbeat hill
#

is there a way to limit slash command use or visibility to a list of specific members?

open bearBOT
slow dome
#

b!rtfm pyc commands.checks

icy sluice
#

how do I send a DM message to the author who added my bot to a server?

steep verge
#

b!rtfm pyc guild.audit_logs

open bearBOT
icy sluice
steep verge
#

That would give you an audit log object then access the user with .user

steep verge
icy sluice
#

ah hm, okay ty

fallen depot
#

I get the prompt as an argument in the slash command:

@slash_command(guild_ids = [], description = "...")
@discord.option("invite", type = discord.Invite, description = "...")
async def invite(self, ctx: discord.ApplicationContext, invite: discord.Invite): ...

And get this error:

File "...\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 851, in _invoke
    arg = await converter.convert(ctx, arg)
TypeError: InviteConverter.convert() missing 1 required positional argument: 'argument'

InviteConverter.convert() Seems to get all the arguments, but an error occurs.

midnight horizon
#
@bot.slash_command(name='reset')
@commands.is_owner()
async def reset(ctx : discord.ApplicationContext):
    await ctx.defer()
    #ONLY FOR TESTING PURPOSES. DO NOT ABUSE THIS COMMAND
    mPrint("WARN", "RESTARTING BOT")
    await ctx.respond("WARNING, DO NOT ABUSE THIS COMMAND...\nplease wait...")
    os.system(f"bot.py RESTART {ctx.guild.id} {ctx.channel.id} {ctx.message.id}")
    sys.exit()

@reset.error
async def reset_error(ctx, error):
    if isinstance(error, commands.NotOwner):
        await ctx.defer()
        await ctx.respond(f"Você não manda em mim, {ctx.author.mention}! 😡")``` the command won't run, its thinking forever
slender lintel
midnight horizon
#

yeah, but i need it to pass the args to the terminal before restarting

#

so it can respond to my message

#

and it won't timeout

fair cradle
#

Why should i write def setup instant of async def setup ???

slender lintel
#

can a msg be a view and ephemeral?

fringe hatch
#

uhmm, why is this happening?

sudden path
#

Didn't invite the bot with the application.commands scope

fringe hatch
#

I did

sudden path
#

Some guild didn't

fringe hatch
#

no, i manually checked, it is

sudden path
#

Code doesn't lie PES2_Shrug

fringe hatch
#

bruh, so is there any way to find out which server is raising this error?

sudden path
#

Just get them to reinvite the bot

fringe hatch
#

the bot is in 45+ servers...

#

the thing is that the code was working fine till now, and I just kicked it out of 1 server and then I restarted the bot, it has been giving this error since that only.

lost sparrow
#

how to have aliases for group subcommands

@honor.command(name="history", aliases=["h"])
async def honor_history(self, ctx, member: Member = None):
    pass

as this dont work, how do you do it?

icy sluice
#

which audit log entry would be for when my bot joins a server?

upbeat hill
#

tying to add cog but keep getting this error

Traceback (most recent call last):
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\cog.py", line 715, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\medbay.py", line 4, in <module>
    class medbay(commands.Cog):
  File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\medbay.py", line 12, in 
medbay
    @discord.slash.command()
AttributeError: module 'discord' has no attribute 'slash'

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

Traceback (most recent call last):
  File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\ticket bot.py", line 73, in <module>module>
    bot.load_extension(f'cogs.{cog}')                                                     , in load_extension
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\cog.py", line 787, in load_extension                                                                       , in _load_from_module_spec
    self._load_from_module_spec(spec, name)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\cog.py", line 718odule 'discord' has no attribute 'slash', in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.medbay' raised an error: AttributeError: module 'discord' has no attribute 'slash'
sudden path
#

slash_command

#

Not slash.command

icy sluice
#

what

sudden path
#

Just index the last entry

icy sluice
#

will that always work?

sudden path
#

You can possibly check the action type

icy sluice
#
@bot.event
async def on_guild_join(guild):
  audits = guild.audit_logs()
  inv_audit = discord.audits.AuditLogEntry.bot_add[0]
  author = inv_audit.id
  await author.send("ello")
#

something like that?

#

i have no clue what I’m doing

fast ermine
#

hey guys, having a TypeError i need help solving in my command error handler, something about ctx?

@commands.Cog.listener()
    async def on_command_error(self, ctx: commands.Context, error: commands.CommandError):
        if isinstance(error, commands.CommandOnCooldown):
            embed = discord.Embed(title="Command Execution Error")
            embed.add_field(name="commands.CommandOnCooldown Error", value="The command `{}` is still on cooldown! You have to wait {} more seconds before using this command.".format(ctx.command, round(ctx.command.get_cooldown_retry_after(), 1)))
            await ctx.reply(embed=embed)
        else:
            raise error
Traceback (most recent call last):
  File "C:\Users\pin\Desktop\VSCode\pinbot-sharpened\.venv\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\pin\Desktop\VSCode\pinbot-sharpened\modules\Core\Core.py", line 51, in on_command_error
    embed.add_field(name="commands.CommandOnCooldown Error", value="The command `{}` is still on cooldown! You have to wait {} more seconds before using this command.".format(ctx.command, round(ctx.command.get_cooldown_retry_after(), 1)))
TypeError: Command.get_cooldown_retry_after() missing 1 required positional argument: 'ctx'
#

been looking at the api and on google but i can't figure it out

ornate fog
half marsh
fast ermine
#

worked now

#

ty!

#

odd how that isn't very obvious in the api docs

half marsh
#

Check out exception hierarchy

fast ermine
#

oh alright

#

thanks again

fringe hatch
ornate fog
slender lintel
#

Can someone explain @client.on_member_join usage to me, documentations are always confusing

steep verge
#

b!rtfm pyc on_member_join

open bearBOT
slender lintel
#

anyone know why this doesnt wanna work?

steep verge
slender lintel
#

just doesnt reply

steep verge
#

Well then that means the author isn’t the guild owner.

#

And are you using the command in a guild?

slender lintel
slender lintel
steep verge
#

Try adding print statements after the if statements and see where it doesn’t work.

slender lintel
#

ighty

slender lintel
#
@bot.event
async def on_member_join(member):
    await member.add_roles(bot.get_role(997906313776467969))
    await bot.get_channel(997926619761098842).send(member.mention)
#

anyone know why this doesnt add the role?

#

oh nvm

#

AttributeError: 'Role' object has no attribute 'Role'

#
@bot.event
async def on_member_join(member):
    await member.add_roles(get(member.guild.roles, Role=member.get_role(810264985258164255)))
    await bot.get_channel(997926619761098842).send(member.mention)```
crimson coral
#

Uhhhh

#

Your old code made way more sense

#

You probably want member.guild.get_role

#

Instead of bot.get_role

slender lintel
upbeat hill
#

is there a way to limit a on_member_join to a specific guild?

hoary moss
#

Has anyone got bridge commands working in cogs?

minor breach
upbeat hill
#

okie

outer valley
#
@bot.slash_command()
async def work(ctx):
    u = discord.ClientUser.mfa_enabled
    print(f'{u}')

returns <member 'mfa_enabled' of 'ClientUser' objects>

slim coral
#

does anyone know why prefix commands would be working in 2.0.0b1 but not 2.0.0?

I am using a cog approach and have the following handler in the Bot:

async def on_message(self, message: discord.Message) -> None:
        if message.author.bot:
            return

        await self.process_commands(message)

this works in 2.0.0b1 but not 2.0.0 hmm

#
def __init__(self, specfile_path: str) -> None:
        intents = discord.Intents.default()
        self.settings = self.load_settings(specfile_path)
        self.set_intents(intents)
        self.configure_logging()
        commands.Bot.__init__(
            self,
            command_prefix=self.settings.command_prefix,
            intents=intents,
        )

init function if it matters

upbeat hill
#

how do you get a role from an id in a slash command in a cog?

crimson coral
crimson coral
upbeat hill
crimson coral
#

it doesn't really matter which

#

as long as you get the guild

#

ctx.guild is just a shortcut for ctx.interaction.guild

slim coral
crimson coral
#
        intents = discord.Intents.default()
        intents.message_content = True```
crimson coral
slim coral
crimson coral
#

what are you trying to do

upbeat hill
crimson coral
#

uhh

#

you can't use interaction as an input type...

crimson coral
#

allgood

upbeat hill
#

yeah i know but i cant get the role with out ctx

crimson coral
#

but you have ctx defined already...

upbeat hill
#

where?

crimson coral
upbeat hill
#

yeah i added that in to get the role but then i get error

#

is there a way to get the role without ctx?

crimson coral
#

?? the error is coming from your interaction argument

#

which you literally don't need

#

all commands require ctx

upbeat hill
crimson coral
#

you get interaction from ctx.interaction

upbeat hill
#

ah

crimson coral
#

but realistically in commands you should just be using the ctx shortcuts for convenience

#

like ctx.author, ctx.respond and so on

upbeat hill
#

i was but i didnt think you could use interaction and ctx together

upbeat hill
crimson coral
#

all good, i think you're misunderstanding their purposes

#

ctx is Context or ApplicationContext, and typically has everything needed to "contextualise" where and how a command was used

#

for prefix commands, Context typically includes a message object since that gives you all the info you need to know; guild, author etc.

#

and for Application commands, Context includes the interaction data since it also delivers the same data you need

#

it's because of context that stuff like permissions can be checked fairly easily

outer valley
upbeat hill
crimson coral
#

i.e. bot.user

#

would be rather worrying if you could check if any random user had 2fa enabled

outer valley
crimson coral
#

mhm

outer valley
crimson coral
#

the ONLY discord.ClientUser you will get is bot.user

outer valley
slim coral
#

fdskljafjdnfkljansdlknfljkdsanflkjsnd

i have this in my code:

from discord.ext import commands

    @commands.command()
    async def ping(self, ctx: commands.context) -> None:
        await ctx.send("Pong!")

and with literally no changes to my code, now i am getting:

0|devbot  | Ignoring exception in command None:
0|devbot  | discord.ext.commands.errors.CommandNotFound: Command "ping" is not found
#

oh it's silently failing to load my cog now

#

okay then

crimson coral
#

cog probably failed to load because it's commands.Context

#

wrong capitalisation

slim coral
#

no it's something else entirely, there is a deep failure in a dependent package i have an editable install of

blazing vortex
#

how can i get embed from a message?

#

this is my snippet:

@bot.event
async def on_message(msg):
    if msg.author.id == 23789456879236582365:
        print(msg.Embed)
slow dome
#

b!rtfm pyc message.embeds

open bearBOT
blazing vortex
#

oh thanks

copper walrus
#

how do I require parameters in slash command?
this is the code and I want the user to type his gamertag

    gt = xbox.GamerProfile.from_gamertag()
    await ctx.respond(f'O usuário tem {gt.gamerscore}g!')
sudden path
#

async def command(ctx, argument: str)

copper walrus
#

Thank you

#

did not work

#

to be more specific: I want the user to input something in the command

cosmic bramble
#

I have a bot in a guild but when I run
serverList = client.guilds print(str(serverList))
it returns a empty list.

sudden path
cosmic bramble
sudden path
#

discord.Intents.all()

#

Or just enable the guilds intent

cosmic bramble
#

still returns empty

sudden path
#

When are you printing that

cosmic bramble
#

after client is defined

#

but anywhere I put still returns empty

sudden path
cosmic bramble
#

TY

craggy rapids
#

Can we make user inputs on views?

frigid lark
craggy rapids
#

Yes

smoky path
#

I'm making a command that when executed by an admin, the bot will list all of the channels in a specific category (Or whole Guild) with the CORRECT order as we see them on discord. I tryed to sort the mess that we get from discord by Channel position but i just can not get this to work...

Can anyone help me with this one?

steep verge
craggy rapids
#

Okie thx

steep verge
smoky path
steep verge
#

What ctx.channel.category.text_channels returns

smoky path
#

And how would i get the right order of the whole guild channels?

wheat topaz
slender lintel
#

hello

#
@bot.command
async def on_member_join(member):
    await member.send("Welcome, Happy Trails! ")

this doesnt work and there are no errors

smoky path
smoky path
slender lintel
#

ok

#

how do i do that then

smoky path
slender lintel
#

that doesnt work

#

TypeError: event() missing 1 required positional argument: 'coro'

smoky path
wheat topaz
#

What do you get from that print?

slender lintel
#
@bot.event()
async def on_member_join(ctx, member):
    await ctx.send("Welcome, Happy Trails! ")
steep verge
steep verge
#
@bot.event()
async def on_member_join(member):
    await member.send("Welcome, Happy Trails! ")
slender lintel
#

@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'

wheat topaz
smoky path
steep verge
#

Forgot the coro was there

slow dome
wheat topaz
slender lintel
#

doesnt work

#

there are no errors either

smoky path
wheat topaz
slow dome
#

intents?

smoky path
slender lintel
#
@bot.event
async def on_member_join(member):
    await member.send("Welcome, Happy Trails! ")
wheat topaz
smoky path
#

aight

slow dome
wheat topaz
slow dome
#

2.0 stable is out

smoky path
#

Thanks for your Help anyways, i think this is "good enough" for now ;v

slender lintel
slow dome
hearty rainBOT
#
import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
slow dome
#

enable the guilds intent

slender lintel
#

i did and it doesnt work

#

wait

#

nvmd

#

it works

#

how do i make it send in the channel tho

smoky path
#

bot.get_channel(id)
channel.send

frigid lark
#

I want to print the text channels and get this error everytime
AttributeError: 'TextChannel' object has no attribute 'news'

#

The channel does not even exist on my test server

slow dome
#

b!rtfm pyc textchannel.news

open bearBOT
frigid lark
wheat topaz
#

What’s your code?

frigid lark
#
@client.command()
async def test(ctx):
    liste = [channel for channel in ctx.guild.channels]
    print(liste)
slow dome
#

show full trace back please and thank you

frigid lark
#
Traceback (most recent call last):
  File "C:\Users\Zerra\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:/Users/Zerra/Desktop/Stuff/Bot/Brynhild/test.py", line 15, in test
    print(liste)
  File "C:\Users\Zerra\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 190, in __repr__
    attrs = [(val, getattr(self, val)) for val in self._repr_attrs]
  File "C:\Users\Zerra\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 190, in <listcomp>
    attrs = [(val, getattr(self, val)) for val in self._repr_attrs]
AttributeError: 'TextChannel' object has no attribute 'news'
frigid lark
#

rc1

steep verge
#
@client.command()
async def test(ctx):
    liste = ctx.guild.channels
    print(liste)
#

Try that

#

Since ctx.guild.channels is already a list.

frigid lark
#
@client.command()
async def test(ctx):
    print(ctx.guild.channels)
#

I was also trying it on my Pi but still the same error and also with a different bot at a different server

steep verge
#

Try updating to 2.0.0

#

!tag install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord from git repository: (alpha)

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
steep verge
#

Bottom one

slow dome
#

?tag install

hearty rainBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
    python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

slow dome
#

2b

solar berry
#

so uh my bot randomly died, process says it's still online but the bot is offline and won't reconnect, nothing in logs, anyone know what could've happened?

wild thunder
#

hey yall i am trying to make a simple prefix command but the bot never responds to the prefix but only to the mention, above is a screenshot and below is my code

import os
import discord
from dotenv import load_dotenv
from discord.ext import commands

load_dotenv()

token = os.environ['TOKEN']
bot = commands.Bot(command_prefix=commands.when_mentioned_or("?"))

@bot.event
async def on_ready():
    print(f"{bot.user} is logged in!")
    
@bot.command(name="hello", aliases=['hi'])
async def hello(ctx):
    await ctx.send("Hi!")

bot.run(token)
crimson gale
slender lintel
solar berry
#

I have my max message cache limit set to a a decently high number, but the bot starts lagging really bad (like 2-3 second delay) at 200,000 messages cached which is only 1.5mb
Anyone know why

slender lintel
icy sluice
#
Ignoring exception in on_guild_join
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/main.py", line 47, in on_guild_join
    await added_me.send ("Tests!")
  File "/home/container/.local/lib/python3.9/site-packages/discord/abc.py", line 1428, in send
    channel = await self._get_channel()
  File "/home/container/.local/lib/python3.9/site-packages/discord/member.py", line 390, in _get_channel
    ch = await self.create_dm()
  File "/home/container/.local/lib/python3.9/site-packages/discord/member.py", line 194, in general
    return await getattr(self._user, x)(*args, **kwargs)
  File "/home/container/.local/lib/python3.9/site-packages/discord/user.py", line 499, in create_dm
    data: DMChannelPayload = await state.http.start_private_message(self.id)
  File "/home/container/.local/lib/python3.9/site-packages/discord/http.py", line 359, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user

Hey, I’m confused why I’m getting this error? My DMs are open to anyone and my bot has all intents enabled?

slate stirrup
#

?tag install

hearty rainBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
    python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

icy sluice
#

??

slate stirrup
#

i have this problem raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed\

upbeat hill
#

what would be the best way to store specific member ids(add and remove) in an exterrnal file and check if a member id in in there?

upbeat hill
slate stirrup
#

import discord
from discord.ext import commands

intent = discord.Intents.all()
bot = commands.Bot(command_prefix="-",help_command=None,intents=intent)
help_command = None

@bot.command
async def he(ctx):
await ctx.send("hehe")

bot.run("Otoken")

#

@slender lintel

slender lintel
#

Otoken has no value

slate stirrup
#

man i hidded it

slender lintel
#

Is it in env

slate stirrup
#

no

#

it's a string

#

@slender lintel

slender lintel
#

So u deleted the line of code that had ur token right

slate stirrup
#

yes

slender lintel
#

Can u send full code but change the string so it dosent have ur token just random letters

slate stirrup
#

import discord
from discord.ext import commands

intent = discord.Intents.all()
bot = commands.Bot(command_prefix="-",help_command=None,intents=intent)
help_command = None

@bot.command
async def he(ctx):
await ctx.send("hehe")

bot.run("degwuidhuwejhfiwjeofwoefpw")

#

that's the full code

#

@slender lintel

vivid nacelle
#

i think you should create a thread

slate stirrup
#

okay

vivid nacelle
crimson coral
#

ohok

vivid nacelle
#

@supple ravine @robust nebula @hearty rain

#

so now

icy sluice
#

user who invited my bot

#

it makes more sense with my code

crimson coral
#

well yeah that'd be useful

icy sluice
#

sorry, one sec

slate stirrup
#

@vivid nacelle can u help me I'm waiting for more than 20 minutes I'm wasting time

vivid nacelle
#

don't ping me, I'm not doing support

slate stirrup
vivid nacelle
#

I'm mainly a mod and managing the infrastructure, stop pinging me.

#

#help-rules §4

icy sluice
#

🤷🏽‍♂️

crimson coral
#

try printing added_me, and how consistently do you get the error?

#

i think using target is the issue, should probably be user

#

because if im not mistaken, target will be the bot that was added

wild thunder
crimson gale
wild thunder
#

oh

wild thunder
crimson gale
#

event is not necessary

wild thunder
#

oh ok

jagged meadow
#

uhh ```python
discord.Option(int, "The time before the invite expires in seconds", required=False, max_value=604800)

`AttributeError: Option does not take min_value or max_value if not of type SlashCommandOptionType.integer or SlashCommandOptionType.number`
icy sluice
jagged meadow
#

is this a bug or is this intentional, if so how do i use it now?

valid cairn
#

How to go about detecting when a member is kicked?

crimson coral
#

you could use on_member_remove and then check the audit log to see if someone actually kicked

sleek grove
#

guys what does that error means

#

and how can i fix it?

#

ah fixed

lusty dragon
#

how can i see who added my bot in a server?
i mean how can i make my bot check who added it in a server so it can dm the person "thanks for adding me" or something

worthy basin
lusty dragon
#

oh

rare summit
#

Hi, is it possible to for interaction to remember how many times someone clicked it?
I have a button inside a view, and I need to make it so when you first click the button, it does something, but when you try to click it second, third, ... time, it says you: you already used this button.

#

This is my current code, it does work, but with one problem, if there are multiple messages containing this view, and you click the button on one of those messages, you cant click it on the others.

    def __init__(self, ctx, em):
        super().__init__(timeout=config.get('defaults').get('default-timeout'))
        self.ctx = ctx
        save_button_users = []

    @discord.ui.button(label="DMs", style=discord.ButtonStyle.secondary, emoji=":floppy_disk:", disabled=False, custom_id="save_to_dms")
    async def save_to_dms_callback(self, button, interaction):
        vi = b.View_cancel_message(ctx=self.ctx)
        if interaction.user not in self.save_button_users:
            await interaction.response.send_message(content=":white_check_mark: Image has been saved to your 
DMs!", delete_after=15)
            await interaction.user.send(content=" ", embeds=interaction.message.embeds, view=vi)
            self.save_button_users.append(interaction.user)
        else:
            await interaction.response.send_message(content=":x: You have already saved this image!", delete_after=15)```
vivid nacelle
worthy basin
rare summit
rare summit
slender lintel
#

How do I do a data base for discord bots could I use a google sheets?

#

What is the easiest way to do that

vivid nacelle
#

You could name the image maybe in a special way to determine it

#

Like embed_id-author_id-img_name.ext

worthy basin
rare summit
vivid nacelle
#

Oh yes

slender lintel
#

I’m using deploy

#

Replit*

worthy basin
#

replit has there own builtin no-SQL database

#

on the sidebar it will tell you how to do it

slender lintel
#

Do they really?

#

Oh wow

#

Very cool

#

I’ll be back with question

#

Just got to work

worthy basin
#

Cant vouch for it being good becouse i have never used it but its worth a try.

deep grail
#

It's about the same speed as a mongodb database

#

Cuz it's not hosted natively

#

It's on a seperate server which makes it slower

#

So every time u make a change it sends a request to the db url

fickle spruce
#
import discord
from discord.ext import commands
from datetime import datetime
from os import times
from time import time

class Shurtsdc992(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_raw_reaction_add(self, payload):
        ourMessageID = 998217970478219274

        if ourMessageID == payload.message_id:
            member = payload.member
            guild = member.guild

            emoji = payload.emoji.id
            if emoji == 998212715858382938:
                role = discord.utils.get(guild.roles, name="| PC")
                await member.send(f"{member.mention} Du hast dir die **PC** Rolle gegeben.", delete_after=15)
            elif emoji == 998213297172135956:
                role = discord.utils.get(guild.roles, name="| Playstation")
                await member.send(f"{member.mention} Du hast dir die **Playstation** Rolle gegeben.", delete_after=15)
            elif emoji == 998213312099651645:
                role = discord.utils.get(guild.roles, name="| Xbox")
                await member.send(f"{member.mention} Du hast dir die **Xbox** Rolle gegeben.", delete_after=15)
            await member.add_roles(role)

    @commands.Cog.listener()
    async def on_raw_reaction_remove(self, payload):
        ourMessageID = 998217970478219274

        if ourMessageID == payload.message_id:
            member = payload.member
            guild = await(self.bot.fetch_guild(payload.guild_id))
            member = await(guild.fetch_member(payload.user_id))

            emoji = payload.emoji.id
            if emoji == 998212715858382938:
                role = discord.utils.get(guild.roles, name="| PC")
                await member.send(f"{member.mention} Du hast dir die **PC** Rolle entfernt.", delete_after=15)
            elif emoji == 998213297172135956:
                role = discord.utils.get(guild.roles, name="| Playstation")
                await member.send(f"{member.mention} Du hast dir die **Playstation** Rolle entfernt.", delete_after=15)
            elif emoji == 998213312099651645:
                role = discord.utils.get(guild.roles, name="| Xbox")
                await member.send(f"{member.mention} Du hast dir die **Xbox** Rolle entfernt.", delete_after=15)   

            if member is not None:
                await member.remove_roles(role)
            else:
                print("Member nicht gefunden")


    @commands.command(pass_context=True)
    async def bye2(self, ctx):
        embed = discord.Embed(
            title="Selfroles",
            description="Wähle deinen Rang aus.\n\n⌨ | Du spielst auf dem PC\n\n![Ps4](https://cdn.discordapp.com/emojis/996497893915631646.webp?size=128 "Ps4") | Du spielst auf der Playstation\n\n![Xbox](https://cdn.discordapp.com/emojis/996497914304139294.webp?size=128 "Xbox") | Du spielst auf der Xbox",
            timestamp=datetime.now(),
            color=ctx.author.color
        )
        embed.set_footer(text=self.bot.user.name, icon_url=self.bot.user.avatar)
        embed.set_thumbnail(url=self.bot.user.avatar)
        embed.set_image(url="https://cdn.discordapp.com/attachments/883805723807588423/901580387950686259/zerotwo_ist_scheie.gif")
        
        msg = await ctx.send(embed=embed)
        await msg.add_reaction('⌨')
        await msg.add_reaction('![Ps4](https://cdn.discordapp.com/emojis/996497893915631646.webp?size=128 "Ps4")')
        await msg.add_reaction('![Xbox](https://cdn.discordapp.com/emojis/996497914304139294.webp?size=128 "Xbox")')


def setup(bot):
    bot.add_cog(Shurtsdc992(bot))
#

What shoud i do?

vivid nacelle
#

Read the error and use google

#

Always the first step

slender lintel
#

so i see how to do it

#

how would i create a new thing

#

from my doc

#

like when someone joins the server it adds their user to the database

toxic tiger
#

Anyone an idea what could cause this?

future: <Task finished name='Task-341000' coro=<ApplicationCommandMixin.on_application_command_auto_complete.<locals>.callback() done, defined at /var/discord/venv/lib/python3.9/site-packages/discord/bot.py:739> exception=TypeError("'NoneType' object is
 not iterable")>
Traceback (most recent call last):
  File "/var/discord/venv/lib/python3.9/site-packages/discord/bot.py", line 742, in callback
    return await command.invoke_autocomplete_callback(ctx)
  File "/var/discord/venv/lib/python3.9/site-packages/discord/commands/core.py", line 1177, in invoke_autocomplete_callback
    await command.invoke_autocomplete_callback(ctx)
  File "/var/discord/venv/lib/python3.9/site-packages/discord/commands/core.py", line 904, in invoke_autocomplete_callback
    choices = [o if isinstance(o, OptionChoice) else OptionChoice(o) for o in result][:25]
rare summit
#

Is it possible to somehow use for loop when generating buttons inside a view? I have i view that has different number of buttons every time. I found somewhere, that every button has to have its own unique callback. In my last script i used a way around that like this:

Class view(view)
  def __init__(self, number_of_buttons, ...)
    self.number_of_buttons = number_of_buttons

  if number_of_buttons >= 1:
    @discord.ui.button(...)
    async def button_1_callback(...):
      some code

  if number_of_buttons >= 2:
    @discord.ui.button(...)
    async def button_2_callback(...):
      some code

  --- i repeated this thing up to 20 (that is i think the discords maximum)
  

My question is, if it is possible somehow to use for loop or something, bcs else this would be many more lines of code (all the buttons are doing basically the same thing, the only difference is one variable, which could be stored as parameter im function)?

dull skiff
#

why my bot send more than 1 embed?

#
async def on_member_join(member):
    guild = bot.get_guild(998188595372367913)
    channel = guild.get_channel(998218612848459877)
    embed = discord.Embed(
        color=0x3498db
    )
    embed.add_field(name=f"Someone Just Joined This Server !", value=f"**Welcome To Server {member.mention} !**")
    embed.set_image(url="https://media.giphy.com/media/AFdcYElkoNAUE/giphy.gif")
    await channel.send(embed=embed)```
#

the code

upbeat hill
#
Traceback (most recent call last):
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 852, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\utils.py", line 16, in add
    cursor.execute(f"SELECT DutieID FROM Duties WHERE DutieName = {duty}")
sqlite3.OperationalError: near "Security": syntax error

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

Traceback (most recent call last):
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\bot.py", line 993, in invoke_application_command   
    await ctx.command.invoke(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 1126, in _invoke
    await command.invoke(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: OperationalError: near "Security": syntax error```
#

dont understand the syntax error

#

any ideas?

dull skiff
vivid nacelle
#

You added two different bots.

dull skiff
#

no

#

eh what you mean?

vivid nacelle
#

I see mee6 and dankmemer. So two are def send

dull skiff
#

while people join my bot also send 3 or 4 embed too

worthy basin
worthy basin
dull skiff
#

the user is me in my phone

#

i use that for testing bot

upbeat hill
worthy basin
#

The only way ot would be sending multiple times is if you have multiple on_member_join events that send an embeds.

worthy basin
upbeat hill
#
Traceback (most recent call last):
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 852, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\utils.py", line 26, in add
    cursor.execute(sql, val)
sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.

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

Traceback (most recent call last):
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\bot.py", line 993, in invoke_application_command   
    await ctx.command.invoke(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 1126, in _invoke
    await command.invoke(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: InterfaceError: Error binding parameter 1 - probably unsupported type.```
#
import sqlite3
import discord
from discord.ext import commands
from discord import option
class Duties(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        
    duties = discord.SlashCommandGroup('duties', description='Add or remove duties from members.')
    
    @duties.command(guild_id=[988177984299081748], name='add', description='Add a duty to a member.')
    @option('duty', description='The duty to add to the member.', choices=["ARF Instructor", "Battalion Security Officer", "Doc Logistics", "Droid Technician"])
    async def add(self, ctx: discord.ApplicationContext, member: discord.Member, duty: str):
        db = sqlite3.connect('Artemis.sqlite')
        cursor = db.cursor()
        cursor.execute(f"SELECT DutieID FROM Duties WHERE DutieName = '{duty}'")
        dutyID = cursor.fetchone()
        
        cursor.execute(f"SELECT MemberID FROM MemberDuties WHERE MemberID = '{member.id}' AND DutieID = '{dutyID}'")
        result = cursor.fetchone()
        if result is None:
            

            sql = (f"INSERT INTO MemberDuties (MemberID, DutieID) VALUES (?,?)")
            val = (member.id, dutyID)
            cursor.execute(sql, val)
            db.commit()
            await ctx.respond(f"{member.mention} has been added to {duty}", ephemeral=True)
        elif result is not None:
            await ctx.respond(f'{member.name} has already been assigned to {duty}')

def setup(bot):
    bot.add_cog(Duties(bot))```
smoky path
#

Hello, i want to make a list of permissions a User has in a Channel (not Server). The Permission value code i get isn't helping me really... Is there a way of printing out all Permissions i have with the value code?

vivid nacelle
#

permission_for maybe

worthy basin
slender lintel
smoky path
worthy basin
slender lintel
#

@smoky path how do i do a listener so it dms the person

#

or wolf

vivid nacelle
slender lintel
#

how do i make it so when the person dms the bot their username, it gets the members database and adds there user

vivid nacelle
#

Learn how to translate this / convert it. Read the docs for permissions

smoky path
worthy basin
# dull skiff

Do you have other bots running or other on_member_join events?

smoky path
#

Isn't there a library for this

vivid nacelle
slender lintel
#

i am trying

slender lintel
dull skiff
#

just one on_member_join

worthy basin
slender lintel
#

well

#

i think i can do that

dull skiff
slender lintel
#

ive tried making dm commands but it doesnt work

#

i dont know why

#

how do i make dm commands that work when dming the bot

vivid nacelle
#

Tbh.. learn python

slender lintel
#

ive done way more advanced stuff than this

#

ive never really done THIS

#

the stuff i have found is bad

worthy basin
# dull skiff just one on_member_join

Are you 100% sure there is not more than 1 bot running. One of the embeds is different. So it means more than 1 bot is running or you have multiple on_member_joins

dull skiff
#

yes

#

and i think its a bug because ii fix it with reset token

upbeat hill
slender lintel
#
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandNotFound):
    embed = discord.Embed(
          title="Hmmmmm",url="", description="There is no command with this given Aircraft name, try checked for Capital letters.", 
          color=0x0033ff
    )
    embed.add_field(name="Example", value="!F14",inline=False)
    await ctx.send(embed=embed)
#

this doesnt work

#

for some reason

worthy basin
dull skiff
#

but how

#

i close vsc

#

and only run in heroku

worthy basin
#

Have you ever used a external host that you kept running

slender lintel
dull skiff
slender lintel
#

cool

worthy basin
slender lintel
#

ice wolf

#
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandNotFound):
    embed = discord.Embed(
          title="Hmmmmm",url="", description="There is no command with this given Aircraft name, try checked for Capital letters.", 
          color=0x0033ff
    )
    embed.add_field(name="Example", value="!F14",inline=False)
    await ctx.send(embed=embed)
      ```
#

this not working

#

idk why

upbeat hill
slender lintel
#

@worthy basin ive looked everywhere

#

i cant find dming the bot

#

only the bot dming the user

worthy basin
#

Does it have the bot.event decorator?

slender lintel
#

oh yeah

#

i fuixed it

#

that was the problem

#

but how do i make it posible for a user to be able to dm the bot

#

ive looked everyhwere

worthy basin
worthy basin
slender lintel
#

like

#

ive seen other bots accept commands from dms

upbeat hill
# worthy basin Are you sure that it is exactly the same? I would understand if this worked. `(...
  cursor.execute(f'SELECT MemberID FROM Detentions WHERE MemberID = {member.id} AND Released = 0')
    results = cursor.fetchone()
    if results is None:
        message = await ctx.send(f'Transfering...')
        roles_list = []
        for role in member.roles:
            roles_list.append(role.id)
            try:
                await member.remove_roles(role)
            except:
                print(f"Cant remove role {role.name}")
        roles_list_str = ','.join(str(x) for x in roles_list)
        sql = (f'INSERT INTO Detentions(MemberID, RoleList, Released) VALUES(?,?,0)')
        val = (member.id, roles_list_str)
        cursor.execute(sql, val)
        await message.delete()
        await member.add_roles(suspended)
        await ctx.respond(f'transfered {member.mention} to {channel} because {reason}', ephemeral=True)
    elif results is not None:
        await ctx.respond(f'{member.mention} is already in the detention list.')
    db.commit()
    cursor.close()```
this is a different command and works perfectly with no errors
slender lintel
#

but i cant find how to do it

worthy basin
slender lintel
#

huh?

#

oh damn

#

i didnt know that

worthy basin
worthy basin
#

And the columns both except ints?

upbeat hill
#

yep

slender lintel
#

ik im doing something wrong

#
author = message_author
#

how do i get the author of the message

upbeat hill
slender lintel
#

alr thx

#

stupid question

#

i should know that lol

#

how do i get a item in my database, and then edit it

worthy basin
#

db["key"] = "value"

worthy basin
# upbeat hill yep

The excuse above that has the 2 IDs being checked against strings. If they are ints they should not be doing this. I do t think thats the error but something I will catch so it dosent cause issues later.

upbeat hill
worthy basin
#

Yes that would be it

upbeat hill
#

how do i format it to get the 1?

worthy basin
#

I would assume just getting the 0th index [0]

slender lintel
#

hmmm

#

im having some trouble

upbeat hill
upbeat hill
#

compared to [1] etc

worthy basin
#

So it returns a tuple so you need to get the first item of that tuple.

slender lintel
#

that creates a new one

#

doesnt it?

worthy basin
worthy basin
# slender lintel doesnt it?

Nope it only creates a new one if the key does not already exist otherwise it just updates it. The repl db works very similar to a dictionary

slender lintel
#

im having trouble displaying all the users and their values

worthy basin
#

You could loop through like this

for key in db.keys():
  print(f"{key}: {db[key]}")
slender lintel
#

undefined name value

#

@worthy basin

worthy basin
#

My bad, updated

slender lintel
#

can i manually delete keys?

worthy basin
#

db.keys() is all the keys than it will print this format for all keys
key: value

slender lintel
#

cause its keeping old keys that have the wrong stuff

worthy basin
slender lintel
#

it does

#

but can i manually do it?

vivid nacelle
#

@slender lintel you ask pretty much. Consider using an own thread from now on. General help should be more like “help with problems which could be quickly resolved”

Advanced stuff spams this thread

slender lintel
#

can i have a permanent thread for me?

#

xD

worthy basin
slender lintel
#

i did it its ok

vivid nacelle
#

can't see your thread

slender lintel
#

i didnt make it yet

#

couple more questions

#

how do i see how long a member has been in the server

#

and send it

#

through code

worthy basin
slender lintel
#

i created the post

slate stirrup
#

How can I make him take all the sentence

deep grail
#

Or

#

In the function declaration

slate stirrup
#

ctx, message

#

I declared two variables

#

Parameters*

deep grail
#
async def example (ctx, *, random):
#

Make sure to have the asterisk

#

That will make it take the rest of the msg

slow dome
#

this will help

slate stirrup
slow dome
#

(probably)

deep grail
slate stirrup
deep grail
slender lintel
#

how do i get the profile picture of a user

#
@bot.command()
async def User(ctx):
    author = ctx.message.author
    embed = discord.Embed(
      title=f"{author}", url="", description=f"Joined On{author.joined_at}", color=0x03fc07
    )
    embed.Set_image(url = f"{author.avatar_url}")
    embed.add_field(name="Sky Warriors Username", value=db[f"{author}"],inline=False)
    await ctx.send(embed=embed)
#

that doesnt work

slow dome
#

author.display_avatar.url

slender lintel
#

u sure?

#

@slow dome

#

like this

#

pfp = author.display_avatar.url()

slow dome
#

?tag tias

hearty rainBOT
slow dome
#

and also rtfm

slender lintel
slow dome
#

?tag idw

hearty rainBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

#

dynoSuccess tag tias edited.

slender lintel
slow dome
#

and you can read the docs

#

b!rtfm pyc member.avatar

vivid nacelle
slender lintel
#

nobody responds to it

vivid nacelle
slate stirrup
hearty rainBOT
#

dynoSuccess Tag nohelp created.

vivid nacelle
#

@slow dome ^ use that next time

slow dome
#

?tag nohelp

hearty rainBOT
#

Nobody helps you? See #help-rules §2, then you know why.

slow dome
#

ok

torpid siren
#

is it possible to execute an async function in a cog when it is loaded ?

#

I didn't find any event related to that in the doc and you can't just put the code at the beginning of the cog as it needs to be in an async function to await something