#discord-bots

1 messages · Page 795 of 1

slim ibex
#

Elaborate more

silver magnet
#

for example ?command @amber beacon#1234

#

the bot should know its trying to find user#1234

#

so from mention, i would say

hoary cargo
#

Ok

slim ibex
#
@command()
async def command(ctx, member: discord.Member):

silver magnet
#

thanks

slim ibex
#

The type hint lets it know to look for a member

#

it won’t work without the type hint

slate swan
#

unless you do something weird like get_member(int(member.strip('<@!>'))) inside the function

silver magnet
#

and if i want the command to give out a specific role to this user? i tried ctx.member.add_roles

slim ibex
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

Oh Robin!

#

Congrats on the Helper role

silver magnet
sick birch
sick birch
#

And can we see the code?

silver magnet
#
async def verify(ctx, member = discord.Member):
    vrole = discord.utils.get(ctx.guild.roles, id=815652214198370334)
    await ctx.member.add_roles(vrole))```
honestly i wouldnt be surprised if everything in this is wrong
maiden fable
#

await ctx.member.add_roles(vrole)

#

there is another )

silver magnet
#

i removed that lol

slim ibex
#

It’s member: discord.Member

silver magnet
#

forgot to do it while copy pasting

prime ibex
#

Is it true that after a certain amount of time discord.py will be unusable?

silver magnet
#

i mean yeah it lost support

slim ibex
#

It’s discontinued but still useable

#

just use a fork or one of those non forks

silver magnet
slim ibex
#

I don’t think you need the ctx before member.add_roles

silver magnet
#

works now

slate swan
#
 NOTE: global commands can take up to 1 hour to show up after registration.
#

what does this means

#

i have to wait a hr to see changes in app??

slim ibex
#

wtf is a global command? Slash commands usually take time to show up though

prime ibex
slim ibex
#

so maybe that’s what it means

prime ibex
#

Hmm

#

Why thou

slim ibex
#

well it is still a lib and there is no point to not make it work anymore

prime ibex
#

Well once discord start releasing new breaking things I’m pretty sure users who want to have a verified bot won’t be able to use

slim ibex
#

well yeah it doesn’t have slash commands or things like that

#

so that’s why it’s recommended to use a fork

prime ibex
#

Mhm

prime ibex
silver magnet
#

how do i make the bot delete the last 2 messages in a channel

slate swan
prime ibex
#

If u want the cmds to be added instantly for testing, use the guild_ids param in ur fork

slim ibex
unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
prime ibex
slate swan
prime ibex
prime ibex
#

If ur testing then sure

slim ibex
#

Those 3rd party libs prolly won’t be as good as the forks will be tbh

prime ibex
#

But it will be available only that specific guild

slim ibex
#

but also watch the non-forks like Pincer and Hikari

haughty quartz
#

is it possible to get the bot the search a user id, as ex. i have a string "gorgonzola" can it search for my id? ofc if im on the server

slim ibex
#

!d discord.Message.author

unkempt canyonBOT
slim ibex
#

if your the message author you just need to use that

silver magnet
haughty quartz
slim ibex
#

I don’t think a string can search for a user my man

haughty quartz
#

a example would be !rank gorgonzola, could it search for my id and get my rank in the db

slim ibex
#

oh

prime ibex
silver magnet
#

oh

prime ibex
#

If u wanna go achieve what u want do

slim ibex
#

you could do something like this @haughty quartz

slate swan
# prime ibex Yes
SyncWarning: Failed to overwrite commands in <Guild id=937778685866565732> due to 403 Forbidden (error code: 50001): Missing Access```
slim ibex
#
async def rank(ctx, member: discord.Member = None)
#

it makes the second parameter after !rank be the member you want to get

prime ibex
#

Ur bot doesn’t have the slash cmd scope (application.commands) ig

#

Kick and invite it with that scope

slim ibex
#

So the command invocation would be !rank <@member>

haughty quartz
#

and then i could just use member in my code

haughty quartz
slim ibex
haughty quartz
#

!rank gorgonzola and not !rank <@gorgonzola>

prime ibex
slim ibex
#

not sure

#

haven’t tried that

haughty quartz
#

okay

#

thanks tho

slim ibex
#

I guess you could setup a converter that changes the string to find that users name if that is possible

#

That just came off the top of my head but idk if that’s possible

haughty quartz
silver magnet
prime ibex
#

It should work

haughty quartz
flat solstice
#

So I have a really weird issue with one of my commands where it's not responding and isn't giving me any errors. I do have a error handler and some members of the dpy server told me I should check out the error handler tag bc my error handler was eating my error (I don't think it is bc it error's correctly for every single other command, and all of those commands work). here is my error handler: https://sourceb.in/fL9sEcdmAl
My command that's not working:py @commands.has_permissions(administrator = True) @commands.guild_only() @commands.command(description = "Sets the bad words that aren't allowed to be said on the server.") async def bad(self, ctx, *, words: str): print(f"Input: {words}") data = await self.bot.get_data(ctx.guild.id) bad_words = [] #bad_words.append(data[28]) for word in words: bad_words.append(word) print(f"Bad Words: {bad_words}") async with self.bot.pool.acquire() as conn: await conn.execute("UPDATE data SET badwords=$1 WHERE guild=$2", [word for word in bad_words], ctx.guild.id,) await ctx.send(embed = discord.Embed(description = f"The bad words list has been update to be `{', '.join(data[28])}`.", colour = self.bot.primary_colour))and my get_data function:py async def get_data(self, guild): async with self.pool.acquire() as conn: res = await conn.fetchrow("SELECT * FROM data WHERE guild=$1", guild) if not res: res = await conn.fetchrow( "INSERT INTO data VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29) RETURNING *", guild, None, None, [], None, None, None, False, [], [], False, [], [], 0, False, 7, None, [], None, None, 0, 0, None, None, None, None, 0, None, [], ) # guild, prefix, category, access roles, logging, welcome, goodbye, logging plus, ping roles, blacklist, anonymous, locked roles, raid channel, current count, raidmode status, acc_age, raidmode log, mistakes role, join/leave log, raidrole, isolation time, guild mistakes, counting channel, deleted messages log, edited messages log, suggestion channel, suggestion count, starbaord channel, bad words return resand what's really weird is that even if I comment out every single bit of code minus the very first print statement it still doesn't do anything which makes me think the commands not being registered or something even tho it appears in my help menu

slim ibex
#

Holy shit

silver magnet
#

the doc doesn't explain it well

#

im my eyes, at least

haughty quartz
#
async def rank(ctx, member: discord.Member = hinted)
``` ?
prime ibex
#

Sure, so I have a cmd let’s take:
async def test(ctx, member: discord.Member):
await ctx.send(f”You chose {member.name}”)

So if I run this code these are the possibilities:
!test @prime ibex
!test 278282828282
!test ASF

All of these will return: You chose ASF

slate swan
#

in the third case, the member argument needs to be all Capitals

slate swan
#

asf won't get a member named ASF

prime ibex
honest vessel
#

@flat solsticefirst thing i can spot is u nvr commit the exeute of update

prime ibex
prime ibex
haughty quartz
prime ibex
haughty quartz
#

awesome

prime ibex
prime ibex
silver magnet
flat solstice
vocal snow
slate swan
#

how do i purge above 10 messages?

vocal snow
#

above 10 messages as in more than 10 messages?

slate swan
#

yes

vocal snow
#

purge has a limit argument

#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Examples

Deleting bot’s messages...
honest vessel
#

@flat solsticeis the update not working or is the fetch not working?

prime ibex
silver magnet
#

i already found out lol

#

i forgot to use the limit

prime ibex
#

Nice

haughty quartz
#

@prime ibex how do i get the member's name when having a id

honest vessel
#

sounds like u need an missingargument error handler on that @silver magnet

#

hah

prime ibex
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
honest vessel
#

u need a user/member object

prime ibex
#

It has a name attr

haughty quartz
#

okay

prime ibex
honest vessel
#

theres few names tho, uhave username (name) and serverside nick aka display_name

haughty quartz
prime ibex
#

Cool

honest vessel
#

I just wanna say yall are awesome

#

nice community

haughty quartz
honest vessel
#

yup

flat solstice
prime ibex
vocal snow
flat solstice
sick birch
#

If the first print statement isn’t getting called then somethings wrong yes

flat solstice
vocal snow
#

are there any other commands in the cog, and are they working?

flat solstice
# sick birch Do you have an on_message?

yep, in a separate cog, and it's not sending errors either.
also to clarify when i said

none of the commands working
I ment none of the code in this bad command are working, all of my other commands are working fine

sick birch
#

Can we see the on_message?

#

It’s usually the culprit of commands that aren’t working

#

And is the on message an event or a listener?

flat solstice
vocal snow
#

also if you have jishaku, try printing [c.name for c in _bot.get_cog(...).get_commands()] and see if you can find bad there

flat solstice
# sick birch Can we see the on_message?
@commands.Cog.listener()
    async def on_message(self, message):
        if message.author.bot:
            return
        if message.guild != None:
            data = await self.bot.get_data(message.guild.id)

            server_info = self.bot.get_channel(id = 500413330368888882) # Server Info channel
            text = f"Please don't mention `@everyone` unnecessarily. If you want to ping a large group of members we have roles for activities or games which can be found in {server_info.mention} or you could ping `@here`."
            if bad := [word for word in data[28] or self.bot.config.default_bad_words if word in message.content]:
            #if message.content in data[28] or message.content in self.bot.config.default_bad_words:
                #if message.author.has_any_role(data[3]) or message.author.has_guild_permissions(self.bot.config.moderator_permissions):
                if (len(set(data[3]) & set([role.id for role in message.author.roles])) > 0) or self.bot.config.moderator_permissions in message.author.guild_permissions:
                    return
                else:
                    await message.delete()
                    if "@everyone" in message.content:
                        try:
                            await message.author.send(text)
                        except discord.HTTPException:
                            await message.channel.send(f'{message.author.mention} {text}')
                    try:
                        await message.author.send(f'Your message had `{", ".join(bad)}` in it, This word is conssidered a "bad" word on this server so your message was removed.')
                    except discord.HTTPException:
                        await message.channel.send(f'{message.author.mention} `{bad}` is conssidered a "bad" word on this server.')```this isn't the full event as it's much too long so I'll put it online and send the link however I don't think this event will be causing the issues (hopefully) bc it's never been the culprit of the bot not working https://sourceb.in/ecwK4dMizG
sick birch
#

Ah it’s a listener

#

Not the problem then

silver magnet
#
async def purge(ctx, a=100):
    await ctx.channel.purge(limit=a + 1)```
if someone doesn't specify how many messages to purge, how do i make it give an error?
slim ibex
#

make it required because now it’s optional

#

or

#

if a is None

#

I believe that should work

sick birch
slim ibex
#

^

sick birch
#

You can then catch that error somewhere

flat solstice
silver magnet
sick birch
#

Problem is not with the on message

sick birch
slim ibex
#

by removing =100

sick birch
#

If you have jishaku you can print all the cogs

#

If not just do it on startup or a test command

vocal snow
flat solstice
silver magnet
slim ibex
#

no

sick birch
#

Or behavior to be more specific

flat solstice
sick birch
#

Try removing all the decorators except the barebones @commands.command() without any arguments

prime ibex
#
@client.command()
async def purge(ctx, a:int = None):
    if a is None:
         return await ctx.send(“Please provide an amnt”)

    await ctx.channel.purge(limit=a + 1)
prime ibex
prime ibex
#

^^

#

Lol

slim ibex
#

^^^

silver magnet
#

ohh the return

slim ibex
#

very fancy return await

prime ibex
prime ibex
spring verge
#

Btw is this a bad practice :-

    //Return Something
//Do something else```
#

Like I didn't use else statment

#

Because it's already returning in if

sick birch
#

Nah it’s just preference

#

Some people will use else some won’t

spring verge
#

Hmm

sick birch
#

Personally I prefer to do what you did there

spring verge
#

Same

slim ibex
#

ye

gaunt ice
#

hm

#

hi

slim ibex
#

hello

gaunt ice
#

wuts going on here

slim ibex
#

Discord bot talk

gaunt ice
#

hm

slim ibex
#

?

gaunt ice
#

damm

dense coral
#

lol

gaunt ice
#

u want guild icon for wut lol

slim ibex
#

that legit the fucking thing

gaunt ice
#

hm

#

lol

slim ibex
#

!d discord.Guild.icon

unkempt canyonBOT
#

property icon: Optional[discord.asset.Asset]```
Returns the guild’s icon asset, if available.
gaunt ice
#

is there a way i can find what activity a user is doing

slim ibex
#

as in game activity or status (do not disturb, etc)

gaunt ice
#

like both

#

like the activity

#

yes the game activity

#

like playing watching,and stuff

slim ibex
#

!d discord.Member.activity

unkempt canyonBOT
#

property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
gaunt ice
#

hm

slate swan
#

Is it possible to make your bot screenshare?

gaunt ice
#

not yet

#

soon ig

slate swan
#

What about a discord account?

gaunt ice
#

wut

slate swan
#

like i can have an alt act as a bot and screenshare

gaunt ice
#

!pip selenium

unkempt canyonBOT
gaunt ice
#

i dont think its possible

flat solstice
vocal snow
#

🤔

#

you just need to do 2 things

#

pip install jishaku

#

bot.load_extension('jishaku')

gaunt ice
#

!pip keyboard

unkempt canyonBOT
gaunt ice
#

SHEEHS

#

this exist

#

hm

maiden fable
#

!d keyboard

unkempt canyonBOT
#
#
Bad argument

Unable to convert 'typing' to valid command, tag, or Cog.

flat solstice
# vocal snow you just need to do 2 things

had to set up the cog, didn't I?```py
from discord.ext import commands
from jishaku.cog import STANDARD_FEATURES, OPTIONAL_FEATURES
from jishaku.features.baseclass import Feature

log = logging.getLogger(name)

class CustomDebugCog(*OPTIONAL_FEATURES, *STANDARD_FEATURES):
@Feature.Command(parent="jsk", name="foobar")
async def jsk_foobar(self, ctx: commands.Context):
await ctx.send("{[c.name for c in _bot.get_cog(...).get_commands()]}")

def setup(bot: commands.Bot):
bot.add_cog(CustomDebugCog(bot=bot))```

flat solstice
#

oh

vocal snow
#

xd

#

essentially you just load the extension and then use the jsk py command to evaluate code

flat solstice
vocal snow
#

you can add it anywhere, wont matter

#

you just need jsk to quickly evaluate code from a running bot

prime ibex
gaunt ice
#

guys

prime ibex
#

Just below that add that part and ur good to go

gaunt ice
#

halp

flat solstice
gaunt ice
#

does discord have an event when a user starts an activity

flat solstice
#

yes, but not the server owner of that guild

vocal snow
#

wait which command are you talking about

#

jishaku only requires you to be the bot owner

flat solstice
#

,jishaku [c.name for c in _bot.get_cog(...).get_commands()]

vocal snow
#

try ,jsk py

flat solstice
#

,jsk py [c.name for c in _bot.get_cog(...).get_commands()] and same error

vocal snow
#

are you sure you're the bot owner 👀

maiden fable
#

lmaooo

grim oar
#

😼

flat solstice
#

yep

vocal snow
#

it's raising commands.NotOwner?

prime ibex
flat solstice
#

well I have a owner and owners param in my bot, my ID is in both sections

prime ibex
#

Could u send a snippet of ur bot constructor?

grim oar
#

What error is it raising

flat solstice
#
# The main bot owner
owner = 446290930723717120

# Bot owners that have access to owner commands
owners = [
    446290930723717120,
    381998065327931392, 
    365262543872327681,
]```and ```py
    bot = GoPostal(
    intents=discord.Intents(
        guilds = True, 
        members = True, 
        presences = True, 
        messages = True, 
        reactions = True,
        ),
    member_cache_flags = None,
    chunk_guilds_at_startup = config.fetch_all_members,
    command_prefix = _get_guild_prefix,
    case_insensitive = False,
    help_command = None,
    owner_id = config.owner,
    heartbeat_timeout = 300,
    shard_ids = shard_ids,
    shard_count = shard_count,
    cluster_id = cluster_id,
    cluster_count = cluster_count,
    version = "2.1.1",
),```
prime ibex
#

Ur id is 365262543872327681

flat solstice
prime ibex
#

Whereas the bot is using the id starting from 4

vocal snow
prime ibex
#

I don’t see what’s the issue?

#

owner_ids should be more than enough

flat solstice
#

oh it is

prime ibex
#

Replace the owner_id with owner_ids and set its value to config.owners

flat solstice
vocal snow
#

you prolly removed the help_command = None, by accident

echo wasp
#

Hello my welcome message is still acting up with no errors in the console doesn't work py @commands.Cog.listener() async def on_member_join(self, member: discord.member): if member.guild.id == 902404450432483378 : return channels = member.guild.channels for channel in channels: if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name) await channel.send(f"A new soldier named, {member.mention} , has joined **Bro's SMP War!** Make sure to check out [#806264072454537267](/guild/267624335836053506/channel/806264072454537267/) and [#899440312223662121](/guild/267624335836053506/channel/899440312223662121/) first before doing anything else.") but this does work ```py
@commands.Cog.listener()
async def on_member_remove(self, member: discord.member):
if member.guild.id == 902404450432483378 : return
channels = member.guild.channels
for channel in channels:
if ('leave' in channel.name.lower()) or ('goodbye' in channel.name.lower()) or ('graveyard' in channel.name.lower()):
if isinstance(channel, discord.TextChannel):
await channel.send(f"{member} left the server because they suck :+1:")

#

it was working fine then all of the sudden it doesn't

#

at all

flat solstice
echo wasp
#

now it don't at all

flat solstice
# vocal snow you prolly removed the `help_command = None,` by accident

okay, so i did that command ,jsk py [c.name for c in _bot.get_cog(...).get_commands()] and the bot dmed me this nice traceback py Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/jishaku/features/python.py", line 145, in jsk_python async for send, result in AsyncSender(executor): File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal value = await base.asend(self.send_value) File "/usr/local/lib/python3.8/dist-packages/jishaku/repl/compilation.py", line 140, in traverse async for send, result in AsyncSender(func(*self.args)): File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal value = await base.asend(self.send_value) File "<repl>", line 1, in _repl_coroutine [c.name for c in _bot.get_cog(...).get_commands()] AttributeError: 'NoneType' object has no attribute 'get_commands'

vocal snow
#

oh replace ... with the cog name

prime ibex
echo wasp
prime ibex
#

Because in the next code bloc of member leave, ur also checking whether it’s an valid channel or not, whereas in the member join u aren’t

echo wasp
#

and i didn't mess with anything

#

but i don't even get an error code

#

in console

prime ibex
echo wasp
flat solstice
# vocal snow oh replace ... with the cog name

,jsk py [c.name for c in _bot.get_cog(Moderation).get_commands()] returned py Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/jishaku/features/python.py", line 145, in jsk_python async for send, result in AsyncSender(executor): File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal value = await base.asend(self.send_value) File "/usr/local/lib/python3.8/dist-packages/jishaku/repl/compilation.py", line 140, in traverse async for send, result in AsyncSender(func(*self.args)): File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal value = await base.asend(self.send_value) File "<repl>", line 1, in _repl_coroutine [c.name for c in _bot.get_cog(Moderation).get_commands()] NameError: name 'Moderation' is not definedik the names correct since I copied it from the cog itself and the cog is appearing in my help command `altho that;s provided by a third party lib called slashhelp so maybe it's fetching it in a different way)

vocal snow
#

[c.name for c in _bot.get_cog("Moderation").get_commands()]

flat solstice
#

me so dumb

prime ibex
flat solstice
slate swan
#

Is there some video on disnake? tutorials

echo wasp
vocal snow
#

How were you invoking bad?

flat solstice
prime ibex
vocal snow
prime ibex
echo wasp
vocal snow
# flat solstice yep

Ok, let's try invoking the command with jsk: ```py
await _ctx.invoke(_bot.get_command('bad'), "act2", "b2b")

flat solstice
# vocal snow Ok, let's try invoking the command with jsk: ```py await _ctx.invoke(_bot.get_co...
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/jishaku/features/python.py", line 145, in jsk_python
    async for send, result in AsyncSender(executor):
  File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal
    value = await base.asend(self.send_value)
  File "/usr/local/lib/python3.8/dist-packages/jishaku/repl/compilation.py", line 140, in traverse
    async for send, result in AsyncSender(func(*self.args)):
  File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal
    value = await base.asend(self.send_value)
  File "<repl>", line 1, in _repl_coroutine
    await _ctx.invoke(_bot.get_command('bad'), "act2", "b2b")
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/context.py", line 144, in invoke
    ret = await command.callback(*arguments, **kwargs)
TypeError: bad() takes 2 positional arguments but 4 were given```
vocal snow
#

Oh wait mb

#

I read the function definition wrong

echo wasp
vocal snow
flat solstice
# vocal snow ```py await _ctx.invoke(_bot.get_command('bad'), words="act2 b2b") ```

okay now it's getting tripped up on the db, which I understand it probs can't accesspy Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/jishaku/features/python.py", line 145, in jsk_python async for send, result in AsyncSender(executor): File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal value = await base.asend(self.send_value) File "/usr/local/lib/python3.8/dist-packages/jishaku/repl/compilation.py", line 140, in traverse async for send, result in AsyncSender(func(*self.args)): File "/usr/local/lib/python3.8/dist-packages/jishaku/functools.py", line 109, in _internal value = await base.asend(self.send_value) File "<repl>", line 1, in _repl_coroutine await _ctx.invoke(_bot.get_command('bad'), words="act2 b2b") File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/context.py", line 144, in invoke ret = await command.callback(*arguments, **kwargs) File "/home/modmail/cogs/moderation.py", line 157, in bad await conn.execute("UPDATE data SET badwords=$1 WHERE guild=$2", [word for word in bad_words], ctx.guild.id,) AttributeError: 'NoneType' object has no attribute 'id'

vocal snow
#

Did you run it in a DM?

echo wasp
#

@prime ibex ??

flat solstice
vocal snow
#

Does the bot have read message permissions in that server?

#

It should work just fine in a server

slate swan
#

how can I get a member object using ID?

vocal snow
flat solstice
vocal snow
#

So jsk works as long as you aren't invoking a command?

flat solstice
#

yep

vocal snow
#

Do you still have that print in the command?

flat solstice
leaden jasper
#

How to tell what wait_for was completed?

#

I just have a task complete object

#
  async def test(self, ctx): 

    react = '👋'
    msg = await ctx.send('React or say hi for a response')
    await msg.add_reaction(react)

    done, pending = await asyncio.wait([
      self.bot.wait_for(
        'reaction_add',
        timeout = 25.0,
        check = lambda reaction, user: 
          user == ctx.author 
          and reaction.message == msg
          and str(reaction.emoji) == react
        ),
      self.bot.wait_for(
        'message',
        timeout = 30.0,
        check = lambda message:
          message.author == ctx.author
          and message.content == "hi"
        )
    ], 
    return_when = asyncio.FIRST_COMPLETED
    )
    
    for future in pending:
      future.cancel()

    await ctx.send('Done')
    
    print(done.pop().result())
vocal snow
leaden jasper
#

trying to wait for 2 events

#

it works, but I can't tell which event was triggered

#

@maiden fable any idea?

vocal snow
#

It should send 1

echo wasp
#

how would i make a new welcome message because my last one failed

slate swan
potent spear
echo wasp
flat solstice
# vocal snow Just do `,jsk py 1`

okay well i got it to send hello print but it's not doing ,jsk py await _ctx.invoke(_bot.get_command('bad'), words="act2 b2b")I gtg eat for a bit now so I'll msg when I get back

slate swan
#

oh I'm an idiot I forgot to add intents 🤦‍♂️

potent spear
prime ibex
# echo wasp how would i redo it?

Oh I had gone AFK, hmm so try getting the channel using discord.utils.get(member.guild.channels, name = “channel_name ur looking for”)

echo wasp
potent spear
echo wasp
#

bruh i use both dark and light

#

because i can change my screen brightness by a single button

prime ibex
#

Well that will work only if they are providing a fixed channel ID, based on their use case they are trying to get the channels with specific names in that server

echo wasp
prime ibex
#

channel = discord.utils.(member.guild.channels, name = “welcome or whatever name it is”
if channel:
await channel.send(“…”)

potent spear
#

text_channels and in pls

prime ibex
#

Why do u wanna do all that lol when discord.utils is doing that for u?

prime ibex
#

Nah it isn’t else it wouldn be there

#

Even r Danny rewrite has it in some places

velvet tinsel
#

is dpy the most cloned project ever? pithink

echo wasp
# prime ibex ^^^ making ur code more easy to understand

so like this then? ```py
@commands.Cog.listener()
async def on_member_join(self, member: discord.member):
if member.guild.id == 902404450432483378 : return
role1 = member.guild.get_role(933104091066941530)
role2 = member.guild.get_role(936481481113632839)
role3 = member.guild.get_role(936712347211419708)
role4 = member.guild.get_role(936712664950931476)
role5 = member.guild.get_role(842254098266718219)
role6 = member.guild.get_role(842253873376264222)
role7 = member.guild.get_role(842254463309316136)
role8 = member.guild.get_role(842260259417489448)
role9 = member.guild.get_role(842260429044842572)
role10 = member.guild.get_role(893308041699680337)
role11 = member.guild.get_role(816838497159610369)
role12 = member.guild.get_role(826636738306506794)
role13 = member.guild.get_role(841144860966125568)
role14 = member.guild.get_role(893308556596641792)
roles = [role1, role2, role3, role4, role5, role6, role7, role8, role9, role10, role11, role12, role13, role14]
await member.add_roles(*roles)
channel = discord.utils.member.guild.channels, name = "welcome"
await channel.send(f"A new soldier named, {member.mention} , has joined Bro's SMP War! Make sure to check out #806264072454537267 and #899440312223662121 first before doing anything else.")

slate swan
#

Possible to create a webhook for a channel with discord.py?

echo wasp
potent spear
#

learn how to use utils via the docs too
also, the implementation only looks for a MATCH with welcome, not if welcome is in its name, but I'll just stop helping since you didn't read my previous messages

prime ibex
velvet tinsel
potent spear
#

no

#

multiple guilds

prime ibex
slate swan
potent spear
#

very true

prime ibex
#

It seems he’s really confused as to what he’s trying o properly achieve

echo wasp
#

I want to role members with 14 different roles on join and want to send a welcome message

potent spear
#

no, ofc not

echo wasp
#

nope just one

potent spear
#

the ID will only match in one guild

echo wasp
#

bingo

potent spear
#

right?

echo wasp
#

and self has to be everywhere lol

#

cool i just need it for one anyway

kind path
#

hello i have this code and am trying out slash commands but its not working. im not getting any errors but its not showing the commands. any ideas why?

#

please ping me when you answer my question

potent spear
#

I'm just saying that get_channel is useless if you're using multiple guilds, since it'll only match with one of those
the self.guild is irrelevant

echo wasp
#

not in this bot i have 2 with the same commands just different functions and i know the channel id 880619564935811132

#

ok so it looks like this then and how do i make the roles list smaller in size? ```py
@commands.Cog.listener()
async def on_member_join(self, member: discord.member):
if member.guild.id == 902404450432483378 : return
role1 = member.guild.get_role(933104091066941530)
role2 = member.guild.get_role(936481481113632839)
role3 = member.guild.get_role(936712347211419708)
role4 = member.guild.get_role(936712664950931476)
role5 = member.guild.get_role(842254098266718219)
role6 = member.guild.get_role(842253873376264222)
role7 = member.guild.get_role(842254463309316136)
role8 = member.guild.get_role(842260259417489448)
role9 = member.guild.get_role(842260429044842572)
role10 = member.guild.get_role(893308041699680337)
role11 = member.guild.get_role(816838497159610369)
role12 = member.guild.get_role(826636738306506794)
role13 = member.guild.get_role(841144860966125568)
role14 = member.guild.get_role(893308556596641792)
roles = [role1, role2, role3, role4, role5, role6, role7, role8, role9, role10, role11, role12, role13, role14]
await member.add_roles(*roles)
channel = self.guild.get_channel(880619564935811132)
await channel.send(f"A new soldier named, {member.mention} , has joined Bro's SMP War! Make sure to check out #806264072454537267 and #899440312223662121 first before doing anything else.")

unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

#

property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
kind path
#

what if i want it for all guilds?

#

?

#

"h!"

#

idk

velvet tinsel
#

why did you do name="ping" when you can async def ping(...)?

#

ok

kind path
#

i followed a tutorial

#

still not working

#

ok

#

but you didnt say what would

#

when

tidal hawk
#

Lol terminal freezes after starting the bot

#

idk, it just freezes, even the cursor isnt blinking

kind path
#

it didnt fix

flat solstice
# vocal snow Just do `,jsk py 1`

okay so it's not responding to ,jsk py await _ctx.invoke(_bot.get_command('bad'), words="act2 b2b") in the server but it is in DMs (it then fails bc of the db call's ctx.guilbut the print statement's send the ouputst Input: act2 b2b Bad Words: ['a', 'c', 't', '2', ' ', 'b', '2', 'b']but I don't want each word split into individual chars so I'm assuming my for looppy for word in words: bad_words.append(word) is not the way to do it and i should instead be splitting the string on " " (I have some inputs that include whitespace so I'd need to wrap each input in a char I can split the input on

kind path
#

nothing

#

ok

#

hello anyone. any idea how to add slash commands correctly? im lost right now having never used slash commands before. pls ping when you respond

#

no errors

flat solstice
echo wasp
#

so i want to make a role giver by command how would you make it so they can pick one out of a number of 13? using the role name

kind path
flat solstice
kind path
echo wasp
#

define ban ip discord bans the ip

#

when you ban a user

flat solstice
# kind path it has administrator perm in my server

did you give it both of these scopes when you first made it's invite link? if not remake the invite link and invite it again (you won't need to kick it before inviting it bc reinviting it will just update it's permissions)

kind path
flat solstice
kind path
#

cool, didnt know that until now

silver magnet
#

making an eightball command, how do i make it give an error when there's no context? i tried this:

#
async def eightball(message):
    responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.",
        "Don’t count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.",
        "Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.",
        "Yes.", "Yes – definitely.", "You may rely on it."]
    if message is None:
        await message.channel.send(f"say something")
    else:
        await message.channel.send(f":8ball: {random.choice(responses)}")```
echo wasp
#

hello again, i want to make a role giver command for example &giverole examplerole and the same command could give multiple roles per their selection do you know where i can start?

flat solstice
silver magnet
#

nope

#

no errors

final iron
#

Since it's the first argument

silver magnet
#

i replaced message with ctx

final iron
#

Ctx will never be none in a prefix command

#

So I don't know what you're trying to do

flat solstice
# silver magnet ```@client.command() async def eightball(message): responses = ["As I see it...

not that i'm trying t spoon-feed (can't remember if there's a rule for that here) but i think your looking for something likepy @client.command() async def eightball(ctx, message: str = None): responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don’t count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.", "Yes.", "Yes – definitely.", "You may rely on it."] if message is None: await ctx.send(f"SAY SOMETHING!") else: await ctx.send(f":8ball: {random.choice(responses)}")

final iron
#

message will also never be None

#

So having that if statement is useless

#

Let's rewind, what are you trying to do

silver magnet
#

8ball command

cold sonnet
#

just tell him to set a default value to message

final iron
cold sonnet
final iron
#

You don't have to go through any if statements. Just send your message

cold sonnet
#

bruh

final iron
#

There is 0 reason to take a message argument

cold sonnet
#

do you know what an 8ball command is

final iron
#

I think you're the one not understanding

cold sonnet
#

you ask a question

#

and it answers, doesn't matter what the question is

prime ibex
#

I think what they are trying to do is the user provides a input, message then the bot shows a response for their message also that’s how, 8th ball works

final iron
#

But they're not using the variable?

cold sonnet
final iron
#

No?

#

What

prime ibex
cold sonnet
final iron
prime ibex
#

Mhm

final iron
#

They're not using the variable

cold sonnet
#

in your command definition

quaint epoch
#

how do you change a roles place in the role heirarchy?

cold sonnet
flat solstice
cold sonnet
#

because if you don't do that, without the message, you'll get an error

final iron
#

How would the user know their question was inputted if it was never repeated back?

cold sonnet
final iron
#

I am helping them. You're one the who started this

cold sonnet
#

sure

final iron
#

If you don't like it, don't continue

cold sonnet
#

now I'm gonna end it

final iron
#

Simple

cold sonnet
flat solstice
#

and now i'm backing off PEEK6

final iron
cold sonnet
#

cuz it would work even if he doesn't put a question

flat solstice
#

Thisyeah was about to say that

cold sonnet
#

wdym how so

#

and even if he puts a question, the bot gets a too many arguments error

#

it would only work without a question

#

!e

def hello(first, second):
    print(first, second)

hello("hello", "world", "!")
unkempt canyonBOT
#

@cold sonnet :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | TypeError: hello() takes 2 positional arguments but 3 were given
flat solstice
#

well not that's it's my command but I seem to be investing in it's success now. here's the latestpy @client.command() async def eightball(ctx, *, message: str): # message is required to be inputted, if no message is given then the command fails with a invalid arg error (I think) responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don’t count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.", "Yes.", "Yes – definitely.", "You may rely on it."] await ctx.reply(f":8ball: {random.choice(responses)}")I used reply so that the user knows that the bot is responding to their invocation not someone else's (since someone mentioned something along those lines)

cold sonnet
#

cpython?

#

oh

slate swan
#

not really

#

ive been told that its not and its very different

#

wut

cold sonnet
#

well

#

I just did compare them bruhkitty

final iron
#

I just tested it

#

There is no such error thrown

slate swan
#

you will

cold sonnet
#

idek

slate swan
#

you will?

final iron
kindred epoch
#

how do i ignore the missing permissions for sending a message error?

slate swan
#

how would it not raise and error

final iron
slate swan
#

it takes 1 argument not 2

#

i dont see why it wouldnt raise

final iron
#

Alright so I was right. There is no reason to add a message variable in the 8ball command

#

Literally just an unused variable

cold sonnet
#

tho it makes more sense

final iron
#

It doesn't make any sense

kindred epoch
cold sonnet
#

it does for visualisation

final iron
final iron
cold sonnet
#

because he wants the bot to only answer when getting a question

slate swan
#

im not are you ok?

cold sonnet
#

so it's not even unused

final iron
#

Simple

velvet tinsel
#

kaya going mad 😳

cold sonnet
#

so you just called another attribute to get a variable, same memory usage

slate swan
#

its how python works?

flat solstice
slate swan
#

if you give more arguments to a function it will raise an error how wouldnt i be confused thats just unpythonic?

velvet tinsel
#

I'm gonna watch this argument

#

it's gonna be interesting

final iron
slate swan
#

i couldnt care less about dpy

#

im not?

#

your arguing by yourself

final iron
#

Mods are gonna come again

velvet tinsel
#

well, not my gif

final iron
velvet tinsel
#

but I used it

velvet tinsel
#

how to make discord bot

#

I asked a question

#

there we're now on topic now

manic wing
#

relax yourself

#

who is this irrelevant person

slate swan
#

i couldnt careless

#

i dont work with dpy anymore why keep arguing?

velvet tinsel
manic wing
#

whos kaya

final iron
velvet tinsel
final iron
#

Get some popcorn and watch

velvet tinsel
slate swan
#

its basic python

velvet tinsel
fluid yarrow
#

guys

cold sonnet
velvet tinsel
#

I got fizzy drinks

manic wing
#

LOL

slate swan
#

lol

velvet tinsel
#

soda and popcorn

#

lovely show

fluid yarrow
#

could I have python bot on my own server?

slate swan
#

useless ping i see no reason why

visual yarrow
#

Hello, what's the issue?

velvet tinsel
fluid yarrow
final iron
velvet tinsel
fluid yarrow
#

to code in my own

slate swan
final iron
velvet tinsel
fluid yarrow
final iron
#

!src

velvet tinsel
#

arguments are my favorite thing to watch

final iron
#

huh

fluid yarrow
#

that link?

velvet tinsel
#

I just fucking died

final iron
velvet tinsel
#

.ping

#

I just

I just fucking

flat solstice
#

it got upset about your argument

velvet tinsel
visual yarrow
#

Let's keep this channel on the topic of Discord bots please 🙂 This isn't off-topic.

velvet tinsel
#

too much bans for one day 🥱

final iron
slate swan
#

lol

final iron
#

Python is back up

#

!src

velvet tinsel
#

!help

final iron
#

...

velvet tinsel
#

@final iron you lied to me

final iron
#

It was online ok?

velvet tinsel
#

😠

final iron
#

They must have fucked with src code and broke something

velvet tinsel
#

@unkempt canyon

deep trellis
#

hey

velvet tinsel
#

hi

flat solstice
#

have I got this compact if statement correct?py guild = 448405740797952010 if ctx.guild.id is None else ctx.guild.idI'm like 95% sure it is

slate swan
thick sigil
#

it will always be the id first

velvet tinsel
thick sigil
#

number*

velvet tinsel
#

by upvoting his post

#

he'll no longer have 69 upvotes

slate swan
slate swan
#

how do i write multiple lines for a command

visual yarrow
flat solstice
slate swan
#

how do i write multiple lines

#

for me i cant seem to write more than one line for a command

flat solstice
#

yay, I don't do many compact if statements and when I do they tend to be rather complex for my little brain to figure out but i am getting better at them

slate swan
velvet tinsel
slate swan
#

thats probably the description kwarg with bold titles

slate swan
sick birch
velvet tinsel
slate swan
velvet tinsel
slate swan
sick birch
#

Yikes

velvet tinsel
#

the bot committed death

slate swan
#

Thank you

visual yarrow
fluid yarrow
#

and i can code and show my code to others

velvet tinsel
#

it's only for python discord server

fluid yarrow
#

huh 😦

slate swan
final iron
visual yarrow
#

Oh @fluid yarrow, are you looking for a bot you can use to run code from a message and see the output?

fluid yarrow
#

is there a command that i can code in my own server?

slate swan
fluid yarrow
#

the link in github

slate swan
#

This is result I get. What do I do if I wanted to have multiple lines for description?

fluid yarrow
#

this?

final iron
#

Yeah

#

If you wanted specific commands you could just copy the code/file

#

One thing though. If you're looking for an eval command then it would be a bit complicated as you would have to setup your own snekbox server

visual yarrow
#

The !eval command uses another service called SnekBox.

fluid yarrow
#

i dont need eval

#

just a thing to underline a cod

#

classic !code

#

then ''' ecc

#

not necessarly to use the output

fluid yarrow
visual yarrow
#

So, when a user uses this command, what do you expect to happen?

#

We have a !code command in this server, which just instructs people on how to use code-blocks in their messages.

#

These things:
```py
hello world
```

#

Is that what you were thinking of?

fluid yarrow
#

YEAH

sick birch
#

Wouldn't you just send a message containing that then?

fluid yarrow
#

I want the cool thing of underline ecc

#

just like jetbrains 😦

sick birch
#

underline ecc?

fluid yarrow
#

for example

#

print is written in blue instead of white

sick birch
#

Well you can create codeblocks with python syntax highlighting like so:
```py
stuff
```

#

Is that what you mean?

fluid yarrow
#

yeah

#

this

#

highlighting

#

my bad not underline

sick birch
#

You can just send that in a message

#

nothing fancy required

final iron
sick birch
#
for i in range(5):
  # stuff
#

It does highlight, functions are red, keywords are green, comments gray etc

flat solstice
#

Hi so I have these lists as part of a command for my discord bot.py db_list = ["glitch", "toffee"] words = ["act2", "b2b", "act 2", "glitch"] bad_words = [] bad_words.append(db_list) for word in words: bad_words.append(word)I have db_list hard coded for this example but it would normally be fetching these from the database. and i also hard coded words but normally these would be a string of words provided in the command async def bad(self, ctx, *, words: str): What i want to happen is for my bot to make a new list (bad_words) and append everything from db_list into bad_words. I then want it to append each word from the words string onto the bad-words list. Currently it is splitting each word in words into individual chars but I don't want that so I'm guess I need to split the string on a character and I want to use , as some of the inputs of words might contain blank spaces.

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

['glitch', 'toffee', 'act2', 'b2b', 'act 2', 'glitch']
cloud dawn
#

This?

#

We won't help with that here, sorry.

slate swan
#

why?

cloud dawn
slate swan
#

bruh

#

ok

split coral
#

So I have this Discord bot idea and I want to have it use Roblox API but I don't know the best library for Roblox API. Anyone have ideas?

flat solstice
# cloud dawn This?

yeah! that solves one question thanks. next question is about splitting the words string input into individual words rather than one long long string as py for word in words: bad_words.append(word)doesn't work for my use case, would it be words.split(",")? and I'd need to save that to a list variable as well so how would i do that? also how can i remove duplicates the lists?

flat solstice
split coral
#

But i dont know which one is better

velvet tinsel
#

I think I'm in their server somewhere

#

oh wait nvm I'm not

split coral
#

Robloxpy has a site that tells all the functions and stuff you can do

#

Also, How would I send an Image from the bot to discord?

cloud dawn
flat solstice
flat solstice
cloud dawn
split coral
#

Thanks!

cloud dawn
#

Oh you want to convert everything into a string?

flat solstice
# cloud dawn I have no clue on what you want to do here.

taking it from the toppy db_list = ["glitch", "toffee"] words = ["act2", "b2b", "act 2", "glitch"] bad_words = [] bad_words.append(db_list) for word in words: bad_words.append(word)

  1. I have db_list hard coded for this example but it would normally be fetching these from the database.
  2. hard coded words but normally these would be a string of words provided in the command async def bad(self, ctx, *, words: str):

~~3) What i want to happen is for my bot to make a new list (bad_words) and append everything from db_list into bad_words. ~~ Done via bad_words(some_list + db_list

  1. I then want it to append each word from the words string onto the bad-words list.

Currently it is splitting each word in words into individual chars but I don't want tha.t

  1. I guess I need to split the string on a character and I want to use , as some of the inputs of words might contain blank spaces.

I'm thinking some_list = words.split(", ") would work?

cloud dawn
#

..?

#

you can't split a list

#

!help

final iron
#

Bot is dead

cloud dawn
#

oof

#

@flat solstice anyways i still have no clue on what we are splitting now

#

Oh you mean you want to make a cmd that takes in those words?

flat solstice
# cloud dawn you can't split a list

ik, I don't want to split a list (I don't think 🤔). I made words = ["act2", "b2b", "act 2", "glitch"] a list in my example but the command accepts it as a stringpy async def bad(self, ctx, *, words: str): and so I need to split that string,

cloud dawn
#

ah

#

:3

flat solstice
#

okay glad i was able to explain my brains weird half formed idea

flat solstice
# cloud dawn ah

so does what I'm trying to do make sense? and if so would some_list = words.split(", ") be the way to do it as I do need a list of the words after it splits them out of the string

cloud dawn
#

!e ```py
s = "act2,b2b, act2,glitch,glitch, b2b"

db_list = ["glitch", "toffee", "act2"]
words = s.replace(" ", "").split(",")

print(set(db_list + words))

#

worth the try

#

Depends if you want to fully disregard spacing yes or no

manic wing
restive crater
#

!d defaultdict

cloud dawn
#

Your effort has been nice

flat solstice
cloud dawn
cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

{'act 2', 'toffee', 'b2b', 'act2', 'glitch'}
cloud dawn
#

🥳

velvet tinsel
#

hooray

#

bot is back up :D

cloud dawn
#

!d zip

unkempt canyonBOT
#
zip

zip(*iterables, strict=False)```
Iterate over several iterables in parallel, producing tuples with an item from each one.

Example:

```py
>>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
...     print(item)
...
(1, 'sugar')
(2, 'spice')
(3, 'everything nice')
```...
restive crater
velvet tinsel
#

!ping

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

flat solstice
velvet tinsel
#

hooray bot is fully functioning

cloud dawn
#

You know the answer, it's still 5, pretty sure it doesn't crash.

cloud dawn
vale wing
#

Removes leading space and the space at the end

#

!d str.strip

unkempt canyonBOT
#

str.strip([chars])```
Return a copy of the string with the leading and trailing characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or `None`, the *chars* argument defaults to removing whitespace. The *chars* argument is not a prefix or suffix; rather, all combinations of its values are stripped:

```py
>>> '   spacious   '.strip()
'spacious'
>>> 'www.example.com'.strip('cmowz.')
'example'
```  The outermost leading and trailing *chars* argument values are stripped from the string. Characters are removed from the leading end until reaching a string character that is not contained in the set of characters in *chars*. A similar action takes place on the trailing end. For example:
cloud dawn
#

Ah yeah i remember

#

ig you could

manic wing
manic wing
cloud dawn
#

report

manic wing
#

gets banned

cloud dawn
final iron
#

Okay but do you have lasagna in your oven?

#

Anyway, I'm adding a welcome card feature to my bot. What's the best way to protect my bot from freezing since pillow isn't async

pliant gulch
#

Just run it in executor

final iron
#

Oh yeah

pliant gulch
#

I'm sure most people do that for pillow

final iron
#

I forgor

slate swan
vale wing
#

The executor is the concurrent.futures.Executor or something else?

final iron
#

!d asyncio.loop.run_in_executor

unkempt canyonBOT
#

awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.

The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor") instance. The default executor is used if *executor* is `None`.

Example:
slate swan
final iron
#

Which option would I use?

#

There are 3

vale wing
final iron
final iron
final iron
manic wing
cloud dawn
#

well you could also just create a task no need for an executor.

slate swan
#

hmm wait

final iron
vale wing
#

Asyncio task ig

cloud dawn
#

!d asyncio.get_running_loop

unkempt canyonBOT
#

asyncio.get_running_loop()```
Return the running event loop in the current OS thread.

If there is no running event loop a [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised. This function can only be called from a coroutine or a callback.

New in version 3.7.
vale wing
#

!e

import asyncio

async def stuff():
    print(10 ** 5)

async def main():
    task = asyncio.create_task(stuff())

    await task

asyncio.get_event_loop().run_until_complete(main())```
flat solstice
#

okay so moving on from my string stripping. I have this function call which is getting data from my dbpy data = await self.bot.get_data(448405740797952010 if ctx.guild.id is None else ctx.guild.id) and it keeps throwing this error when used in DMspy ddata = await self.bot.get_data(448405740797952010 if ctx.guild.id is None else ctx.guild.id) AttributeError: 'NoneType' object has no attribute 'id'so I triedpy data = await self.bot.get_data(ctx.guild.id or 448405740797952010)and got the same error so i removed ctx.guild.id just to see if something else is broken and got this errorpy bad_words = (set(data[28] + words)) TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'

unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

001 | <string>:11: DeprecationWarning: There is no current event loop
002 | 100000
final iron
#

!d asyncio.loop.create_task

unkempt canyonBOT
#

loop.create_task(coro, *, name=None)```
Schedule the execution of a [Coroutines](https://docs.python.org/3/library/asyncio-task.html#coroutine). Return a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") object.

Third-party event loops can use their own subclass of [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") for interoperability. In this case, the result type is a subclass of [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task").

If the *name* argument is provided and not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").

Changed in version 3.8: Added the `name` parameter.
final iron
#

This?

cloud dawn
#

Yeah

flat solstice
vale wing
#

I mean you have the condition put wrong

#

You can't access any attributes of the None as it doesn't have any

#
#instead of this
if ctx.guild.id is None
#do this
if ctx.guild is None```
flat solstice
#

ohhh

#

that makes more sense

pliant gulch
#
import rin

class CommandDemo(...):
    # Some implementation here
    ...

rin.export(type=rin.AppCommand.MESSAGE, entry=CommandDemo)
``` thoughts?
#

This would be in a separate file, which the main file then hooks onto

manic wing
pliant gulch
#

Reasons for it

manic wing
#

absolutely not

#

andy being different for the sake of being different

#

@pliant gulch give me advantages of this opposed to cogs/normal implementation

spark wigeon
#

this is supposed to delete non-english messages, but im getting an error

def isEnglish(s):
    try:
        s.encode(encoding='utf-8').decode('ascii')
    except UnicodeDecodeError:
        return False
    else:
        return True
        
@client.event
async def on_message(ctx, message):
    if isEnglish(message.content):
        pass
    else:
        await message.delete(message)

        delete_em = discord.Embed(title=f"Message Deleted.", colour=0x2c1945)
        delete_em.add_field(name="Reason:", value=f"Not-English Message", inline=False)
        delete_em.set_footer(text="https://github.com/zoaq1")

        await ctx.message.channel.send(f"{ctx.message.author.mention}", embed=delete_em)
pliant gulch
slate swan
#

!d discord.on_message

unkempt canyonBOT
#

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

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

Warning

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

this too

TypeError: Message.delete() takes 1 positional argument but 2 were given
spark wigeon
slate swan
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
unkempt canyonBOT
#

examples/example_custom_event.py line 31

@client.on(CUSTOM_MESSAGE_CREATE)```
pallid mango
manic wing
#

whats message.custom

#

oh shit

#

im blind

#

ignore thy

#

it forces the message into the typehint?

pliant gulch
spark wigeon
slate swan
#

yw

pliant gulch
#

Errr used to be a literal enum, now it's a class instance with a cache

#

Allowing client-less events

#

Somewhat*

#

You can wait-for without client, register without client, etc but a gateway connection is still needed

manic wing
#

andy whos your audience for this

#

it seems like a lot to learn how to use rin

pliant gulch
#

Intellectuals who enjoy strongly typed code

pallid mango
#

hmm

manic wing
#

this dude

pliant gulch
#

We got collectors, one time event dispatches, collectors with timeouts

#

Cool stuff

manic wing
#

the one time event dispatches is nice

pliant gulch
#

We use semaphores

manic wing
#

whelp

#

sleep makes the mind strong

#

off i pop

pliant gulch
#

I know right brandy

spark wigeon
#

how would i catch the exception for missing permissions of bot role? what i have now isnt working.

except discord.errors.Forbidden:
spark wigeon
cloud dawn
#

Yeah i recommend a on_command_error

spark wigeon
modest plover
#

I don't know where I went wrong:

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

load_dotenv()
token = os.environ["bot_token"]

bot = commands.Bot()

@bot.event
async def on_ready():
  print(f"Logged in as {disnake.user}.")
  
  
bot.login(token)
token.env
bot_token=token

I get this:

~/artemis-mk2 $ python3 main.py
Traceback (most recent call last):
  File "/storage/emulated/0/coding/python/artemis-mk2/main.py", line 7, in <module>
    token = os.environ["bot_token"]
  File "/data/data/com.termux/files/usr/lib/python3.10/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'bot_token'
~/artemis-mk2 $
#

It worked before I accidentally deleted my code

#

So idk why it isn't working now

pallid mango
#
import disnake
from disnake.ext import commands
import os
from dotenv import load_dotenv

bot = commands.Bot()

@bot.event
async def on_ready():
  print(f"Logged in as {disnake.user}.")
  
  
client.run("token")```
#

this should work

spark wigeon
#

how can i send a message when my bot joins a server?

pallid mango
#

when your bot JOINS a server?

spark wigeon
pallid mango
#

no clue

spark wigeon
#

it joins then says hi

pallid mango
#

best bet would be to make it send something on ping

spark wigeon
#

good idea

pallid mango
#

i sent fixed code above

visual island
unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

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

It hasn't loaded the dotenv file

#

Meaning it doesn't have the token variable

modest plover
#

Am I not able to have it called token.env?

rustic onyx
#

can I have 2 on_message listeners in the same cog?

rustic onyx
sick birch
rustic onyx
#
    @commands.Cog.listener()
    async def on_message(self, message):
``` two of these
sick birch
#

Yeah should work like you'd expect

rustic onyx
#

👍

#

thanks

sick birch
#

No prob

obtuse hearth
#

how can I have a gui control my discord bot? I just need an area to get directed in

sick birch
#

Could be difficult since I'm not aware of any GUIs that are async

obtuse hearth
#

currently im using tkinter, dont know how im going to use multi threading to do that

sick birch
#

You might able able to have some sort of websocket connection from discord bot to your tkinter

#

ah multi threading

#

you would need to get inter-thread communication (if that's the right term)

obtuse hearth
#

ok thanks, ill try to work on that

pallid mango
#

and if you’re trying to use a secret thru replit just create the secret name the top part whatever u want, then the second part put the token

#

client.run(os.getenv(""))

sick birch
#

Well obligatory but you should consider not using replit

#

but if you must it's probably easier to just put it in as a string

pliant gulch
#

But repl.it has public codespaces, so if you put your token as a raw string instead of getting it through getenv you will be leaking your own token

pallid mango
#

except you can change it to private very easily

#

and i use replit because i can’t run my pc 24/7

slate swan
#

Okay, so I have a selfbot for fun because why not (started a new one)

Everytime I try to make a embed and send it, it returns a 400 saying it cannot send a empty messages
Did discord patch selfbot or something?

Aware of TOS by the way, i'm not using it maliciously

dry kelp
#

how can i check if my json database has already 1 thing "inside" the guild id?

#
        if len(add_channel[str(ctx.guild.id)]) == 1:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"{channel} Is currently set for the antinuke logs!\nType: `{p}Antichannel Remove` To remove the channel!", color=discord.Color.red())
            await ctx.send(embed=em)
            return
#

that's just checking wrong

#

i can remove the channel because the command is going to ignore that even tho it returns

#

it's fucking my brain literally

#

wait

#

is not going to remove even tho it says successful

#

what the fuck

slate swan
#

i think its > 2 or sum idk i havent coded in a year 💀

dry kelp
#

i tried laughskull

slate swan
#

oh

sick birch
#

so we can't really help you fix your selfbot

dry kelp
#

@sick birch

#

How can i get a channel that's inside the json database?

pliant gulch
dry kelp
#

without using it as parameter

sick birch
dry kelp
#

yep

sick birch
#

Then you can just do either get_channel() or fetch_channel()

dry kelp
#

how do i use it tho

#

with open..

#

lemme see

sick birch
#

Why not just store the ID w/o the <#>?

dry kelp
#

i tried using

#

but because channel is a required parameter

#

and is already a str

#

idk how to add the id only

sick birch
#

you can store strings

dry kelp
#

yeah but look

sick birch
#

how are you defining channel?

dry kelp
#

async def add(self, ctx, channel):

sick birch
#

and that's a command?

dry kelp
#

yep lemme send u the entire code

#

what should i use