#discord-bots

1 messages · Page 504 of 1

fast hedge
#

I am incredibly new to this and am digesting as much info as I can while building this. If anyone is free you mind hopping in code/help 0 with me and catch my fuck ups?

slate swan
#

you know the cooldown error you get when a command is on cooldown??? i want to have limit to how many times that error can go off because i dont want people to be able to spam a command and get my bot rate limited i.e. i spam .command 20 times and it says command is on cooldown 20 times i need it to only say it twice

cloud dawn
fast hedge
hasty iron
#

!d asyncio.Lock

unkempt canyonBOT
#

class asyncio.Lock```
Implements a mutex lock for asyncio tasks. Not thread-safe.

An asyncio lock can be used to guarantee exclusive access to a shared resource.

The preferred way to use a Lock is an [`async with`](https://docs.python.org/3.10/reference/compound_stmts.html#async-with) statement:

```py
lock = asyncio.Lock()

# ... later
async with lock:
    # access shared state
```...
cloud dawn
slate swan
hasty iron
pliant gulch
#

!customcooldown

unkempt canyonBOT
#

Cooldowns in discord.py

Cooldowns can be used in discord.py to rate-limit. In this example, we're using it in an on_message.

from discord.ext import commands

message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)

@bot.event
async def on_message(message):
    bucket = message_cooldown.get_bucket(message)
    retry_after = bucket.update_rate_limit()
    if retry_after:
        await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
    else:
        await message.channel.send("Not ratelimited!")

from_cooldown takes the amount of update_rate_limit()s needed to trigger the cooldown, the time in which the cooldown is triggered, and a BucketType.

hasty iron
#

my idea maybe really dumb

#

well idk

#

i just gave whatever came in my mind first

pliant gulch
#

I think the custom cooldown is optimum then

#

As you get ctx.message in on_command_error

#

asyncio.lock could work as well

#

actually I think it might be cleaner to use asyncio.lock

#

¯_(ツ)_/¯

slate swan
#

so how would i use it to only send like 2 on cooldown messages then it wont react or send another message untill the cooldown is over

jade jolt
#

add the times its been said until it reaches 2

hasty iron
#

you can use that custom cooldown or use asyncio.Lock

jade jolt
#

when its at 2 just do nothing until it ends

hasty iron
#

oh wait

#

oh right

#

since you get retry_after

#

wait

slate swan
#

retry after is just time untill you can do it again

hasty iron
#

commands are run inside on_message which is run inside a task, if you use asyncio.sleep it would basically do nothing?

#

i mean null’s idea is really vague imo

jade jolt
#

yes it is

#

hm wait

slate swan
jade jolt
#

uhhh

hasty iron
#

an asyncio.Lock

#

read what it does

#

it limits access to a resource

#

in your case, as i said before, you could have it sleep before releasing the lock

slate swan
#

how would i implement this?

hasty iron
#

by using a subclass and a dict

jade jolt
#

just wondering

hasty iron
#

you wouldn’t want this to apply to everyone at the same time

jade jolt
#

is my regex for catching pings bad?
(@!*&*[0-9a-zA-Z]+)

hasty iron
#

i know nothing about regex tbh

jade jolt
#

oh

#

:)

slate swan
pliant gulch
#

<(?:@(?:!|&)?|#)([0-9]{15,20})>$ is the one discord.py uses

jade jolt
#

for pings like @\here

pliant gulch
#

Not for pings like here and everyone

#

I'm pretty sure they have another one for that not sure

jade jolt
#

mine does all

#

untill you try to do @12 and it gets blocked

fallow mauve
#

do i have to import smth first?

#

hello?

slate swan
fallow mauve
#

import what?

slate swan
#

random

fallow mauve
#

thx

slate swan
#

]

fallow mauve
#

this is the error i got

jade jolt
#

lol

#

random.randint(1,6)

fallow mauve
#

?

hasty iron
#

!d random.randint

unkempt canyonBOT
#

random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
slate swan
fallow mauve
#

oh

#

had no idea

#

im lost now

jade jolt
#

show code

fallow mauve
jade jolt
#

xd

fallow mauve
#

did i do smth stupid?

jade jolt
#

use commands and not on_message

fallow mauve
#

if i did smth dumb again just tell me

fallow mauve
jade jolt
#

what is that

fallow mauve
#

?

jade jolt
#

@hasty iron you can help

sinful marsh
#
RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'Client._run_event' was never awaited``` Why would discord-ext-ipc be throwing this
jade jolt
#

await it?

stark hearth
fallow mauve
stark hearth
fallow mauve
#

i need to classify it?

#

what do you mean classify?

hasty iron
stark hearth
#

just do ctx.send

#

or classify the channel

hasty iron
fallow mauve
stark hearth
#

no you gotta change the code a bit

sinful marsh
# jade jolt await it?
import discord
from discord.ext import commands, ipc


class MyBot(commands.Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.ipc = ipc.Server(self, secret_key="my_secret_key")  # create our IPC Server

    async def on_ready(self):
        """Called upon the READY event"""
        print("Bot is ready.")

    async def on_ipc_ready(self):
        """Called upon the IPC Server being ready"""
        print("Ipc is ready.")

    async def on_ipc_error(self, endpoint, error):
        """Called upon an error being raised within an IPC route"""
        print(endpoint, "raised", error)


my_bot = MyBot(command_prefix="!", intents=discord.Intents.all())


@my_bot.ipc.route()
async def get_member_count(data):
    guild = my_bot.get_guild(
        data.guild_id
    )  # get the guild object using parsed guild_id

    return guild.member_count  # return the member count to the client


if __name__ == "__main__":
    my_bot.ipc.start()  # start the IPC Server
    my_bot.run("")``` This is the code, I dont thing mybot.ipc.start needs to be awaited
#
  File "/Users/matthewjames/Desktop/LooicDevelopmentServices/Python Testing/bot.py", line 37, in <module>
    my_bot.ipc.start()
  File "/Users/matthewjames/Desktop/LooicDevelopmentServices/Python Testing/venv/lib/python3.9/site-packages/discord/ext/ipc/server.py", line 253, in start
    self.bot.dispatch("ipc_ready")
  File "/Users/matthewjames/Desktop/LooicDevelopmentServices/Python Testing/venv/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 154, in dispatch
    super().dispatch(event_name, *args, **kwargs)  # type: ignore
  File "/Users/matthewjames/Desktop/LooicDevelopmentServices/Python Testing/venv/lib/python3.9/site-packages/discord/client.py", line 403, in dispatch
    self._schedule_event(coro, method, *args, **kwargs)
  File "/Users/matthewjames/Desktop/LooicDevelopmentServices/Python Testing/venv/lib/python3.9/site-packages/discord/client.py", line 363, in _schedule_event
    return asyncio.create_task(wrapped, name=f'discord.py: {event_name}')
  File "/opt/homebrew/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 360, in create_task
    loop = events.get_running_loop()
RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'Client._run_event' was never awaited```
fallow mauve
sinful marsh
#

Yeah sry just realizes that

stark hearth
sinful marsh
#

@hasty iron

hasty iron
#

yes i saw

#

well its an issue related to how discord.ext.ipc tries to dispatch before the bot is running is what i am@getting

slate swan
#
@client.command()
@commands.check_any(commands.is_owner(), commands.has_permissions(manage_channels=True))

async def help(ctx):
    embed=discord.Embed(title="Embed Bot", color=discord.Colour.random())
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"help`", value="Shows all commands' info", inline=False)
    img = ctx.message.author.avatar_url
    embed.set_thumbnail(url=img)
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"embed <message>`", value="Sends embeded message\n *(Requires 'Manage Channel' Permissions)*", inline=False)
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"about`", value="Shows info about the bot", inline=False)
    embed.timestamp =datetime.datetime.utcnow()
    embed.set_footer(text="Requested by {}".format(ctx.author))
    await ctx.reply(embed=embed)    ```

Error:

async def help(ctx):
^
Invalid Syntax```

visual island
#

you forgot the @

slate swan
#

Where?

visual island
#

@commands.has_permissions(manage_channels=True)

slate swan
#

But isn't in braces

visual island
#

and you have an extra closing parentheses right there

amber night
slate swan
#

Lemme check

#

I dont understand what you wanna say,

This is working in my other command

visual island
#

oh, you are using commands.check

slate swan
#

Yea

#

Its only happening in help command

#

My other command are working good

visual island
#

do you have anything wrong above it?

slate swan
#

Nah

#

Other code is working

#

I even remove the command.check but still giving error

stark hearth
mighty anchor
#

Yes

#

Add @ before commands.has_anypermissions

normal bolt
#

How do I send DM to a member through his ID ??

slate swan
#

Yea

mighty anchor
#

I can tell you how to dm a author

#

Of the command

kindred epoch
unkempt canyonBOT
kindred epoch
#

use that

normal bolt
#

thanks 🙂

kindred epoch
#

and if that fails then use fetch_user but that makes an api call so use it with precautions

slate swan
#
sync def help(ctx):
    embed=discord.Embed(title="Embed Bot", color=discord.Colour.random())
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"help`", value="Shows all commands' info", inline=False)
    img = ctx.message.author.avatar_url
    embed.set_thumbnail(url=img)
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"embed <message>`", value="Sends embeded message\n *(Requires 'Manage Channel' Permissions)*", inline=False)
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"about`", value="Shows info about the bot", inline=False)
    embed.timestamp =datetime.datetime.utcnow()
    embed.set_footer(text="Requested by {}".format(ctx.author))
    await ctx.reply(embed=embed)    ```

Still error
slate swan
#

I removed the @commands.check any

#

But still error

kindred epoch
#

send the code and error

mighty anchor
#

What is error

stark hearth
#

then check if there are errors

stark hearth
mighty anchor
#

!code

stark hearth
#

!code

mighty anchor
#

!code

#

Lol

visual island
#

!code

stark hearth
#

oop lmao

visual island
slate swan
kindred epoch
slate swan
#

Yea but it was working good yesterday

#

But when my bot got rate limited, I edited the code and this happened

stark hearth
slate swan
#

Its embed colour

#

Random colour

#

To choose a random colour of the line

<- That coloured line in embed

stark hearth
#

do discord.Colour.random() @slate swan

slate swan
#

Which line

#

I remember I did ()

stark hearth
#

wait you did nm

slate swan
#

Yea

stark hearth
#

so every command works except the help command correct?

slate swan
#

Yes

tribal sundial
#

hi guys
i've set up a bot that on command goes to a specific voice channel (specified by channel id) and plays an audio file
how would i make it go to a different voice channel if
the command was used in a specific text channel (defined by id)?

stark hearth
slate swan
#

Well I just checked in replit, that none of the command is working

#

I think its because of the commands.checkany

stark hearth
slate swan
#

Yea

#

I mean

#

except about command

stark hearth
#

bruh i thought it was only the help command lmao

slate swan
#

Teheee

#

What can I do as an alt for commands.checkany

sleek ore
#

Try changing line 18 to this

await client.change_presence(activity = discord.Activity(discord.ActivityTye.listening, name =f"to {prefix} in {str(len(client.guilds))} servers")
```@slate swan
slate swan
#

Ok wait

sleek ore
#

Probably it's because of the previous lines

stark hearth
stark hearth
slate swan
#

Let me try

#

But can you tell me an alt for command.check_any

stark hearth
#

i said it in the fields cuz i thought you said only help command lmao

slate swan
#

I mean, the bot will check that either I or a person with manage channels perms should be able to access the commands

stark hearth
slate swan
#

Ok

#

I thought it was not gonna work lel

#

Help command still not working CryingOof

#

Same error

stark hearth
slate swan
#

IDK testing....

stark hearth
#

ok

slate swan
#

Nah none of the command working

patent lark
#

its possible you have an on_message event in which commands arent being processed?

slate swan
#

Nope

#

I didnt make on message event

patent lark
#

do you have an on_message event anywhere?

slate swan
#

Commands simply giving syntax error

stark hearth
patent lark
#

okay

kindred epoch
stark hearth
#

@slate swan did you implement f string on the client.event

slate swan
#

Yea but I csnt find error

#

Yea

stark hearth
slate swan
#

Still error

stark hearth
#

also do f strings in your help command as well

    embed.add_field(name=f"\uD83E\uDDCA ` {prefix} help`", value="Shows all commands' info", inline=False)
    img = ctx.message.author.avatar_url
    embed.set_thumbnail(url=img)
    embed.add_field(name=f"\uD83E\uDDCA `{prefix} embed <message>`", value="Sends embeded message\n *(Requires 'Manage Channel' Permissions)*", inline=False)
    embed.add_field(name=f"\uD83E\uDDCA `{prefix} about`", value="Shows info about the bot", inline=False)
    embed.timestamp = datetime.datetime.utcnow()
    embed.set_footer(text="Requested by {}".format(ctx.author))

like this

slate swan
#

I am saying that I tried to remove helpbcommand

#

But it still give same error on other command

patent lark
#

whats the error.

stark hearth
slate swan
#

Syntax error

kindred epoch
slate swan
#

I saw the code multiple times

stark hearth
#

@slate swan move the async down a line in the embed command

kindred epoch
slate swan
#

I know but

#

I am on phonr

kindred epoch
#

but?

slate swan
#

Right now

#

And it shows it in next line

kindred epoch
#

maybe theres something called auto rotate in your phone?

#

and idk why you would code on phone

#

like that just does not make sense

slate swan
#

Becuase I cannot code at PC right now

#

broken pc?

#

At this hour actually

supple thorn
stark hearth
slate swan
#

Nah its 6 am here

patent lark
slate swan
#

ppl might not have enough money to buy a pc too

kindred epoch
slate swan
patent lark
stark hearth
#

anyways...

slate swan
#

i use mine at 5 am

kindred epoch
supple thorn
patent lark
slate swan
#

:p

kindred epoch
patent lark
#

because its obvious

slate swan
kindred epoch
slate swan
#

I wake at 4

#

ohh

patent lark
kindred epoch
#

anyways, you can continue lmfao, i cant stop you from coding on a phone.

slate swan
patent lark
#

not everyone has the resources like other people do, sasuke, you seem to have a hard time understanding that.

stark hearth
#

lets just help shall we

#

please

slate swan
stark hearth
#

async def help

slate swan
#

Is there a tab before async def help

stark hearth
slate swan
#

My first time using commands.has_perms

stark hearth
#

also you can remove the @command.is_owner

patent lark
stark hearth
slate swan
#

Yea I thought that about the tab

stark hearth
#

IM MUTITAKINFG IM SORRY LMAO

#

i cant think straight

slate swan
patent lark
#
@bot.command()
async def hello(ctx):
  await ctx.send("Hello")```
basic command
slate swan
#

Everything was working good yesterday

#

Bad things started when my bot got rate limited in replit and I tried to add is_owner command

stark hearth
#

try removing the help command and saving it somewhere and see if the bot works without the help command

heavy heath
#

Could anyone help me rq with this command im trying to make?

slate swan
#

I think there is something in @commands.is_owner and has perms

stark hearth
slate swan
#

Yea

#

Its now giving error in embed command

#

Also I found this on stackoverflow

#

Cant we use something like this```py

@commands.is_owner() or @commands.has_permissions(manage_channels=True)```

#

@stark hearth

slate swan
#

Sad

stark hearth
#

my bad for caps i was dm someone

slate swan
#

👍

heavy heath
#

Im trying to make a command that only I can use. Everyone who uses the command gets the "You are not allowed to use this command" response, including me

async def servers(ctx):
    if ctx.author.id == '298856608585351168':
        await ctx.reply('Info posted in bot panel.')
        print('BotName is in these servers:')
        print('---------------------------')
        for guild in client.guilds:
            print(guild.name)
        print('---------------------------')
    else:
        await ctx.reply('You are not allowed to use this command.')```
#

Could anyone help please? Thanks

slate swan
heavy heath
#

Isnt that the server owner?

slate swan
#

nah

heavy heath
#

ohhh really?

slate swan
#

Just add your owner_id inpy client=bot.Commands(owner_id=Your ID)

heavy heath
#

thats pretty cool, thank you :)

slate swan
#

:)

patent lark
#

you dont need to do that

stark hearth
heavy heath
#

perfect, thank you all

patent lark
#

theres no need to add the owner_id kwarg in commands.Bot() to use @commands.is_owner()

slate swan
#

Need to go rn

Will come back after exams

#

Can anyone analyse the code please

stark hearth
stark hearth
#

also

slate swan
slate swan
stark hearth
#

i need help, how can make the roles not position like this

stark hearth
final iron
stark hearth
# final iron Give them more room

how?

    @commands.command(aliases=["whois"])
    async def userinfo(self, ctx, member: discord.Member = None):

        if member == None:
            member = ctx.author

        roles = [role for role in member.roles][1:]

        embed = discord.Embed(
            description = f'**User Infomation - **{member.mention}',
            colour=member.color, 
            timestamp=ctx.message.created_at
            )

        embed.set_thumbnail(url = member.avatar_url)
        embed.set_footer(text=f'Requested by {ctx.author}', icon_url=ctx.author.avatar_url)

        embed.add_field(name='ID:', value=f'`{member.id}`')
        embed.add_field(name='Nickname:', value=member.display_name)

        embed.add_field(name='Created at:', value=member.created_at.strftime('%a, %#d %B %Y, %I:%M %p UTC'))
        embed.add_field(name='Joined at:', value=member.joined_at.strftime('%a, %#d %B %Y, %I:%M %p UTC'))

        embed.add_field(name=f'Roles ({len(roles)})', value=" ".join([role.mention for role in roles]))
        embed.add_field(name='Top Role:', value=member.top_role.mention)

        embed.add_field(name = 'Bot:', value = member.bot)

        await ctx.send(embed=embed)
patent lark
#

you could add a newline character for every role

#

value = "\n".join()

stark hearth
patent lark
#

👍

rain bolt
#

Hello, I had a question about the select menu, I wanted to know how to send it with Embed?

wicked atlas
#

With those, most of them just extend the send or reply methods with a components kwarg, so just use both the embed and components kwargs

junior ore
#

what would be the event for checking when someone (specifically my bot itself) stops talking/playing audio

fast hedge
#

Can I get a hand with this. Description is being cut off

slate swan
#

@fast hedge , *, description

junior ore
#

light mode, why D:

fast hedge
hoary gust
#

Guys need some help

fast hedge
hoary gust
#

Guys I need a good host to host my dashboard and my bot together so is there one u guys know that can do this?

slate swan
fast hedge
#

@slate swan All good man. Thank you

slate swan
#

Yeah no worries cool

lilac galleon
#

can anyone give me tips for creating discord bot

wicked atlas
fast hedge
#

@slate swan Now I just have to figure out to combine these lol

exotic patrol
#
@commands.has_permissions(manage_server=True)```
lilac galleon
#

thanks @wicked atlas

exotic patrol
#

then you can do get role of that member and then check permissions of them

outer violet
outer violet
#

Hastebin

outer violet
exotic patrol
#

it is manage_server

#

let me check again

ember sorrel
#

manage_guild

#

np

lilac galleon
#

can anyone suggest me youtube video where discord.py is explained clearly

ember sorrel
ember sorrel
lilac galleon
stark bobcat
#

Which is better heroku or replit

ember sorrel
slate swan
stark bobcat
ember sorrel
#

none of them is suitable

slate swan
#

replit and heroku are not meant for hosting discord bots

ember sorrel
#

^

stark bobcat
slate swan
#

replit is better , yet not suggested to use

ember sorrel
#

doesnt matter which one is better, the point is that hosting a discord bot in either of them is not reliable

stark bobcat
#

Hmm ok

slate swan
#

yeah , both of them can lead to a ratelimit :p

covert igloo
#

how am I able to limit a command use to a certain channel

ember sorrel
covert igloo
#

'if ctx.channel == (ID) 'work?

slate swan
#

Working absolutely fine. Thanks !

ember sorrel
covert igloo
#

thank you!

ember sorrel
#

np

lilac galleon
boreal ravine
lilac galleon
boreal ravine
#

meaning

lilac galleon
#

nvm

#

i got this

boreal ravine
#

lmfao?

#

what dont u understand smh they all explain it clearly except those videos where they let you copy & paste lol

ocean leaf
#

Any mistake I have made?

#

It is not sending the message when a member joins a server

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.

slate swan
#

Make sure you have enable intents

ocean leaf
#

ok

#

i have intents already enabled

#

still dosen't work

slate swan
#

You have import intents in your main file?

ocean leaf
ocean leaf
slate swan
#

Go to discord developer portal

ocean leaf
#

ok

slate swan
#

And show me

ocean leaf
#

which tab?

slate swan
#

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

Restart your bot. Create new token and try again

ocean leaf
#

ok

#

nope still not working

slate swan
#

!pastebin

unkempt canyonBOT
#

Pasting large amounts of code

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

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

maiden fable
#

What happened?

slate swan
#

Show me your code

ocean leaf
#

it is 400 lines

slate swan
#

Yes

ocean leaf
#

with all features

slate swan
#

Then must organize your code

#

It will make everyone's life easier

ocean leaf
#

It is a challenge to make a bot in one file

maiden fable
ocean leaf
maiden fable
#

channel = member.guild.get_channel()

#

Also there's a typo

slate swan
#

Fk

maiden fable
#

In get_channel

eager bolt
maiden fable
#

Weird, should have raised an error

maiden fable
ocean leaf
slate swan
#

You wrote it wrong

maiden fable
#

Weird. Anyways fix it now

ocean leaf
slate swan
#

Should not return error?

eager bolt
#

i sent a message by accident

maiden fable
#

Ah, okay. It's fine

slate swan
#
AttributeError: 'Bot' object has no attribute 'chsannel'
#

Like that?

maiden fable
#

???

#

Should have raised Bot object has no attribute get_chsannel

slate swan
#

That's what I mean

ocean leaf
#

what is this?

maiden fable
#

discord.Embed

slate swan
#

discord.Embed

maiden fable
#

Capital E

ocean leaf
#

Ok

slate swan
#

!d discord.Embed

unkempt canyonBOT
#

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

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

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

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
lyric moat
#

why does it say 1 users? i used

{len(client.users)}```
slate swan
#

bcuz your its only counting it self

#

cuz client.users client.user specifies only it self

lyric moat
slate swan
lyric moat
#

yeah

slate swan
unkempt canyonBOT
#

property users: List[discord.user.User]```
Returns a list of all the users the bot can see.
lyric moat
slate swan
#

since users wont be cached until it is

lyric moat
#

hollon ima readd it to the server

#

nope does not work

#

prob its the version cause it worked on my other code

#

nope its not

#

Nvm i fixed it i did not added py intents = intents

slate swan
#

¯_(ツ)_/¯

dusk pumice
#
bot.remove_command("help")
maiden fable
#

Don't do like that

#

help_command = None in the bot constructor

dusk pumice
#

Hmm

#

I will make better help command

maiden fable
#

👍

dusk pumice
#

But is this ok alright?

#

Will it work?

maiden fable
#

?

dusk pumice
#

The code
Will it work?

maiden fable
#

Sure

dusk pumice
#

good

warm flame
#

guys for embedspy embed = discord.Embed() embed.setThumbnail(can i use a png directory here?)

maiden fable
#

Wrong

#

set_thumbnail()

gilded tundra
#

m

maiden fable
#

!d discord.Embed.set_thumbnail

unkempt canyonBOT
#

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

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

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
maiden fable
#

And u need a url bro

warm flame
maiden fable
#

U can do something like

#

url="attachment://name.png"

warm flame
#

in a string?

maiden fable
#

Yups

warm flame
#

is the name.png a string?

maiden fable
#

Edited it. Fine now?

dusk pumice
#

What about file=discord.file('dir') ?

warm flame
#

okk

maiden fable
dusk pumice
#

kk

warm flame
maiden fable
#

embed=embed

#

U did send(embed)

little ether
warm flame
#

ohhh

#

😅

#

this line is still not working

#

all im getting is this

slate swan
#

u also need a discord.File object and when u send it u also need to add (..., file=file)

maiden fable
#

....?

warm flame
#

on the set_thumbnail line?

dense swallow
#

Hi, I have dict of permission values for a member that is key perms, example: administrator etc... So how do I check if those dict of perms are there in a member?

#

I'm using member.guild_permissions for checking if member has that permission

hoary gust
#

Guys is there any host familiar to you that can run a quart app discord bot and one IPC together

warm flame
#

on the ctx.send()?

slate swan
#

.send(embed=embed, file=file)

warm flame
#

aight

slate swan
#

where file is a file object

#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
warm flame
#

i got it

dense swallow
#

I'm doing dict bcz I want specific perms to show up and also to remove _ even tho ik we can do it like .title() and replace

maiden fable
#

@dense swallow

#

Dude

#

!d discord.Permissions.advanced

unkempt canyonBOT
#

classmethod advanced()```
A factory method that creates a [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") with all “Advanced” permissions from the official Discord UI set to `True`.

New in version 1.7.
maiden fable
#

There

warm flame
#

does fp stand for filepath?

maiden fable
#

Yea

full valley
#

Hey guys, I'm wanting to make a 6 mans bot. Where players can q up for a game and it will randomly assign them in teams etc. I was wondering how I would host the bot, and the best way to go about a database for the win/loss stats.

#

I've only ever created very simple bots ran off my own pc.

dense swallow
stark hearth
#

if not, you are very limited

full valley
#

yeah, given its not to expensive

warm flame
#

wtf do i put for fp

#

do i just copy paste the file path?

left dove
warm flame
#

i put the comma and its still showing the same error

stark hearth
#

it depends on what perks you want on your vps

#

like memory and stuff

full valley
#

As in is it worth it

quiet coral
#

hello can someone show me how to use the spotify class in discord.py?

lone aurora
#
@client.event
async def on_message(ctx):
    guild = ctx.guild
    rol1e = discord.utils.get(guild.roles, name="susmommuted")
    if (ctx.author.has_role(rol1e)):
        embed = discord.Embed(
        title = '',
        description = '',
        colour = 0
        
        )
        embed.set_footer(text='By oSeatch#6969')
        embed.add_field(name='Disqualified!', value=f"{ctx.author} Has Lost!", inline=False)
        channel1 = client.get_channel(890476025996275732)
        await channel1.send(embed=embed)
        await ctx.author.remove_roles(rol1e)``` `AttributeError: 'Member' object has no attribute 'has_role'` getting this error ._.
left dove
stark hearth
lone aurora
warm flame
#

i got it

stark hearth
lone aurora
#

i didnt

warm flame
lone aurora
left dove
slate phoenix
lone aurora
#

yea but i put in ctx

#
@client.event
async def on_message(ctx):```
left dove
warm flame
#

not quite working

lone aurora
#

role = discord.utils.find( lambda r: r.name == 'susmommuted', ctx.message.guild.roles) AttributeError: 'Message' object has no attribute 'message' eh

stark hearth
slate phoenix
#

!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.
stark hearth
boreal ravine
lone aurora
#

yea i did, it didnt have the message parameter, it had the ctx one xd

lone aurora
#

i fixed it kekw (after someone gave me the code lmao)

stark bobcat
#

Hello

slate phoenix
stark hearth
# warm flame yea

it can be simple as await ctx.send(embed = embed, file=discord.File('idk.png'))

boreal ravine
#

idk if it works tho

slate phoenix
#

that wont work its not a url

slate swan
#

is there any way i can limit the amount of times OnCommandError can be raised untill it does nothing? kinda like putting a limit on how many times a command that is on cooldown can be called

boreal ravine
#

???

stark hearth
#

!d discord.Embed.set_image

unkempt canyonBOT
#

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

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

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
boreal ravine
boreal ravine
stark hearth
#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
boreal ravine
stark hearth
left dove
#

ill check with it

left dove
#

attachment// also we can use

stark hearth
boreal ravine
#

ok

stark hearth
#

i just saw in one of the docs

#

my bad kayle

lone aurora
#

is there anything i can use to make a command that will list all members with a specific role?

unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
stark hearth
#

!d discord.Role.members

unkempt canyonBOT
stark hearth
#

!d discord.Role

unkempt canyonBOT
#

class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
slate swan
#

How to change prefix for a single cog file?

stark hearth
# slate swan How to change prefix for a single cog file?

its something like

class Anything(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.prefix = "prefix"
    async def cog_check(self, ctx):
        return ctx.prefix == self.prefix

i know you would have to put something in your main file but i forgot and think staright cuz its like 11pm

#

imma go

#

bye bye

ocean leaf
#

we use <#channelid> to tag channel right?

umbral carbon
#

Hello I use repl and I want keep a few commands in a different .py file but also work in the main so it can be clean, is there anyway to do that?

umbral carbon
#

how do i use them i found the page kind of confusing

ocean leaf
#

cogs are used to make seperate files and then connect them to the main file

umbral carbon
#

yeah

little ether
ocean leaf
ocean leaf
#

or without space?

little ether
ocean leaf
ocean leaf
# umbral carbon how do i use them i found the page kind of confusing

In this video, we learn about cogs and how to implement them in a discord bot.

If you have any suggestions for future videos, leave it in the comments below.

GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/

OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN MY HELP SERVER: https:...

▶ Play video
lone aurora
#

prolly the best tutorial out there ngl

boreal ravine
#

ah class lucas

#

classic*

boreal ravine
lone aurora
slate swan
#

heyo bot is not taking the whole question its only making the first word as the question and not the word after space in as question

lone aurora
#
@client.command()
async def test(ctx):
    guild = ctx.guild
    role = discord.utils.get(guild.roles, name="susmommuted")
    members = discord.utils.get(role.list.Members)``` something like this?
slate swan
#

?

lone aurora
#

remove the , after question ._.

slate swan
#

kk

cloud dawn
lone aurora
cloud dawn
boreal ravine
lone aurora
boreal ravine
#

Just use 8ball i dont get why its _8ball lol

lone aurora
#
@client.command()
async def test(ctx):
    guild = ctx.guild
    role = discord.utils.get(guild.roles, name="susmommuted")
    members = role.list.Members
    ctx.send(members)``` tried this too ._.
cloud dawn
boreal ravine
cloud dawn
#

!e ```py
def 8ball(inputs):
return 'string'

8ball('something')

unkempt canyonBOT
#

@cloud dawn :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     def 8ball(inputs):
003 |         ^
004 | SyntaxError: invalid syntax
slate swan
cloud dawn
lone aurora
#

So the command should be like

!test @winged charm

bot :

  1. seatch
  2. some random
  3. idk
#

wait i pinged someone on accident..

boreal ravine
#

dont ping random people bruh

lone aurora
boreal ravine
#

you did moving on

lone aurora
#

it auto pinged for some reason

lone aurora
#

i just did

lone aurora
#

is there any way to do that?

boreal ravine
lone aurora
#

i didnt bruhhh

#

i pressed space

cloud dawn
lone aurora
#

@winged charm gonna send this

#

S E E

lone aurora
lone aurora
#

see i told u kayle

lone aurora
slate swan
#

!d discord.Role.members

unkempt canyonBOT
lone aurora
slate swan
#

What's so hard?

#

Get a role, and do role.members..

cloud dawn
#

🧠

lone aurora
#

i try this it hit me in the face

slate swan
#

no, role.members

#

not Members

lone aurora
#

wha ok

cloud dawn
lone aurora
#

okok i try

slate swan
orchid talon
#

my on_member_join command is not working properly

orchid talon
#

what ok

lone aurora
#
@client.command()
async def testing(ctx):
    role_id = discord.utils.get(guild.roles, name="susmommuted")
    member = role_id.Members
    if role_id in [role.id for role in (member.roles or ctx.author.roles)]:
        await ctx.send('Role found')``` like this?
orchid talon
# cloud dawn okay

i have asked one of my friend his on_member_join command is also not workin

#

g

lone aurora
#

send the code

orchid talon
#

wait

orchid talon
orchid talon
spring flax
cloud dawn
lone aurora
#

ok wtf wait i need to see why my entire bot breaking.. no cmds working brehhh

orchid talon
spring flax
spring flax
orchid talon
#

wait

plain eagle
#

If anyone knows MongoDB please help me in discord bot ;-;
#databases

lone aurora
orchid talon
#

see dev portel

spring flax
umbral carbon
lone aurora
#

ill try it but for now the command itself isn't working..

spring flax
#

alternatively you can add
await bot.process_commands(message) to the bottom of the @bot.event

umbral carbon
#

why are my curly braces not like in lukas's video?

spring flax
orchid talon
lone aurora
#

okok

orchid talon
spring flax
#

huh

plain eagle
#

naw

cloud dawn
lone aurora
#
@client.listen()
async def on_message(ctx):
    role = discord.utils.find( lambda r: r.name == 'susmommuted', ctx.guild.roles)
    if role in ctx.author.roles:
        embed = discord.Embed(
        title = '',
        description = '',
        colour = 0
        
        )
        embed.set_footer(text='By oSeatch#6969')
        embed.add_field(name='Disqualified!', value=f"{ctx.author} Has Lost!", inline=False)
        channel1 = client.get_channel(890476025996275732)
        await channel1.send(embed=embed)
        await ctx.author.remove_roles(role)``` how's this diabolical?
spring flax
#

!d discord.ext.commands.Bot.listen

plain eagle
# orchid talon code

client = commands.Bot(command_prefix='c!', intents=discord.Intents.all(), case_insensitive=True)

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.9)").

Example...
plain eagle
lone aurora
umbral carbon
spring flax
spring flax
#

bruh

cloud dawn
spring flax
#

make it a command not an event @lone aurora

#

wait

lone aurora
#

i- i- w h a t

plain eagle
placid skiff
plain eagle
#

on_message is an event

spring flax
spring flax
umbral carbon
slate swan
#

i need help

cloud dawn
plain eagle
spring flax
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.9)").

Example...
slate swan
#

please help

cloud dawn
umbral carbon
#

oh-

little ether
lone aurora
#
@client.command()
async def testing(ctx):
    role_id = discord.utils.get(guild.roles, name="susmommuted")
    member = role_id.Members
    if role_id in [role.id for role in (member.roles or ctx.author.roles)]:
        await ctx.send('Role found')``` just please, how can i fix this to show all the members in a specific `role`
plain eagle
slate swan
#

im getting this error

#

Traceback (most recent call last):
File "main.py", line 18, in <module>
client.run(os.environ['token'])
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
Traceback (most recent call last):
File "main.py", line 18, in <module>
client.run(os.environ['TOKEN'])
File "/usr/lib/python3.8/os.py", line 675, in getitem
raise KeyError(key) from None

cloud dawn
unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
spring flax
#

oh yeah that's for cog

little ether
spring flax
spring flax
#

!d discord.Role.members

unkempt canyonBOT
cloud dawn
slate swan
#
@client.command()
@commands.is_owner()
@commands.has_permissions(manage_channels=True)
async def help(ctx):
    embed=discord.Embed(title="Embed Bot", color=discord.Colour.random())
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"help`", value="Shows all commands' info", inline=False)
    img = ctx.message.author.avatar_url
    embed.set_thumbnail(url=img)
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"embed <message>`", value="Sends embeded message\n *(Requires 'Manage Channel' Permissions)*", inline=False)
    embed.add_field(name="\uD83E\uDDCA `"+prefix+"about`", value="Shows info about the bot", inline=False)
    embed.timestamp =datetime.datetime.utcnow()
    embed.set_footer(text="Requested by {}".format(ctx.author))
    await ctx.reply(embed=embed)```
slate swan
#

So should I divide the program?

spring flax
#

yeah you can read the pinned messages

slate swan
#

Or is there any other way to check if a user has a perm.......other than ```py
@commands.has_permissions(manage_channels=True)

lone aurora
#

nice it works now

slate swan
#

y am i get no help

lone aurora
#

@slate swan define your TOKEN

slate swan
#

wdym

#

here check out my repl link

lone aurora
#

like uh add

TOKEN = your.token```
#

do you know what a bot token is?

slate swan
#

yea

#

he is using .env

placid skiff
#

Someone knows where i can host both bot and website? (Rather if the server is dedicated)

lone aurora
lone aurora
#

but there are plenty of hosts out there

slate swan
#

infinty free

grand oracle
#

How do i have the bot send emojis??

slate swan
maiden fable
slate swan
#

yea lmao

maiden fable
#

\:emoji:

grand oracle
#

carp i meant stickers

maiden fable
maiden fable
placid skiff
slate swan
#

plerase help

cloud dawn
#

wups

lone aurora
slate swan
#

without sub classing

grand oracle
maiden fable
#

@slate swan what do u need help with?

grand oracle
#

i cant copy the link :(

lone aurora
placid skiff
lone aurora
#

it looks nicer and easier to read imo

slate swan
timber crescent
#

whats the worst that could happen if i were to host two different scripts using the same bot token?

slate swan
#

HELP PLEASE

maiden fable
#

help is already a function in Python

#

!d help

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3.10/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3.10/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3.10/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
slate swan
#

nah any command is not working

maiden fable
#

See

timber crescent
#

like some messages could go unlistened or not go through yea?

slate swan
#

HELP

timber crescent
maiden fable
#

U should do command(name="help") and name the function something else

slate swan
maiden fable
grand oracle
spring flax
#

@slate swan calm down.

cloud dawn
# lone aurora something like [User1] [User2]
@client.command()
async def testing(ctx):
    role = discord.utils.get(guild.roles, name="susmommuted")
    members = "\n".join([member.name for member in role.members])

    await ctx.send(members)
placid skiff
timber crescent
#

also what are shards

slate swan
maiden fable
#

No one would click that

spring flax
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

spring flax
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

ok

spring flax
#

bruh

maiden fable
#

Hmm

timber crescent
#

that...

slate swan
#

andd error Traceback (most recent call last):
File "main.py", line 18, in <module>
client.run(os.environ['token'])
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
Traceback (most recent call last):
File "main.py", line 18, in <module>
client.run(os.environ['TOKEN'])
File "/usr/lib/python3.8/os.py", line 675, in getitem
raise KeyError(key) from None
KeyError: 'TOKEN'

timber crescent
#

thats not too big XD

cloud dawn
#

how to jinx yourself

maiden fable
#

Token ain't set as an environment var

unkempt canyonBOT
#

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

maiden fable
#

....?

cloud dawn
maiden fable
timber crescent
#

how can i run multiple instances on like the same bot token

maiden fable
#

🤷

cloud dawn
#

🤦‍♂️

slate swan
#

let me try some thing

grand oracle
timber crescent
#

isnt that the same thing as 'shards'

cloud dawn
maiden fable
#

@slate swan does it work BTW?

slate swan
#

music bot isn't breaking rules right?

cloud dawn
maiden fable
slate swan
#

HOW what about rhythem,groove

maiden fable
timber crescent
cloud dawn
maiden fable
slate swan
#

f youtube

timber crescent
#

youtube just announed an official collab with discord to implement it themselves and murdered all the bots

maiden fable
slate swan
#

ikr

slate swan
cloud dawn
slate swan
#

so let me try

cloud dawn
grand oracle
#

i forgot its name

placid skiff
slate swan
#

lmao i think umm youtube stopped making it work i think

maiden fable
placid skiff
#

Lel

grand oracle
#

yt sued em

cloud dawn
slate swan
#

boy im delete now

cloud dawn
timber crescent
#

what are.... 'shards'

slate swan
#

welll how else would i play music

timber crescent
#

or is that a java thing

cloud dawn
#

although they let off rythm and groovy kinda easy.

slate swan
#

in my server

timber crescent
#

host an illegal internet radio perhaps perhaps

slate swan
#

cuz how would i rickroll my dev staff lol

maiden fable
timber crescent
#

if youre at the point of putting in the effort to make a music bot you might as well ig

cloud dawn
cloud dawn
placid skiff
maiden fable
cloud dawn
timber crescent
#

how can shards work but running two diffferent instances of a script one will break

slate swan
#

yea

maiden fable
cloud dawn
grand oracle
#

yep

cloud dawn
grand oracle
#

on 15th or 14th september

heavy folio
#

hi, i made a snipe command, and i want the bot to check only the channel, not the entire server but now it keeps saying theres nothing to snipe

sniped_messages = {}

@client.event
async def on_message_delete(message):
  sniped_messages[message.guild.id] = (message.content, message.author, message.channel.id, message.created_at)

  await asyncio.sleep(3600)

@client.command(aliases=['sn'])
async def snipe(ctx):
  channelid = sniped_messages[ctx.guild.id]
  if channelid == ctx.channel.id:
    try:
      contents, author, created_at = sniped_messages[ctx.guild.id]
    except:
      await ctx.reply("There's nothing to snipe, bro")
    embed = discord.Embed(title="Last Deleted Message", description=f"> {contents}", color=discord.Color.random())
    embed.set_author(name=f"{author.name}#{author.discriminator}", icon_url=f"{author.avatar_url}")
    embed.set_footer(text=f"sniped by {ctx.author.name}#{ctx.author.discriminator}")
    await ctx.reply(embed=embed)
  else:
    await ctx.reply("There's nothing to snipe, bro")
timber crescent
maiden fable
timber crescent
#

i am making smthn that will be kinda user hosted

maiden fable
timber crescent
#

like each individual user runs it

maiden fable
timber crescent
#

so itll end up with multiple instances regardless

maiden fable
#

DON'T give your token to anyone

#

They can kill your bot, nuke your serer and stuff

timber crescent
#

nah bot wont have power anyways and i trust these peeps

maiden fable
#

Bruh

timber crescent
#

its like a convinience bot we;re working on

cloud dawn
# maiden fable Indeed

python in the future ```py
from discord import Main

Main('*#U9jd3j93JD(#*u938ddk--3-3dj(#((#')

grand oracle
timber crescent
#

so... even if everyone has the same scripts running (same token) bot wouldnt break too much yea?

grand oracle
#

bot give error saying bot is already being ran

tropic briar
#

Why I am getting these errors from external scripts when I run a command

maiden fable
timber crescent
maiden fable
tropic briar
timber crescent
#

like every instance acts like a shard

maiden fable
#

Bruh no

grand oracle
#

no

timber crescent
#

why doesnt that work?

maiden fable
#

What....? That's your code only

cloud dawn
timber crescent
#

its just one server

heavy folio
#

ohh nvm

maiden fable
grand oracle
#

you are saying "can i use the same keyboard for 10 pcs?"\

tropic briar
#
Bot is now Online
F:\Python\monke bot\main.py:45: RuntimeWarning: coroutine 'Message.delete' was never awaited
  msg.delete()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ignoring exception in command bant:
Traceback (most recent call last):
  File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "F:\Python\monke bot\main.py", line 22, in bant
    await member.ban(reason=reason)
AttributeError: 'Context' object has no attribute 'ban'

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

Traceback (most recent call last):
  File "F:\monke bot\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'ban'
``` Bant and kickt are commands lol
timber crescent
#

but there will be several instances of the script

cloud dawn
timber crescent
#

i just want several instances to exist epacefully

slate swan
#

it's a coroutine

tropic briar
maiden fable
#

@timber crescent

drifting arrow
#

Oh lord

timber crescent
#

can sharding also do that as a side effect?

slate swan
tropic briar
timber crescent
tropic briar
timber crescent
#

so sharding essentially breaks the bot functions into several scripts?

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

maiden fable
drifting arrow
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

heavy folio
tropic briar
#
import discord
from discord.ext import commands

client = commands.Bot(command_prefix='.')
Filter = 'giant'


@client.event
async def on_ready():
    await client.change_presence(status=discord.Status.idle, activity=discord.Game('Hello there!!'))
    print('Bot is ready')
    print('Bot is now Online')


@client.command()
async def kickt(member: discord.Member, *, reason=None):
    await member.kick(reason=reason)


@client.command()
async def bant(member: discord.Member, *, reason=None):
    await member.ban(reason=reason)


@client.command()
async def setdelay(ctx, seconds: int):
    await ctx.channel.edit(slowmode_delay=seconds)
    await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")


@client.command()
async def clear(ctx, amount=5):
    await ctx.channel.purge(limit=amount)


@client.command()
async def delete(ctx, message):
    await ctx.channel.delete(message)


@client.event
async def on_message(msg):
    for word in Filter:
        if word in msg.content:
            msg.delete()

    await client.process_commands(msg)
timber crescent
#

welp in that case idts the instances will function quite how i want them to

maiden fable
heavy folio
#

oh

timber crescent
#

so my best bet is to either have a central script that has the bot acess or several bots ye?

slate swan
tropic briar
#

ok

timber crescent
#

thatll be quite the hassle but a managable hassle i suppose ty for the help

little ether