#discord-bots

1 messages · Page 943 of 1

austere vale
#
@commands.command()
  async def join(self, ctx):
    if ctx.author.voice is None:
      await ctx.send('You are not in a voice channel.')
    voice_channel=ctx.author.voice.channel
    if ctx.bot.is_connected is None:
      await voice_channel.connect()
    else:
      await ctx.bot.move_to(voice_channel)

is it supposed to be like this?

upbeat gust
#

it's self

#

Not ctx

austere vale
#
@commands.command()
  async def join(self, ctx):
    if ctx.author.voice is None:
      await ctx.send('You are not in a voice channel.')
    voice_channel=ctx.author.voice.channel
    if self.is_connected() is None:
      await voice_channel.connect()
    else:
      await self.move_to(voice_channel)

like this?

silent ermine
hushed galleon
unkempt canyonBOT
silent ermine
hushed galleon
#

although is_connected() and move_to() are methods of voice client so neither self.bot or ctx.bot should be used

#

you can get the voice client from ctx.guild.voice_client

glacial echo
#

how can i write a check for if a specific user (a user at index 0 of a list of users) has sent a message, and if they have proceed with my logic for the bot and if they havent after 5 minutes, do somethign else

#

like if user[0] has sent message: do thing 1, if no message from user[0] for 5 minutes: do thing 2

spice adder
#
@client.event
async def on_member_unban(guild, user):
  username =  str(user)
  userid = str(user.id)
  unbanreason = await guild.audit_logs(limit=1, action=discord.AuditLogAction.unban).flatten()
  unbanembed = discord.Embed(title=f"User {username} was unbanned", color=0x2ecc71)
  unbanembed.set_thumbnail(url="")
  unbanembed.add_field(name="🔓 User ID:", value=f"{userid}", inline=True)
  unbanembed.add_field(name="📄 Reason:", value=f"{unbanreason}", inline=True)
  modlog = client.get_channel(904806027025854544)
  await modlog.send(embed = unbanembed)
``` Have been pulling my hair out trying to figure out how to add a reason to an unban. The only bot I've seen be able to do it is Dyno, so I'm not sure if I'm just missing something in the docs or if it's not really possible - code above doesn't work with the `unbanreason = await guild.audit_logs(limit=1, action=discord.AuditLogAction.unban).flatten()` part, which I found by searching back through this channel
glacial echo
#

so, Dyno is giving a reason for it itself unbanning somene, not it sending an embed as a modlog

high nexus
#

can I await a change in a list

glacial echo
#

do dyno isnt doing what youre describing

supple thorn
glacial echo
spice adder
supple thorn
#

I mean that's what i used

high nexus
#

am I able to await a change in a list

glacial echo
#

when it is unbanning someone, it presumably is just putting the same unban reason you provided in the command

supple thorn
#

It's the first solution that came to my head

slim ibex
glacial echo
#

it probably isnt firing on_member_unbanned

spice adder
#

Hmm, odd

slim ibex
#

and await syntax can only be used in async functions

#

no top-level await 😢

glacial echo
#

does dyno send a modlog if you manually unban a user

spice adder
#

One moment, let me test that

supple thorn
slim ibex
#

and also @high nexus there is 0 need to await some change in a list

pliant gulch
supple thorn
#

What kind of timer?

slim ibex
#

well that I could think of LOL

spice adder
#

Dyno does not seem to send a modlog when banned through anything other than Dyno

pliant gulch
#

Gets rid of race conditions

slim ibex
#

ah yeah smart

spice adder
#

Though I'm still confused as to how it's adding a reason to unban since (to my knowledge) unbans don't support reasons

slate swan
#

!d discord.Member.unban

unkempt canyonBOT
#

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

Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
spice adder
#

Hm, then how would you get the reason in on_member_unban?

#

Or would it use something else entirely

boreal ravine
#

Didn't I help you with this yesterday

slate swan
#

Can someone help me

boreal ravine
#

Sure why not

spice adder
pliant gulch
#

on_member_unban doesn't give you the ban data itself, only the guild the member is bound to, and the member itself. You need to query the audit log in order to get the reason for the unban

slate swan
# boreal ravine Sure why not

Alright. I’m looking to do this. When someone says hi. And embed pops up saying Hai! Then I have buttons at the button that says bye. Talk. And depending on what they click is what the bot says in embed ofc

boreal ravine
spice adder
#

Oh I've got that part done

#

I'm talking about unban reasons

boreal ravine
#

Oh

slate swan
#

@boreal ravine above is what I need help with

slate swan
quaint forum
#

How can I get a message from its id?

spice adder
pliant gulch
#

!d discord.abc.Messageable.fetch_message

unkempt canyonBOT
#

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

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

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
boreal ravine
supple thorn
pliant gulch
#

Guess you can only fetch message, even though internally the client has a memory cache

supple thorn
#

😔

pliant gulch
slate swan
#

Alright. I’m looking to do this. When someone says hi. And embed pops up saying Hai! Then I have buttons at the button that says bye. Talk. And depending on what they click is what the bot says in embed ofc

boreal ravine
spice adder
#

[<AuditLogEntry id=958885480085221376 action=AuditLogAction.unban user=<User id=155149108183695360 name=...

slate swan
#

Yo I need help

spice adder
#

I understand what it means, but I'm not quite sure how to actually use it in this case

pliant gulch
unkempt canyonBOT
slate swan
#

Dang no one is helping me

spice adder
pliant gulch
supple thorn
slate swan
# supple thorn okay

Alright. I’m looking to do this. When someone says hi. And embed pops up saying Hai! Then I have buttons at the button that says bye. Talk. And depending on what they click is what the bot says in embed ofc

boreal ravine
quaint forum
#

submissions is a list of message ids

slate swan
boreal ravine
quaint forum
#

im guessing I'm not getting the channel correctly?

hushed galleon
#

there's view examples in the github repository

supple thorn
slate swan
#

Can I get an example

supple thorn
#

almost are

#

it's just channel

pliant gulch
hushed galleon
#

although View is only available in dpy 2.0 and some of its forks

slate swan
#

I need help coding this please help

supple thorn
boreal ravine
slate swan
supple thorn
#

you legit got an example

slate swan
#

Where

boreal ravine
slate swan
boreal ravine
#

Click one

supple thorn
#

it's examples

boreal ravine
#

confirm.py

supple thorn
#

click one

hushed galleon
#

what version of dpy are you using @slate swan

slate swan
#

I don’t want an command

#

I want it just an word “hello”

#

Anyone know How i can grab the guild ID from the message sent ```py
@bot.listen()
async def on_message(message):
guild= message.guild.id
if message.content.startswith("prefixreset"):
with open ("prefixes.json", "r") as f:
prefixes=json.load(f)
prefixes.pop[str(guild)]
prefixes[str(guild)] = "s-"
with open ("prefixes.json", "w") as f:
json.dump (prefixes, f, indent=4)
await message.channel.send("Reset prefix to s-")
await bot.process_commands(message)

#

what i do rn grabs the message ID and dumps that into the json instead of the guild id

boreal ravine
high nexus
#

wait so how would I go about awaiting a change in a list or doing something with a similar affect

slate swan
hushed galleon
glacial echo
slate swan
slate swan
supple thorn
#

or just message.guild

slate swan
#

oh

supple thorn
#

i don't remember

slate swan
#

ill try that rq

hushed galleon
#

having to mention the bot means you can write it as a command, and would more sense than the bot just reacting to anyone that types prefixreset

supple thorn
#

fuck

boreal ravine
hushed galleon
#

message.guild gives you the Guild object

supple thorn
#

yes

hushed galleon
#

it doesnt seem like it should be adding any message id to your json

boreal ravine
slate swan
boreal ravine
#

What

supple thorn
#

what

slate swan
#

what

boreal ravine
#

@slate swan Don't

slate swan
supple thorn
#

chain starting

slate swan
#

Hello

hushed galleon
#

did you check if the added id actually did come from a message?

slate swan
#

Can I just get help for my request

supple thorn
supple thorn
slate swan
#

Alright. I’m looking to do this. When someone says hi. And embed pops up saying Hai! Then I have buttons at the button that says bye. Talk. And depending on what they click is what the bot says in embed ofc

#

Why can’t u make that into my example

supple thorn
#

why are you spamming these messages

supple thorn
hushed galleon
#

also what is your dpy version

slate swan
#

What’s dpy?

hushed galleon
slate swan
#

💀 💀 💀

supple thorn
slate swan
#

Idk man

slate swan
hushed galleon
#

wait you havent started with a library yet?

supple thorn
#

i'm confused how you got this far without even knowing the library you're using

slate swan
#

If you guys wanna help please help and I won’t speak on the chat for any longer

supple thorn
#

you did get helped

slate swan
supple thorn
#

you're lowkey asking to get spoonfed

hushed galleon
#

this is a serious question, we really need to know how far you are so we can start with the most appropriate information

pliant gulch
#

Not spoonfeeding != Not helping

slate swan
#

Thank you guys I guess I’m going in stackoverflow/yt

supple thorn
high nexus
hushed galleon
#

gl then

supple thorn
#

💀

quaint forum
#

How do I get the reactions from a message?

I'm trying to do

        for message in submissions:
            channel = client.get_channel(submissionChannelID)
            message = channel.fetch_message(message)
            if message.reactions.count > currentHighestReactions:```

But it is telling me that reactions is not a attribute of message
#

Im scrolling through the documentation and just dont understand this

final iron
#

!d discord.Message.reactions

unkempt canyonBOT
pliant gulch
#

You need to await fetch_message as I said eariler

#

It's a coroutine

quaint forum
#

too bad it works without the await... lol

pliant gulch
#

Right now it's erroring because message is a coroutine object. Not an actual discord.Message object

#

A coroutine object has no attribute reactions

quaint forum
#

the if statement is whats erroring not the fetch

pliant gulch
#

So, await it. Then it will work

quaint forum
#

Wouldnt it error at the fetch and say it has to await?

pliant gulch
#

No?

#

You don't need to always await a coroutine.

#

But in this case you do

quaint forum
#

okay ill try it in a second

pliant gulch
#

Also, keep in mind list.count is a method, not an attribute

#

If you want the amount of elements in the list you cast len

#

!e ```py
print(len([1, 2, 3]))

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

3
slim ibex
#

!e

print([1, 2, 3].__len__())

🗿

unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

3
pliant gulch
#

You know this really tricked me up

#

Because a while back I thought len was always O(n)

slim ibex
#

its O(1) right

pliant gulch
#

But it depends on the object's implementation of __len__, in the case of python sequences. It's all O(1) yes

#

Custom user objects could have it be O(n), O(log n) O(n^2) etc

slim ibex
#

cool

#

custom O(n log n) version incoming

quaint forum
#

Okay I understand the await now

#

i think

slim ibex
#

what didn't you understand about ti before

quaint forum
#

when to use it

slim ibex
#

use it when you are calling a coroutine

quaint forum
#

right

#

but I also have a new problem that I dont understand much either

#

I know you said the list.count is a method so it wont have the count of the reactions but all of the reactions right?

#

I added len() and it doesnt like it much

tame nymph
#

#help-carrot can someone take over i don't want to help someone that doesn't know python and is trying to code a bot

quaint forum
#
        for message in submissions:
            channel = client.get_channel(submissionChannelID)
            message = await channel.fetch_message(message)
            if len(message.reactions.count) > currentHighestReactions:
                currentHighestReactions = len(message.reactions.count)
                currentWinner = message.author.id```
slim ibex
#

lol

pliant gulch
#

You never removed message.reactions.count

tame nymph
#

I need to go do some homework

pliant gulch
#

Like I said earlier, list.count is a method

tame nymph
#

take over for me please

pliant gulch
quaint forum
#

i dont understand

pliant gulch
#

remove .count, and cast len on the list

slim ibex
#

seems like transpiled JS or sometuing

quaint forum
#

ah okay thanks, I was confused cause you said I never removed the whole message.reactions.count

pliant gulch
#

👍

slim ibex
#

also not sure if this is the right cahnnel for this

balmy ivy
slim ibex
#

a random script tag doesn't tell me anything though

pliant gulch
#

Something cloudflare?

#

Is this within the scope of this channel

slim ibex
#

thats what im wondering

quaint forum
#

I think message.reactions gets the amount of unique reactions and not the like amount of times a reaction was used on a message

final iron
#

!d discord.Message.reactions

unkempt canyonBOT
high nexus
#

yo if I take argument from a command what data type is it in

slim ibex
high nexus
slim ibex
#

dpy enforces types in typehints iirc

pliant gulch
#

If no typehint is given it defaults to str

#

And if you give an incompatible typehint, E.g a type without an equivelent converter

#

It will not work, I think?

#

Or it might just cast str

#

I can't remember the behaviour

slate swan
#

how can I create a listener for an event, I mean, I want to have the same event twice but I cannot do this, I must create a listener but how?

pliant gulch
#

!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/master/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...
silent ermine
#

how to make a safe eval command

slate swan
hushed galleon
#

for public evals you could look into snekbox for isolating python, its developed by this discord

velvet compass
#

There is snekbox, but its pretty closely tied to the infrastructure we have. iirc there are no plans to make it totally standalone

#

Or there is a way to port it to another project, and I just don't know how to

hushed galleon
#

ah okay

silent ermine
slate swan
silent ermine
velvet compass
silent ermine
#

like

#

!eval print("sussy")

unkempt canyonBOT
#

@silent ermine :white_check_mark: Your eval job has completed with return code 0.

sussy
pliant gulch
#

Python bot runs off of docker, you could probably modify that to run your own bot along side snekbox API

#

Might not work though in case of some specifics

#

Definitely easier then doing it yourself with NsJail

pliant gulch
#

Snekbox uses NsJail under the hood for process isolation

#

And API as in the snekbox API

#

It’s a REST one

slate swan
silent ermine
slate swan
pliant gulch
#

To clear any confusion you might have regarding the API, it’s not hosted on the web and rather it’s localhosted

#

In case you were wondering it there was some hosted API

boreal ravine
pliant gulch
#

From my experience of doing a PR for the bot the docker boots the API up locally

boreal ravine
sick birch
#

That, or for the learning experience and more control, set up your own nsjail isolated environment for safe eval

pliant gulch
#

I'll probably be checking out NsJail later and make my own project off it

#

Process isolation seems pretty interesting

sick birch
#

Indeed

pliant gulch
#

Albeit, not my field of study

high nexus
#

Hey guys when I do queue.join() my thing does not unblock

sick birch
bronze pilot
high nexus
#

And the queue is cleared

#

But it just does not unblock

bronze pilot
#

one moment

silent ermine
pliant gulch
high nexus
#

idk if you can tell anything off that

hearty dust
#

int or str?

pliant gulch
#

It should show 0

torn sail
hearty dust
#

thanks

high nexus
high nexus
pliant gulch
#

😔 Did they get rid of it or something? Danm

#

Well, not sure but just make sure every time you finish a put call or something, that you call task_done()

high nexus
#

ok

high nexus
pliant gulch
#

I'm unsure then, if you did it properly join should've unblocked when all tasks are counted as finished

little drift
#

I didn't get any response in #python-discussion so I'm posting it here.

I'm trying to start my discord.py bot with self.run() (yes it inherits commands.Bot) but discord.py is raising LoginFailure: Improper token has been passed and I've copy-pasted the token over and over.

I was using secretbox to get the token from .env file and there's no problem with secretbox (I tried printing the token and it just prints that).

Is this a discord.py bug?

#

I've also tried creating a new bot and copy-pasted it's token but it raised the same error as before.

slate swan
#

Can you show code?

#

Also make sure you're not prepending anything onto the token string.

cerulean osprey
#

Anyway to make the bot do a thing when mentioned? (docs link preferred)

little drift
#

bot.py

class Client(commands.Bot):
    def __init__(self) -> None:
        self.config = SecretBox(auto_load=True)
        self.logger = logging.getLogger("discord")

        super().__init__(
            command_prefix="!",
            description="Later...",
        )

    async def init_extensions(self) -> None:
        extensions = os.listdir("./extensions")
        for extension in extensions:
            self.load_extension(f"extensions.{extension[:-3]}")

    async def on_ready(self) -> None:
        await self.init_extensions()

    def init_logging(self) -> None:
        self.logger.setLevel(logging.DEBUG)
        handler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w')
        handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
        self.logger.addHandler(handler)

    def launch(self) -> None:
        self.run(self.config.get("BOT_TOKEN"))

main.py

from bot import Client

if __name__ == '__main__':
  client = Client()
  client.launch()
cerulean osprey
slate swan
#

@cerulean osprey That can be implemented yourself with little to no logic, doc links aren't needed.

if f'<@{your_app_id}>' in message.content:
    ...
cerulean osprey
little drift
slate swan
#

@cerulean osprey

cerulean osprey
#

I forget, what does the ! do again?

slate swan
#

Uh it's cause of how mentions work. If the user has a nickname I'm pretty sure Discord adds an exclamation mark to the mention

cerulean osprey
#

Ahh yeah that makes sense, I've seen it somewhere just forgot what it was abt. Honestly I had forgotten mentions can be checked like that, ty

slate swan
#

Discord.py has little to do with your token being invalid.

#

2.0 can be buggy, but it's only for features being developed.

#

The logic behind Client.run() was implemented ages ago and won't break that easily.

little drift
pliant gulch
cerulean osprey
slate swan
#

What are you passing as BOT_TOKEN?

little drift
#

the bot token ofc

slate swan
#

Are you sure it's not the OAuth2 secret?

little drift
#

I've also tried passing other bot tokens

#

nope

slate swan
little drift
#

I've tried that

slate swan
little drift
#

I've also reset it a couple of times now

little drift
slate swan
#

Hm. Odd.

little drift
#

a problem with discord perhaps?

slate swan
#

No

little drift
#

discord is returning 401

slate swan
#

Well, maybe but it's unlikely

cerulean osprey
#

I had to reset my token like 2-3 times when it happened to me.. but Im not sure tbh

little drift
#

hmm

slate swan
little drift
#

nope

#

not now atleast

pliant gulch
#

Can you verify self.config.get is returning a string and not None

little drift
#

I've printed it out

#

and it's a string

#

I've also tried passing the token directly

slate swan
#

Can you try this:
Reset your application token again and copy it with the COPY button (don't select it)
Paste it into your .run() call

little drift
#

I'm using the copy button

#

I don't usually select

pliant gulch
#

How long has this issue been happening?

little drift
#

since yesterday

slate swan
#

What do you believe triggered it?

pliant gulch
#

What happens when you run a normal vanilla client with your token?

#

Like without making a subclass, etc

little drift
#

I don't think anything triggered it

pliant gulch
slate swan
#

Try opening a Python terminal and pasting

import discord; discord.Client().run('TOKEN')
little drift
#

i ran it with nextcord and it worked

little drift
#

hm it worked

#

weird

slate swan
#

Can you please run python3 -m discord -v in a terminal?

little drift
#
- Python v3.9.9-final
- discord.py-self v2.0.0-alpha
    - discord.py-self pkg_resources: v1.7.3
- aiohttp v3.8.1
- system info: Windows 10 10.0.19043
slate swan
#

At this point I have reason to believe it's your code that's failing.

little drift
#

hm it doesn't make sense though

slate swan
#

Just try passing the token in your env file without enclosing it in quotes.

#

*Again.

little drift
#

it worked smh

slate swan
#

So what was it?

little drift
#

I just installed nextcord to check if nextcord returns the same error

little drift
austere solstice
#

Help pls

slate swan
#

Let me tell you from experience, sometimes we (as humans) feel very confident in what we do not know or are not sure of. In this case (I've experienced this too), you're fixated on the library being faulty. I suggest taking a step back and looking at the actual source of the issue (don't look at the direct cause of the error, just trace further back)

austere solstice
slate swan
spring flax
#

How is owner text yellow

austere solstice
austere solstice
slate swan
slate swan
austere solstice
spring flax
slate swan
austere solstice
#
owner = str(ctx.guild.owner)
slate swan
spring flax
#

Ah

slate swan
austere solstice
slate swan
#
intents = discord.Intents.default()
intents.members = true

client = discord.Client(intents=intents)

...
austere solstice
fading harness
slate swan
fading harness
slate swan
austere solstice
austere solstice
little drift
slate swan
austere solstice
slate swan
feral lichen
#

hey is there a way to dm a user using a bot.event? just wondering

#

like specifically

slate swan
#

But you're probably right.

austere solstice
#

@slate swan really 2,000+ lines?

feral lichen
#

bro making dyno 2.0 💀

austere solstice
#

lol

slate swan
slate swan
feral lichen
#

ight thanks

slate swan
#

I'm not supposed to have it but it got leaked so what should I do

austere solstice
slate swan
#

It's kinda bad code ngl

feral lichen
#

oh shit fr?

#

thats funny

slate swan
#

I mean it's bad because it's inconsistent and kind of rushed

feral lichen
#

i thought it was in js not py

slate swan
#

Oh wait

slate swan
#

I'm not sure what my activity status was saying

feral lichen
#

oof

slate swan
#

I thought the Dyno project was showing up too

little drift
#

pip warned me about aiohttp being outdated while installing nextcord

feral lichen
#

idk if this is a simple mistake, but when i lock a channel and it sends to my modlogs, it says for example @wizguy has locked None for reason, for some reason it says none for the channel. Any help? ```py

@bot.command()
@commands.has_permissions(manage_channels=True)
async def lock(ctx, reason=None, channel : discord.TextChannel=None):
overwrite = ctx.channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = False
await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
await ctx.send(f'Channel locked for {reason}')
channels = bot.get_channel(958877700351754250)
await channels.send(f'{ctx.author.mention} has locked {channel} for {reason}')
@lock.error
async def lock_error(ctx, error):
if isinstance(error,commands.CheckFailure):
await ctx.send('You do not have permission to use this command!')

high nexus
cerulean osprey
austere solstice
cerulean osprey
#

Im not sure if this was said or not but I forgot I also did 1 other thing that might've fixed it... (or it could be entirely useless, idk 😂

austere solstice
high nexus
#

Rn I have activities off but vscode with them on just does not show

high nexus
cerulean osprey
#

Isnt it a plugin?

austere solstice
cerulean osprey
#

Or an extension yeah

high nexus
austere solstice
sick birch
austere solstice
feral lichen
# austere solstice whats prob in it?

idk if this is a simple mistake, but when i lock a channel and it sends to my modlogs, it says for example
@feral lichen has locked None for reason
, for some reason it says none for the channel. Any help?

austere solstice
#

let me test it

#

then i tell

feral lichen
#

no it says "None" for the channel instead of the channel name but sure

cerulean osprey
feral lichen
#

everything else is fine besides that

hasty bison
#

what is the command for this with colour?

heagpl
wkgfoa

cerulean osprey
#

Yeah but the channel in question, like the channel you want, is it that one?

austere solstice
feral lichen
feral lichen
hasty bison
#

i mean this

cerulean osprey
#

Oh, embed color

hasty bison
#

what is the command

feral lichen
#

for embeds?

hasty bison
#

yes

feral lichen
#

wait i dont think that worjs

#

only for specific things

cerulean osprey
#
embed = discord.Embed(title"...", color=0x{hex code}
``` is what I have... tho Idk if thats the best way
feral lichen
#

yea theres a bunch of ways

hasty bison
feral lichen
#

embed=discord.Embed(title="Commands", url="", description="", color=discord.Color.blue())

cerulean osprey
#

But, naturally since ur making a disc bot 😂

feral lichen
#

then ```py
await ctx.send(embed=embed)

feral lichen
# hasty bison is there a library i need to import?

im pretty sure on grepper or stackoverflow you can find a example someone used like ```py
embeded = discord.Embed(title=server.name, description='Server Info', color=hex)
embeded.set_thumbnail(url=server.icon_url)
embeded.add_field(name="Created on:", value=server.created_at.strftime('%d %B %Y at %H:%M UTC+3'), inline=False)
embeded.add_field(name="Server ID:", value=server.id, inline=False)
embeded.add_field(name="Users on server:", value=server.member_count, inline=True)
embeded.add_field(name="Server owner:", value=server.owner, inline=True)

    embeded.add_field(name="Default Channel:", value=server.default_channel, inline=True)
    embeded.add_field(name="Server Region:", value=server.region, inline=True)
    embeded.add_field(name="Verification Level:", value=server.verification_level, inline=True)

    embeded.add_field(name="Role Count:", value=roles, inline=True)
    embeded.add_field(name="Emoji Count:", value=emojis, inline=True)
    embeded.add_field(name="Channel Count:", value=channels, inline=True)
#

^for an example

worn bane
#

hello, i am using Hikari for my API and beginning to code a discord bot, however everything i try for the Discord Bot Status seems to fail and return some sort of error. may I have some help?

cerulean osprey
#

I can try, tho I am not very good at it myself. Mind showing the code?

slate swan
austere solstice
austere solstice
slate swan
slate swan
#

If you enable the extension it will connect via RPC

#

I doubt you know how activity statuses on Discord even work

austere solstice
slate swan
#

Uh off topic

#

Regardless, just read what it says on the extension page

#

Why ask me

sick birch
feral lichen
austere solstice
slate swan
#

If you're using Sublime you should also just know how to proceed after installing an extension

worn bane
cerulean osprey
#

Preferably in a codeblock :o

worn bane
#

oh my bad

#
intents = hikari.Intents.default()
intents.members = True
intents = intents.all()
commandprefix = "$"
activity = hikari.Activity(type=hikari.ActivityType.playing, name=f"at Paradise Point")
client = lightbulb.commands(command_prefix=commandprefix, intents = intents, activity=activity, status=hikari.Status.ONLINE)```
#

@cerulean osprey ^^

cerulean osprey
#

Uhhh... I have never used hikari tbh... but I can still try to help. Whats the error?

worn bane
#

but when i put a similar code into the

@bot.listen(hikari.StartedEvent)
async def on_start(event):

code, it says that 'BotApp' isnt defined or somthing along those lines

cerulean osprey
#

(before anyone yells at me to rename it to bot, no 😂 )

vale wing
#

Don't you set an activity with change_presence()

cerulean osprey
#

Thats how you change one iirc

#

Cuz thats async

worn bane
cerulean osprey
vale wing
#

Idk anything about hikari so can't help with it probably

#

Also why does it sound like a sort of anime

worn bane
#

i was just watching a video on how to set python up, and they recommended hikari as discord.py has apparently stopped??

cerulean osprey
#

Cuz its Japanese iirc lmao

cerulean osprey
cerulean osprey
#

It didnt stop working

vale wing
worn bane
#

i have learnt python at school

vale wing
#

Oh k

worn bane
vale wing
#

Could you give a link to that video

cerulean osprey
#

Its what I use 🤷‍♂️

worn bane
high nexus
#

yo I still can't figure out why my queue.join() isn't unblocing

#

blocking

vale wing
high nexus
vale wing
#

And what is queue

high nexus
#

in asyncio

austere solstice
#

downloading kernal32.dll brainmon

vale wing
#

@worn bane as I noticed, in that vid some steps are missing.

  1. Python installation. You need to download the interpreter from https://python.org and run the setup, putting the "Add Python to PATH" checkmark on.

  2. Installing VSC Python extension. Head to "Extensions" tab in VSC (cubes), search python and install it

  3. There's a better way of activating venv in VSC: after you created it, press CTRL+SHIFT+P, search "Python: Select Interpreter" and select the one with venv (not global). If it tells you that scenarios execution is prohibited in this system just use global if you don't wanna watch another tutorial of how to enable it

worn bane
vale wing
tropic flame
#

where if a person doesnt send a command once 24hours a role will be removed from him and if he does send then he has the role for 24 hours from when he sent it

tropic flame
#

i cant make the thing where if he sends the command he will keep the role for next 24 hours

vale wing
#

Store the limit time in a db and periodically fetch the users to take the role off from using the tasks.loop

supple thorn
vale wing
#

In sqlite you could do something like

user_id INT | takeoff_time REAL```
#

And store the timestamps

supple thorn
vale wing
#

When he uses the command do something like INSERT OR UPDATE or whatever it's called in sqlite

#

Ok it's INSERT OR REPLACE

supple thorn
#

hi hunter

maiden fable
#

Hi

austere solstice
#

succesfuly downloaded kernal32.dll

supple thorn
buoyant zodiac
#
msg = await channel.send(embed=embed)
await msg.add_reaction(":white_check_mark:")
#

why doesnt the reaction work?

slate swan
#

Error?

#

Use this

slate swan
supple thorn
#

copy this

#

and paste it directly into the string

#
"✅"
boreal ravine
#

Or \N{WHITE CHECK MARK}

hasty stump
#

how can i specify that only @staff can use that command

boreal ravine
hasty stump
boreal ravine
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
hasty stump
#

i mean is there anyway i can add the role id there?

boreal ravine
#

yes sure

hasty stump
#

only they can access

hasty stump
boreal ravine
boreal ravine
hasty stump
#

@discord.ext.commands.has_role(role id here)

#

like this?

#

wait

boreal ravine
#

yes

hasty stump
#

@commands.has_role(role id here)

boreal ravine
#

Or that way

oblique adder
#

How to create an announcement channel ?

cerulean osprey
#

This might be a basic question but I want to make sure

my_list = ["a", "b", "c"]

if x == any(my_list):
``` this will check to see if x = either a, b, or c right?
oblique adder
maiden fable
maiden fable
cerulean osprey
cerulean osprey
austere solstice
buoyant zodiac
#

why do they stack, this is DiscordComponents

boreal ravine
buoyant zodiac
#
await ctx.send(embed=embed,
        components = [
      Button(style=ButtonStyle.URL,label="Invite",url=f""),Button(style=ButtonStyle.URL,label="Support Server",url="")
    ]
    )

boreal ravine
buoyant zodiac
#

what is that

boreal ravine
#
[["hello"]]
#

A 2D list

buoyant zodiac
#

@boreal ravine thank you

boreal ravine
#

👍

hasty stump
rocky trench
hasty stump
rocky trench
hasty stump
hasty stump
#

i am new in coding database and api stuffs

#

trying to learn

austere vale
#

what is this?

buoyant zodiac
#
@role.command()
    @commands.has_permissions(manage_roles=True)
    async def add(self, ctx, user: discord.Member, role:discord.Role):
            
        if role.position > ctx.author.top_role.position:
            return await ctx.reply("you cannot give someone a role higher than your top role")
        elif ctx.author is ctx.guild.owner:
            pass
        else:
            try:
                await user.add_roles(role)
                await ctx.reply("**role** gave")
            except:
                await ctx.reply("**role** failed")
``` i want it so if the guild owner uses the command they can do whatever
buoyant zodiac
austere vale
#

how do i fix it?

buoyant zodiac
#

is it not letting you run your bot?

austere vale
#

no i cant run it

buoyant zodiac
#

your api blocked im pretty sure.

austere vale
#

isnt there a way to clear console or smth and get it running again?

hasty stump
#

use that method

boreal ravine
buoyant zodiac
#

wait

austere vale
worn bane
#

anyone have some code that sends an embed to a user, my code doesnt seem to work

hasty stump
buoyant zodiac
#

hes on repl

hasty stump
#

oh

boreal ravine
hasty stump
#

i didnt noticed

hasty stump
worn bane
# boreal ravine Show your code
  if msg.startswith('Hello!'):
    await message.author.send
    embedVar = discord.Embed(title="HELP", description="tEXT", color=0x619491)

This works without the embed, but when i go to add an embed code it does not work

boreal ravine
hasty stump
#

try that i think

boreal ravine
hasty stump
buoyant zodiac
#

message*

boreal ravine
hasty stump
boreal ravine
#

alright

hasty stump
# boreal ravine alright

i want to store staff team data there
and they can also import data So when people will do ?staff list they can see all the peoples name in list whoever merged account into bot

boreal ravine
#

ok

hasty stump
boreal ravine
boreal ravine
worn bane
#

it works! thank you so much, have a great night

boreal ravine
#

👍

worn bane
#

@boreal ravine im so sorry, ive hit a wall in my knowledge even when its the simplest thing.

@client.event
async def on_member_join(member):
    embedVar = discord.Embed(title="HELP", description="tEXT", color=0x619491)
    await client.message.send(embed=embedVar)

which part of this is incorrect? it doesnt seem to be sending to new users

(what you mentioned hasnt seemed to fix it)

#

i just had to resend it so it was in the right chanlel

boreal ravine
#

Any errors?

worn bane
#
@client.event
async def on_member_join(member):
    embedVar = discord.Embed(title="HELP", description="tEXT", color=0x619491)
    await member.send(embed=embedVar)
boreal ravine
#

do you have member intents?

worn bane
#
intents = discord.Intents.default()
intents.members = True
intents = intents.all()
@client.event
async def on_member_join(member):
    embedVar = discord.Embed(title="HELP", description="tEXT", color=0x619491)
    await member.send(embed=embedVar)

@boreal ravine

boreal ravine
#

ok now try again

worn bane
supple thorn
supple thorn
vale wing
#

First 2 statements are unnecessary

worn bane
vale wing
#

How is client defined

worn bane
vale wing
#

Yes

worn bane
#

client is
client = commands.Bot(command_prefix = ';')

vale wing
#
intents = discord.Intents.all()```
Basically enables all intents
vale wing
#
intents = discord.Intents.all()
client = commands.Bot(command_prefix=";", intents=intents)```
#

Like this

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

worn bane
#

okay ive got the intents and enabled them on the bot

supple thorn
#

or you can keep listening to Exenifix if you like the human touch

worn bane
#

so now i guess i reinvite the bot to the server?

worn bane
#

or will it automatically

vale wing
#

No need to

#

None of scopes were changed

supple thorn
#

just restart your bot

worn bane
#

okay so then it should work?

supple thorn
#

and it should work if you set it up right

swift imp
#

how to use bot mention as prefix?

vale wing
#

Prefix helpers or smth

worn bane
#

amazing, it did.

#

thank you ALL so much, you were all such a big help

#

have a great night!!

vale wing
#

!d discord.ext.commands.Bot.command_prefix check the docs about parsing functions to there

unkempt canyonBOT
#

The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.

An empty string as the prefix always matches, enabling prefix-less command invocation. While this may be useful in DMs it should be avoided in servers, as it’s likely to cause performance issues and unintended command invocations.

feral lichen
#

@bot.command()
async def dmtwo(message):
  user = bot.get_user(842756567527063582)
  await user.send("Hello!")
feral lichen
#

hey i was wondering what was wrong with this. Basically someone uses the command dmtwo and it sends me hello.

vale wing
feral lichen
#

holup one sec

vale wing
#

Why do you call the first arg message

#

It's not an actual message and might cause confusion

supple thorn
#

yeah

vale wing
#

Call it ctx instead

feral lichen
#

yeah so i changed it to ctx just a visual mistake, but yeah no error and dms me nothing

vale wing
#

Do you have DMs opened + do you have an error handler

feral lichen
vale wing
#

Check if user is not None by printing it

#

Replit might have issues with ratelimit

feral lichen
#

ight lemme try it on visual code

#

no still doesnt work @vale wing

vale wing
#

Have you tried printing the user

feral lichen
#

wym

#

like in console?

vale wing
#
user = ...
print(user)```
feral lichen
#

let me try and no

vale wing
#

If it turns out to be None, try fetching it with

#

!d discord.ext.commands.Bot.fetch_user

unkempt canyonBOT
#

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

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

Note

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

Changed in version 2.0: `user_id` parameter is now positional-only.
feral lichen
#

yea it said none, ill reply with any issues i might have

vale wing
#

In newer versions there's get_or_fetch_user

feral lichen
feral lichen
#

im confused on using fetch_user on how to use it

slate swan
#

cause get_user needs it.

feral lichen
vale wing
#

All API calls in dpy must be awaited

feral lichen
#

eh idk how i feel about this topic. I kinda just wanted to make a messaging system towards me. But thank you for the help i will come back to this in the future

sullen pewter
boreal ravine
#

The hell?

supple thorn
#

I don't know why but sometimes when there's new messages it doesn't show them

#

So there's like a big time gap or any gap with the messages

swift imp
#

how to disable the use of the command in private messages?

supple thorn
unkempt canyonBOT
#

@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.

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

Thx

supple thorn
#

Just add this check to your command

swift imp
#

ok

brisk zodiac
#

How do i make a command that the bot with mention me?

modest bear
#

is there is function i can use to send a message before the bot shuts down

brisk zodiac
#

nope like when i use a command the bot will mention me

boreal ravine
slate swan
#

i have intents on but it still returns member as none i dont know whats happening here
intents = discord.Intents.all()
@client.event async def on_raw_reaction_add(payload): guild = await client.fetch_guild(payload.guild_id) member = guild.get_member(payload.user_id) if payload.message_id == 958650021224517662 and guild is not None: if payload.emoji.name == "🏵️": role = discord.utils.get(guild.roles, id=958249933050368100) await member.add_roles(role)

boreal ravine
slate swan
#

yes

#

if it matters i did
client = commands.Bot( command_prefix = "!", case_insensitive = True, intents = intents )

unkempt canyonBOT
tidal hawk
#

Can Discord bots see when somebody replies to a message?

wild oxide
#

em = discord.Embed(title=Member Unbanned, color=0xff00ee, description = f'<@{ctx.author.id}> unbanned <@{member.id}>')
SyntaxError: invalid syntax. Perhaps you forgot a comma?
how to fix

tidal hawk
cedar stream
wild oxide
tidal hawk
#

Yep

#

message.MessageType.reply-> True/False

placid skiff
#

Github finally accepted me to the github copilot technical preview, i'm so happy 😄

bleak karma
#

help? this error is showing up even though me and my friend has 2fa on

pliant gulch
bleak karma
pliant gulch
#

You need 2fa on then

bleak karma
#

i have it on

pliant gulch
#

Are you sure?

bleak karma
#

very

pliant gulch
#

Just make sure, to be 100% sure

#

Ok, well that would be the only possibility then

#

Because bot's inherit 2fa from their owner's account

bleak karma
#

its enabled

pliant gulch
#

When did this start happening?

bleak karma
#

oh wait

bleak karma
pliant gulch
#

Yes

bleak karma
#

my bad i made the application on my alt account

pliant gulch
#

Checks out

bleak karma
#

😭

empty quest
#

i have an

@bot.event
  async def on_message(message)

and an

@bot.command

When I send a message to my bot, to trigger @bot.command, it also triggers @bot.event. I do not want this to happen, because two messages are being sent instead of one. How do I fix this, so that if an @bot.command is triggered, then the @bot.event will not be triggered?

hoary cargo
#

Well
Depends what you have inside the event

empty quest
#

its the ai chatterbot library

hoary cargo
#

on_message will watch over all messages sent by users

supple thorn
#

You could set it up so that only messages in a certain channel triggers the on_message

empty quest
#

on message is triggered without any command prefix in dms and with command prefix '-' in servers

#

i might have an idea

supple thorn
#

If it is then ignore

#

@empty quest what

empty quest
#

i have an idea:
i can create a command prefix for the commands, and keep that as bot.commands
for the event, i can rename to client.event, i can say on message, if it starts with that prefix, then break, else, generate ai response

#

would this work?

pliant gulch
#

!d discord.User.bot

unkempt canyonBOT
empty quest
#

thats not the issue

pliant gulch
#

You'd check via message.author.bot

#

Then return if the message author is a bot

supple thorn
pliant gulch
#

I thought the issue was the bot would trigger the thing?

empty quest
#

no

supple thorn
#

He wants it to not respond if it's triggering a command for the ai

empty quest
#

i want the ai not to respond if its a command

supple thorn
#

Yes

#

That's what i said

pliant gulch
#

Oh, you could call get_context and see if ctx.valid is True

placid skiff
#

just use the listen decorator, commands will be triggered if the message has the prefix, otherwise it will use your on_message event

pliant gulch
#

If it is, it's in a command context

#

!d discord.ext.commands.Bot.get_context

unkempt canyonBOT
#

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

Returns the invocation context from the message.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Changed in version 2.0: `message` parameter is now positional-only.
pliant gulch
#

You call this on your message object, E.g message

#

It return's a Context object, you'd then check ctx.valid

#

If it is valid you'd return since it's in a command context

empty quest
#

which is an easier option?

pliant gulch
#

Using a listener doesn't filter out messages with a command in them

#

All it simply does is subscribe a callback to the MESSAGE_CREATE event from the gateway

#

You would still need to check if there is a command in the message

#

What I mentioned would do what you want

placid skiff
#

!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/master/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...
pliant gulch
#

Do you realise, listen(...) just does the same thing as bot.event, except it doesn't override the previous subscribed callback?

#

It doesn't filter out messages that have a command context

#

Not without implementing a check yourself, which is what I'm suggesting obviously^

placid skiff
#

Yup but remember that everytime you run a command the on_command event is triggered

wild oxide
#
import os
import subprocess
import sys
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 
'py-cord==2.0.0b4'])
reqs = subprocess.check_output([sys.executable, '-m', 'pip',
'freeze'])
installed_packages = [r.decode().split('==')[0] for r in reqs.split()]
os.system('python main.py')```
anything wrong here?
placid skiff
#

triggering that event should automatically ignore the on_message event used by a listener

wild oxide
pliant gulch
#

A command is still invoked VIA a MESSAGE

#

Otherwise you'd be invoking from thin air

placid skiff
#

Uhm well let's read the source code

supple thorn
pliant gulch
#

🤦 What does the source code have to do with this issue?

#

You cannot invoke a command without sending a message, that would dispatch MESSAGE_CREATE

#

You cannot somehow invoke the command from thin air

supple thorn
empty quest
#

anyway what are the lines of code i need to write to make it ignore an on_message when a command is triggered? i didnt understand the first time it was explained, as im still a beginner in discord.py

supple thorn
placid skiff
pliant gulch
wild oxide
pliant gulch
placid skiff
#

if you have no event decorators in your code then in the backedn it will be registered as a listener

#

btw if the message has a prefix

placid skiff
#

and no on_message event using event decorator are triggered

pliant gulch
#

commands.Bot has a default on_message

placid skiff
#

it will call the on_command event

empty quest
#

like this?

pliant gulch
#

That's how your commands work

pliant gulch
placid skiff
pliant gulch
supple thorn
#

I like when andy and Blvck argue

unkempt canyonBOT
#

discord/ext/commands/bot.py lines 1276 to 1277

async def on_message(self, message: Message, /) -> None:
    await self.process_commands(message)```
pliant gulch
#

Well look what we have here 😳

#

What do you know huh, it does have a default on_message 😂

#

Otherwise your commands wouldn't work without manually calling process_commands

placid skiff
pliant gulch
#

And do you know what a listener is

#

It's an event, but doesn't override the previous subscribed callback

placid skiff
#

exactly

pliant gulch
#

So.... it would still call this

placid skiff
#

and what's on_command?

pliant gulch
#

What does on_command even have to do with this?

placid skiff
#

an event, in other terms a callback

#

on_command will be triggered everytime you run a command

pliant gulch
#

on_message -> if command dispatch on_command

#

You're still running on_message

empty quest
#

now it's not running the @bot.command at all - its just going for @bot.event all the time

cloud dawn
#

Andy is right but to be fair, who reads the source code.. py_guido

pliant gulch
slate swan
#

hi uh i did not find the right channel for help but i wanna ask a question

slate swan
#

i downloaded pyinstaller like 10 times and its not running

cloud dawn
slate swan
pliant gulch
cloud dawn
unkempt canyonBOT
#

PyInstaller bundles a Python application and all its dependencies into a single package.

slate swan
#

but the commands are not working

cloud dawn
slate swan
cloud dawn
#

You either gotta go to the location of pyinstaller or add it to PATH.

slate swan
slate swan
cloud dawn
slate swan
#

not sure, binya is the name of the computer

pliant gulch
# placid skiff Happy now?

You clearly don't understand the problem that OP was asking about. They want to ignore COMMANDS in on_message, and they have an AI Chatbot... The input isn't always test

slate swan
#

so it need to be there

pliant gulch
placid skiff
#

my god, a message listener will not be triggered with a commands

pliant gulch
#

Then run bot a command, and a regular message

#

and see the output, and send it in the chat

cloud dawn
#

Where is it actually?

slate swan
#

found it

#

to add it now to path?

cloud dawn
slate swan
placid skiff
pliant gulch
# placid skiff

And what do you know!! You just proved that commands still dispatch on_message

cloud dawn
#

So in that folder open cmd or powershell, win11 cmd is in the context else hold SHIFT+RIGHT_CLICK

pliant gulch
#

Oh wait, I read this wrong. Print the content

placid skiff
#

Nope, it would send &test, if you were correct

pliant gulch
#

And are you stripping the prefix?

#

You can add a kwarg to the bot's constructor that strips the prefix

unkempt canyonBOT
#

discord/ext/commands/bot.py line 178

self.strip_after_prefix: bool = options.get('strip_after_prefix', False)```
placid skiff
cloud dawn
pliant gulch
placid skiff
pliant gulch
slate swan
#

to like cd it?

pliant gulch
#

Show the constructor & super().init(...)

cloud dawn
#

Way faster, you can do cd it.

placid skiff
slate swan
radiant wing
#

What's off here? Does not work

cloud dawn
slate swan
slate swan
cloud dawn
radiant wing
#

Need to be more careful with that

cloud dawn
slate swan
#

?

cloud dawn
#

Context menu

slate swan
#

i dont see context menu

cloud dawn
#

Your path has to be inside the folder of your executable.

#

Okay so in cmd right.

slate swan
#

yes

cloud dawn
#

This is my path now C:\Users\eboss>

pliant gulch
cloud dawn
#

So i will execute command inside that folder.

pliant gulch
bleak karma
#

help?

@bot.command()
async def massban(ctx, members: Greedy[int], reason=None):
  if not members:
    await ctx.send("Please specify the users i need to ban.")
  else:
    list1 = members
    for i in list1:
      await ctx.guild.ban(discord.Object(id=int(i)))

    await ctx.send(f"successfully banned **{len(members)}** user(s).")

error:

HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In user_id: snowflake value should be less than or equal to 9223372036854775807.

i tried banning a bunch of raiders but it gives an error

slate swan
placid skiff
cloud dawn
slate swan
pliant gulch
# placid skiff mhhh

So, as you can see it does run on_message even when the message is a command 😂

slate swan
#

still not working

cloud dawn
pliant gulch
slate swan
#

Can anyone tell me, how i can read a file then count for ctx.author in it and do a if statement like this:
if str(ctx.author) more than 3 times in the file:
well in the correct words obviously

#

i cant figure it out

slate swan
pliant gulch
radiant wing
cloud dawn
placid skiff
#

well btw if you are right i'll not suggest to use the get_context method

cloud dawn
placid skiff
#

!d discord.ext.commands.Bot.get_context

unkempt canyonBOT
#

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

Returns the invocation context from the message.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Changed in version 2.0: `message` parameter is now positional-only.