#discord-bots

1 messages ยท Page 480 of 1

forest mortar
#

oh really.

#

gonna need to say that.

shut axle
#
from discord_slash import SlashCommand
client = commands.Bot(command_prefix='k.', intents=discord.Intents.all())
slash = SlashCommand(client, sync_commands=True)

@slash.slash(name="ping", description="sends pong")
async def ping(ctx):
  await ctx.send("**Pong!**")

It doesn't work without any error.

slate swan
#

anyone have an autorole system I can use?

bitter perch
#

Not true

#

It's literally just cached python bytecode

pliant gulch
#

I'm confused to as why you are even telling me this and what it has to do with what I was talking about

slate swan
#

how to get when new chanell** is created

hasty iron
#

!d discord.on_guild_channel_create

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

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

Is there a command decorator to make commands case insensitive or would I have to manually do it?

#

Also came somebody explain to me the difference between has_permissions and has_guild_permissions

slate swan
final iron
slate swan
#

does anybody know what does this mean i just dont get it still its a async praw command:

if not submission.is_self
#

depends has_permission mean you have to manually go to everychannel and set the perms but it can be useful for VERY specific things has_guild_permissions is the easiest for things like mod commands

slate swan
# slate swan what are you trying to do?

im trying to get reddit submissions that are only images and text and not only text but i got this command that i know what it means the is.self but i dont understand what the whole thing means im just very confused

final iron
#

No idea why you would really want to do that

#

Since there is not in there

slate swan
#

@final iron You can solve this one

final iron
#

Its checking if it didn't make the post

slate swan
final iron
#

let this man do it

#

Im terrible at explaining

hasty iron
#

it checks if the submission was not posted by the authenticated user

#

which is you

#

or whoever

slate swan
final iron
#

Oh nice just figured out that the person who made the discord.py documentation doesn't live in the us

#

Thats cool ig

slate swan
#

lol

#

Hey does anyone have an autorole system I can use

#

bot not client

final iron
#

Like created yourself?

slate swan
#

that's not how we help here....

final iron
#

^

#

Basically we help you with existing commands to help you learn

slate swan
#

I understand

final iron
#

Not create you commands

slate swan
#

*event

#

some materials that you can use are like

#

!d discord.on_raw_reaction_add

#

huh

unkempt canyonBOT
#

discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.

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

Me when bot

slate swan
#

!d discord.Reaction.emoji

unkempt canyonBOT
final iron
#

Oh d is for documentation

slate swan
#

yes

final iron
#

Makes sense

slate swan
final iron
#

for create_role in the documentation it says colour is Colour, int so what exactly does that mean

slate swan
#

!d discord.Colour

unkempt canyonBOT
#

class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)").

There is an alias for this called Color.

`x == y` Checks if two colours are equal.

`x != y` Checks if two colours are not equal.

`hash(x)` Return the colourโ€™s hash.

`str(x)` Returns the hex format for the colour.
slate swan
#

?

final iron
#

No

#

Its a parameter in create_role

slate swan
#

lemme check

final iron
#

colour=

slate swan
#

!d discord.Guild.create_role

unkempt canyonBOT
#

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

Creates a [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

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

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
slate swan
#

oh I see

#

the colour parameter can either be a discord.Colour instance or an int

final iron
#

discord.Colour is like rgb right

#

3 numbers

#

That define the colour?

slate swan
#

it has methods

#

discord.Colour().red()

#

for example

final iron
#

For the integer

slate swan
#

but as I see, it could just have a value

final iron
#

Can I get an example

#

Its not a hex code right

slate swan
final iron
#

If I used Colour.from_rgb I could have the user pass in the 3 numbers right

#

like 100 50, 125?

slate swan
#

check it in the docs...

final iron
#

alr

slate swan
#

classmethod from_rgb(r, g, b)

#

so indeed

final iron
#

Yup I see now ty

slate swan
#

discord.Colour().from_rgb(r, g ,b)

visual island
#

you don't need to create it as an instance

#

discord.Color.from_rgb(r, g, b)

slate swan
#

mmhmm

#

will remember that

lapis lintel
#

What are the options now that dpy has been archived?

final iron
#

Can somebody link me to the documentation to delete a role I can't seem to find it

visual island
#

!d discord.Role.delete

unkempt canyonBOT
#

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

Deletes the role.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this.
visual island
final iron
#

I don't see it in the parameters

visual island
final iron
#

so discord.utiles or whatever it is?

visual island
#

no

#

!d discord.Guild.get_role

unkempt canyonBOT
visual island
#

!d discord.utils.get or this yeah

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/stable/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...
final iron
#

Thank you

slow epoch
#

How do I have my bot press a anothers bots button

#

im trying to have my bot press another bots button and that bot adds a role to my bot

bitter perch
#

Bots cannot interact

untold wharf
#
@raven.command()
async def prefix(ctx, *, message):
    print(f"[{Fore.MAGENTA}RAVEN{Fore.WHITE}] [{Fore.MAGENTA}{current_time}{Fore.WHITE}] โ€บ Command Ran {PREFIX}{Fore.MAGENTA}prefix{Fore.WHITE}")
    if ravenconfig.get("Raven-COMMANDLOGGING") == "on":
        with open("log/Commands.log", "w") as l:
            l.write(f" Log: [{current_time}] Prefix Was Ran By User {raven.user}")
    if ravenconfig.get("Raven-COMMANDLOGGING") == "off":
        pass
    with open("Raven.json", "w") as r:
        newPrefixData = {
            "Raven-TOKEN": TOKEN,
            "Raven-PREFIX": message,
            "Raven-DELTIMER": DELTIMER,
            "Raven-COMMANDLOGGING": LOGGING
        }
        r.write(json.dumps(newPrefixData))
        NEWPREFIX = ravenconfig.get("Raven-PREFIX")
        raven.command_prefix = str(NEWPREFIX)
    prefixEmbed = discord.Embed(
        color=0x483248,
    timestamp=ctx.message.created_at)
    prefixEmbed.set_author(name="Prefix was changed :heavy_check_mark:")
    await ctx.send(embed=prefixEmbed)```
#

why is it in my prefix command
when i run it, it changes the prefix but it doesnt allow me to use the new prefix
i realised i needed to reopen the json and define NEWPREFIX but what do i do then?

final iron
bitter perch
final iron
#

How would I store permission attributes like administrator=Trueall together?

bitter perch
#

You don't

final iron
#

Im creating a command that makes a role with certain permissions

untold wharf
#

learn python or re-read it

bitter perch
#

dude

#

I have read your code

#

I even told you this in dpy

untold wharf
#

do it again or ill point it out again

bitter perch
#

please do

#

You never reload the json

untold wharf
#

get the new prefix

bitter perch
#

Nope

untold wharf
#

from the already established

bitter perch
#

Still the old json

untold wharf
#

oh

bitter perch
#

From before the new values were dumped

untold wharf
#

ok

bitter perch
#

Which if you listened, I pointed out, but it seems you were too busy being a dick.

slate swan
#

lol

#

Umm

#

Yea because logs are not a thing here

untold wharf
#

not to you

slate swan
#

And?

untold wharf
#

@bitter perch yea thats

#

not woeking

stark bobcat
#

Hoi

bitter perch
#

You can't read on a write open

#

...

untold wharf
#

so reopen

bitter perch
#

yes.

untold wharf
#

yes there is stuff in the json file

#

yea that still doesnt work lol

#

it should go like

bitter perch
#

Your json became invalid

untold wharf
#

never heard of that before

bitter perch
#

There should be L:C of where the json is invalid

untold wharf
#

line 1 column 1

bitter perch
#

What is the json

final iron
#

How would I store permission attributes like administrator=True?

#

Would I use a tuple?

bitter perch
#

What are you trying to do

final iron
#

A command to create a role with preset permissions

#

Permission which I would set

bitter perch
#

You could do a store true type thing

#

If the perm doesn't appear assume false

final iron
bitter perch
#

if you pass it, it's true

#

Else it's false

final iron
#

Ik but how would I store it

#

In a tuple?

#

I need to store it in a variable

#

Because I need to define a lot of permissions

bitter perch
#

like in a database or as a parameter?

untold wharf
final iron
#

like permissions =

bitter perch
#

You can create a discord.Permissions object

#

And call .update

#

And that takes a k: v pair of permission: bool

final iron
#

I don't think im really explaining what I need help with well

untold wharf
#

no help bruh

#

like fr its this simple

#

!prefix ;

#

;help

final iron
#

An example of what im trying to do is

permissions = [
  administrator=True
  manage_messages=True
  ]
#

Something like that except working

bitter perch
#

use a dictionary

#

or a tuple

#

(List of tuples)

final iron
#

Sorry its a bit late so im kinda so rn

bitter perch
#

A dictionary is a collection of key: value

#

This is the exact data type you want

final iron
#

Oh alr

#

So would it be administrator: True?

#

If its not can I just get an example please?

bitter perch
#

you'd want it to be a string

#

"administrator": True

untold wharf
#

help me

#

this is so complicated for no reason

final iron
#

Oh alr ty

#

Ill try it out

#

Btw if I don't define the permission will it default to False?

bitter perch
#

For?

final iron
#

In the dictionary

lyric moat
#

how do i make my bot say Command Not Found when someone try saying a command thats not there

final iron
#

If I parse the dictionary for a roles permissions and certain permissions aren't defined will they default to False

bitter perch
#

If a key doesn't appear in a dictionary and you try to index it, it'll throw a key error

final iron
#

Oh okay so ill have to define everything then

unkempt canyonBOT
#

discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
slate swan
#

And use commands.CommandNotFound to compare isinstance

bitter perch
final iron
bitter perch
#

yes I got that

#

!d discord.Permissions.update

unkempt canyonBOT
#

update(**kwargs)```
Bulk updates this permission object.

Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored.
bitter perch
#

make a permissions object then update it with your dict

final iron
#

You know what imma just finish this tmr

lyric moat
# slate swan !d discord.on_command_error

Could This Work?

@client.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.MissingRequiredArgument):
    await ctx.send(':heartbroke_no: **Command Not Available**')```
slate swan
#

Replace commands.MissingRequired.....

#

!d discord.ext.commands.CommandNotFound with this

unkempt canyonBOT
#

exception discord.ext.commands.CommandNotFound(message=None, *args)```
Exception raised when a command is attempted to be invoked but no command under that name is found.

This is not raised for invalid subcommands, rather just the initial main command that is attempted to be invoked.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").
lyric moat
#

replace it with

commands.CommandNotFound(message=None, *args)
slate swan
#

No , the () is not required

#

just commands.CommandNotFound

#

in case you want to get the name of command user used , you can use ctx.invoked_with

lyric moat
#

Thanks It worked

slate swan
#

glad to help :3

final iron
#

You know what lemem try again to explain

lyric moat
#

How can i make the bot sends a message in there server as they added it?

final iron
#

Im using this await guild.create_role(name="Moderator", permissions=, colour=rgb_color) to create a role. I want permissions= to equal a list/tuple/whatever that holds the roles permissions like this

administrator=False,
manage_messages=True,
manage_channels=True
#

My issue is I don't know what to store those permissions in

drifting arrow
#

๐Ÿค” anybody have any ideas on how one would allow a discord bot to do a thing when it receives a private message?

opaque trellis
#

Hi, I am trying to make a bot that plays music, however, when I run this command (below)

@bot.command()
async def stop(ctx):
    if ctx.voice_client is not None:
        await ctx.voice_client.stop()
        await os.remove('temp\song.mp3')
        
    else:
        await ctx.send("Bot is not connected to a voice channel")

it raises the error "Object NoneType cannot be used in await expression"

drifting arrow
#

there's 3 awaits there.

opaque trellis
#

oh my bad

#

the one that errors is the stop

#

but if I take it out of the await it says it needs to be in an await expression

final iron
drifting arrow
#

Looking into it. I havent done much with voice.

#

gimme a moment. I think that command is wrong.

#

Usually it's the opposite of whatever you did to start it.

drifting arrow
#
voice = discord.utils.get(bot.voice_clients, guild=ctx.guild) #gets the bots voice clients by guild.
await voice.stop() #try this

#

@opaque trellis

opaque trellis
#

hm ok

#

thank you, will update

drifting arrow
#

Alternatively, you could just do a force disconnect and reconnect ๐Ÿ˜‰

opaque trellis
#

that's true, but I need it to be able to delete the mp3 file as well

drifting arrow
#

No. Just disconnect the bot from voice. do the thing to the MP3 file. then reconnect. not as efficient or good, but it's AN solution

slate swan
#

hi guys, someone can made a bot of games?

opaque trellis
#

ah I see, but yeah functionality is iffy lol

#

@drifting arrow same error lol

drifting arrow
#

๐Ÿ˜ฆ

jolly vault
#
@bot.command(name='summarize')
async def summarizer(ctx,*,args):
    text = int(args)
    tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum")
    model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
    tokens = tokenizer(text, truncation=True, padding="longest", return_tensors="pt")
    summary = model.generate(**tokens)
    x = tokenizer.decode(summary[0])
    await ctx.channel.send(x)

nothing is happening here

drifting arrow
#

what is a pegasus tokenizer?

jolly vault
#

Pegasus is an AI model used for text summarization

drifting arrow
#

neat

jolly vault
#

and the toxinizer is needed to toxinize the first input of information so that it could change into the summary

drifting arrow
#

Well if nothing is sending, perhaps try printing out each variable to make sure they're working

slate swan
#

Code: #Pfp command to view somones pfp! @bot.command() async def avatar(ctx, *, avamember : discord.Member): userAvatarUrl = avamember.avatar_url await ctx.send(userAvatarUrl) Error: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 995, in invoke await ctx.command.invoke(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 895, in invoke await injected(*ctx.args, **ctx.kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 177, in wrapped raise CommandInvokeError(exc) from exc nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'

#

i think nextcord does member.avatar.url or is that pycord?

#

idk

#

try avamember.avatar.url maybe

#

may or may not work

slate swan
#

I am using nextcord but like

#

it should

drifting arrow
#

Oh

#

idk how nextcord works

slate swan
#

It should the same thing because discord.py stopped in development

#

isn't nextcord based on the latest master release

#

then it should be avatar.url

drifting arrow
slate swan
#

no, avatar.url

#

it's one of the last changes danny made before quitting development

drifting arrow
#

Mine works as avatar_url

slate swan
drifting arrow
#

;-;

slate swan
#

??

#

i dont remember dpy 2.0 being avatar.url

drifting arrow
#

it's the ver im using

#

Had to get it to do a thing

slate swan
#

ahhhh

#

let me see

#

so like this? @bot.command() async def avatar(ctx, *, avamember : discord.Member): userAvatarUrl = member.avatar.url await ctx.send(userAvatarUrl)

#

yup

drifting arrow
#

Wait nevermind @slate swan is right. I was using the wrong command LOL

slate swan
#
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 995, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 895, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 177, in wrapped
    raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'member' is not defined```
#

@slate swan

boreal ravine
#

why make a variable just send it lmfao

slate swan
drifting arrow
# slate swan ```Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/pytho...

You need to tag someone.

    @commands.command(help='[Sends the avatar of the mentioned user.]')
    @commands.is_owner()
    async def avatar(self, ctx, *, member: discord.Member):
        userAvatar = member.avatar.url
        embed = discord.Embed(color = member.color, timestamp = ctx.message.created_at)
        embed.set_author(name = f'Avatar of {member}')
        embed.set_image(url = userAvatar)
        embed.set_footer(text = f'REquested by {ctx.author}', icon_url=ctx.author.avatar.url)
        await ctx.send(embed=embed)
slate swan
#

not only that,

#

he made his variable name avamember

#

so it's avamember.avatar.url

#

not member.avatar.url

boreal ravine
# slate swan

Will member.avatar.read() work for default profiles?

boreal ravine
slate swan
#

wait

drifting arrow
#

Waiting

slate swan
#

welp thanks

#

lol

boreal ravine
#

nextcord is 2.0

slate swan
slate swan
#

its newer

lost lagoon
#

Hi ya there I need some help. I made some kick and ban commands but turns out anyone can use them, anyone know how to make it role specific?

sour mountain
#

i wanted to know how to find if a message contained some keywords which i cant find with message.content

slate swan
#

@commands.has_guild_permissions(perm here=True)

lost lagoon
#

does the perm have to be a role

#

or just the general perms?

boreal ravine
# lost lagoon does the perm have to be a role
@commands.has_permissions(ban_members=True, kick_members=True) 
#  e.g. this command will require both kick and ban permissions
# Check if user has all of the passed permissions 
@commands.has_any_role("role1","foo",11132312313213) 
# Check if user has any of the roles with the names "role1", "foo", or the role with id 11132312313213
slate swan
sour mountain
#

anyhelp ?

slate swan
#

is the overall perms of the role

lost lagoon
#

ok

sour mountain
#

cuz there was a way in java but idk how to do that in python

slate swan
#

so if I have manage messages for a role it will be possible for every channel

lost lagoon
slate swan
#

works both

boreal ravine
#

bruh

slate swan
#

so this works as well: #Bans a User @bot.command(description="Bans a member") @commands.has_guild_permissions(ban_members=True) async def ban(ctx, member: discord.Member, *, reason=None): await member.ban(reason=reason) await ctx.send(f"{member} was banned!")

lost lagoon
#

so do i replace client.command?

slate swan
#

??

lost lagoon
boreal ravine
slate swan
sour mountain
#

no there was

#

some other

#

in java

#

i think it was contains or something

slate swan
#

the func/attribute would be using message.content inside its structure for sure

drifting arrow
#

How can I target messages sent by a specific user so I can remove them?

slate swan
slate swan
#

if the role updates its name you have to go back and update it

slate swan
drifting arrow
#

Then dont update its name?

lost lagoon
boreal ravine
sour mountain
#

thx

slate swan
#

no

dapper cobalt
boreal ravine
slate swan
#

where is your client.command() ??

sour mountain
#

ill try both

dapper cobalt
#

includes() is in Java and JavaScript and not Python.

slate swan
#

it was for java , wont work in py

lost lagoon
sour mountain
#

oof

dapper cobalt
boreal ravine
dapper cobalt
#

Below, so the command would be registered with the checks.

slate swan
#
@commands.has_guild_permissions(kick_members=True)
async def boot(ctx......)```
dapper cobalt
#

!code and yes, correct.

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.

slate swan
#

something like that

lost lagoon
#

this right, just confirming sorry for being annoying

dapper cobalt
#

kick_members.

slate swan
lost lagoon
#

thats it right?

dapper cobalt
#

And this is a Python help server, I don't think it's annoying to ask?

lost lagoon
#

nothing else required

slate swan
#

should be

lost lagoon
#

Thanks for you time!

dapper cobalt
lost lagoon
#

yup will do!

#

thanks again

dapper cobalt
#

No problem.

#

Also I suggest adding if statements to check whether the bot would be able to kick that member or not. For example, check if the member's top role is above or equal to the bot's top role.

#

!d discord.Member.top_role

unkempt canyonBOT
#

top_role```
Returns the memberโ€™s highest role.

This is useful for figuring where a member stands in the role hierarchy chain.
boreal ravine
#

How do I view my avatar if I have a default pfp in 2.0? The error I get: ```py
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'url'

dapper cobalt
#

if member.top_role >= ctx.guild.me.top_role:

drifting arrow
#

How would I purge the messages from a specific person?

drifting arrow
dapper cobalt
drifting arrow
pliant gulch
#

You would pass a function to the check kwarg of purge

#

There you return if the message author is the same as the user you specified

dapper cobalt
#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=None, 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/stable/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own (unless you are a user account). The [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Internally, this employs a different number of strategies depending on the conditions met such as if a bulk delete is possible or if the account is a user bot or not.

Examples

Deleting botโ€™s messages
slate swan
#
@bot.event
async def on_member_join(member):
    role = discord.utils.get(member.guild.roles, id="888819465020649533")
    await member.add_roles(role)```
#

so this is my autorole code

pliant gulch
#

Id's aren't strings

slate swan
#

but it doesnt work

pliant gulch
#

This would return None

#

Id's are integers

dapper cobalt
#

purge has a check kwarg. You could do

check=lambda m: m.author == user
slate swan
#

and doesnt give me errors

pliant gulch
dapper cobalt
slate swan
#

ohhh

slate swan
#

f me

#

shush

pliant gulch
#

You don't need discord.utils.get

#

You can just do guild.get_role(id)

#

Since you have access to guild ofc, from member.guild

drifting arrow
#
@commands.command()
    async def clear_messages(self, ctx, member: discord.Member):
        check = lambda m: m.author == member
        await ctx.channel.purge(limit=amount, check=check)
``` would work?
patent ivy
#

when you do !help how do I get the descriptions to display there instead of when you do !help command

drifting arrow
#

Oh I forgot to specify limit. but I can do that in a moment

pliant gulch
#

Whats the point of assigning a variable as a lambda instead of passing the lambda directly

#

Kinda defeats the purpose of a lambda here

dapper cobalt
#

As andy said.

boreal ravine
drifting arrow
#
@commands.command()
async def clear_messages(self, ctx, member: discord.Member, amount=10):
    await ctx.channel.purge(limit=amount, check=lambda m: m.author == member)
```?
#

imma run it and see I guess

patent ivy
#
@client.command(description = f"purges x amount of messages. Needs manage messages perm. Example: {client.command_prefix}purge 3")
@commands.has_permissions(manage_messages=True)
async def purge(ctx, amount:int=1):``` where
patent ivy
#

let me show you

boreal ravine
#

ok ig

drifting arrow
#

๐Ÿ˜ฎ It works!

patent ivy
#

I want it to display when I do $help

boreal ravine
#

o

drifting arrow
#

I think he wants a more fancier version

boreal ravine
#

you mean the help command and not the sub command

patent ivy
#

yes

boreal ravine
#

hmmm

#

I mean it should be there if you didn't do anything to the help command lel

patent ivy
#

good

drifting arrow
#

What's some good commands I could build? ๐Ÿค”

winged mural
#

Hello,
Has discord.py been taken over by someone else?

lost lagoon
slate swan
#

Code: ```#Unbans a User
@bot.command(description="Unbans a member")
@commands.has_guild_permissions(ban_members=True)
async def unban(ctx, *, member):
bannedUsers = await ctx.guild.bans()
name, discriminator = member.split("#")

for ban in bannedUsers:
    user = ban.user

    if(user.name, user.discriminator) == (name, discriminator):
        await ctx.guild.unban(user)
        await ctx.send(f"{user.mention} was unbanned.")
        return```**Error:** ```Traceback (most recent call last):

File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 995, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 895, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: not enough values to unpack (expected 2, got 1)```

#

it says name, discriminator = member.split("#") is the main problem

drifting arrow
#

Didnt know description worked. I've been using 'help='whatever it does'

slate swan
#

lol

maiden fable
#

Bad code

winged mural
slate swan
#

how

maiden fable
maiden fable
slate swan
#

why??

boreal ravine
slate swan
#

??

boreal ravine
#

why are people using lucas ban

slate swan
#

idk

#

I started using it a while ago

lost lagoon
slate swan
#

and it always worked

boreal ravine
maiden fable
boreal ravine
#

That sticker has a gay flag

#

so blurry though

lost lagoon
#

like i k what youre talking about

#

but i dont know how to do it

boreal ravine
#

!d discord.on_command_error

unkempt canyonBOT
#

discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
lost lagoon
#

so on the bottom

#

of the thing

#

@client.command()
@commands.has_guild_permissions(kick_members=True)
async def boot(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)
discord.on_command_error(ctx, error)

boreal ravine
#

It's an event

#
async def on_command_error(ctx, error):
lost lagoon
#

ok

#

k

#

thanks again

boreal ravine
maiden fable
lost lagoon
#

im back again sorry

#

for the perm to ban members is it ban_member

#

ban_members?

vagrant brook
#

!d discord.Member.edit

unkempt canyonBOT
#

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

Edits the memberโ€™s data.

Depending on the parameter passed, this requires different permissions listed below...
vagrant brook
#

Here you go

gloomy coral
#
@bot.command(aliases=["checkcogs"])
async def checkcog(ctx):
    if ctx.author.id == 815555652780294175 or ctx.author.id == 723032217504186389:
        if ctx.author.id == 815555652780294175:
            author = "Mr One"

        elif ctx.author.id == 723032217504186389:
            author = "Mr Zero"
            
        for filename in os.listdir('./cogs'):
            all_cogs=[]
            loaded_cogs=[]
            if filename.endswith('.py'):
                print(filename[:-3])
                all_cogs.append(filename[:-3])
                print(all_cogs)
        await ctx.send(f"Hey {author} All cogs are [{''.join(all_cogs)}]")

        for i in all_cogs:
            try:
                bot.load_extension(f"cogs.{i}")
                await ctx.send(f"{i} wasn't loaded")
                await asyncio.sleep(1)
                bot.unload_extension(f"cogs.{i}")
            except commands.ExtensionAlreadyLoaded:
                loaded_cogs.append(i)

        await ctx.send(f"Hey {author} All loaded cogs are [{''.join(loaded_cogs)}]")
    else:
        await ctx.send(embed=discord.Embed(title="Nope you imposter", description="I dont take orders from peasants like you :ZOWumpusTongue:", color=discord.Color.random()))
#

this returns

vagrant brook
#

What's wrong with that

#

It should be an instance of discord.Member

#

which points to the member you want to change nickname

#

Not the class itself

#

Here, member is your instance of discord.Member

#

But I think if you can't understand the difference between a class and it's instance then you should learn some python OOP first ๐Ÿ™‚

slate swan
#

heyg uys

#

do you know why my json file sometimes get overwritten with nothing?

#

but when i rewrite it the function works fine

heavy radish
#

Do you know how to code for the BOT to pin messages? Like i do !pin {ID}

slate swan
#

its just really annoying

maiden fable
maiden fable
slate swan
#

and r is for reading

#

which i already have

lost lagoon
#

just cleaning up my code rn

gloomy coral
#
import discord, datetime, time
from discord.ext import commands

start_time = time.time()


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

    @commands.command(name="onlinetime")
    async def uptime(self, ctx):
        current_time = time.time()
        difference = int(round(current_time - start_time))
        text = str(datetime.timedelta(seconds=difference))
        embed = discord.Embed(colour=discord.Color.random())
        embed.add_field(name="Uptime", value=text)
        embed.set_footer(text="Chad")
        try:
            await bot.send(embed=embed)
            await ctx.send(embed=discord.Embed(title=f"Chad has been online for:",description=f"{text}:zo_tick_anim:",color=discord.Color.random()))
        except discord.HTTPException:
            await bot.send("Current uptime: " + text)


def setup(bot):
    bot.add_cog(Uptime(bot))```
#

This shows

#

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'startTime' is not defined

gloomy coral
zenith flicker
#

if i have a string, is it possible to send it as a file with ```py
await send(file=discord.File("string here"))

gloomy coral
keen talon
#

!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/stable/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/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
slate nymph
#
async def id(ctx,*args):
    x = str("hello")
    if args == "Hello":
        await ctx.send(x)```
#

whats wrong with this

slate swan
#

hey i am making a verify command ,how do i set different role permissions for different channels ?

slate swan
slate nymph
#

okay

slate swan
#

and you cannot have id as function name

#

its a builtin func

slate nymph
#

but whats the difference between *args and args?

#

i ve seen people using *args

river walrus
slate nymph
#

ahh okay thanks

river walrus
#

np

#

Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message

slate swan
# river walrus `@commands.has_any_role`
@bot.command()
async def setverifychannel(message,channpel : discord.TextChannel, member =discord.Member):
  if channpel == channpel:
    await channpel.send("TYPE !verify to VERIFY")
    unverifiedrole = discord.utils.get(message.guild.roles,name= "unverified")

  if not unverifiedrole:
    unverifiedrole = await message.guild.create_role(name="unverified")
    for channel in message.guild.channels:
              await message.guild.channels.set_permissions(unverifiedrole, view_channel=False ) 
              await channpel.set_permissions(unverifiedrole, view_channel=True )```tried it this way ,its not working
heavy radish
#

You spelt Channel wrong

slate swan
#

i want the channel set by the user to have send message perms but the rest to have no send message perms

slate swan
heavy radish
#

and u add @command.has_any_role(ID, ID, ID, ID) goes after @bot.command()

#

idk

slate swan
heavy radish
#

ohh

#

idk then

slate swan
#

anyone else?

untold wharf
#

Hello, In my code i have this within my prefix command:

#

And this

#

throws an error, after the message is deleted

#

sorry for small/brad cropping

#

any reason to why this may be happening?

#

I have the embed deleted after 3 seconds, BTW. To cmd spam

#

Any help is appreciated

keen talon
#

lol

#

share full code

#

and not screenshots

#

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

untold wharf
#
@raven.command(aliases=["av"])
async def avatar(ctx, member:discord.Member = None):
    if member == None:
        selfAvatarEmbed = discord.Embed(
            color=0x483248,
            timestamp=ctx.message.created_at
        )
        selfAvatarEmbed.set_image(url=ctx.author.avatar_url)
        selfAvatarEmbed.set_footer(text="Raven")

        avEmbed = await ctx.send(embed=selfAvatarEmbed)
        await asyncio.sleep(DELTIMER)
        await avEmbed.delete()

    avatarEmbed = discord.Embed(
        color=0x483248,
        timestamp=ctx.message.created_at
    )
    avatarEmbed.set_image(url=member.avatar_url)
    avatarEmbed.set_footer(text="Raven")

    avatarEmbed = await ctx.send(embed=avatarEmbed)
    await asyncio.sleep(DELTIMER)
    await avatarEmbed.delete()```
#

I know, thanks..

keen talon
#

!d discord.Member.avatar_url

#

oh I got the error

#

the second part of function is executing even if the member is None

#

cause u didn't indent it with second condition

untold wharf
#

what

#

explain at a 10 iq level @keen talon

river walrus
#
avatarEmbed.set_image(url=member.avatar_url```
This happens regardless of member being None or not
untold wharf
#

ok nice

#

so i need to indent

untold wharf
#

still happening

untold wharf
#

i indented the avatarEmbed part

#

not the

lyric moat
#

How can i make the bot sends a message in there server as they added it?

river walrus
lyric moat
#

Like this like this

#

when they added it it sends a message in any channel it sees first

untold wharf
#

should it look like this?

river walrus
#

if member is None is better btw

#

Use that

untold wharf
#

ok

#

but is that correct?

tired olive
#
emoji = Guild.fetch_emoji("some id")
text = "Hello (emoji fetched from pervious var)"
await Channel.send(text)

How do i combine plain text with emoji?

untold wharf
#

should it look like that?

river walrus
#

I believe it should

#

Lemme look closer

tired olive
#

ah i see, thanks!

river walrus
#

Yw

river walrus
untold wharf
#

im pretty sure it does

#

also that doesnt workso

tired olive
#

yes it dows

river walrus
#

Avoid API calls as much as you can

tired olive
#

i see

#

thanks

river walrus
#

yw

untold wharf
#

yea so that doesnt work

#

so ๐Ÿ˜ฆ

unkempt canyonBOT
#

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

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

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

drifting arrow
#

I figured out what I want to make.

#

Im gonna make a reminder bot!

lyric moat
#

how i make my bot sends the prefix if someone mentioned it
i tried this and i would not work

@client.event
async def on_message(message):
  if not message.author.bot:
    if bot.user.mentioned_in(message):
        # run code here```
heavy folio
#

is it possible to have an event in a command

#

im trynna make an afk tag

slate nymph
#

how can i control my bot commands from the discord itself and not from vscode?

#

like a command for bot owner only

slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/stable/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
heavy folio
#

oh

untold token
heavy folio
#

but is it possible for an event to be in a cmd?

untold token
#

!d discord.ext.commands.is_owner

unkempt canyonBOT
#

discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
untold token
#

When you call it

#

So if it is in a command, yes you can use it

slate nymph
#

suppose i have to store a string in my bot how do i do it from discord itself?

#

like bots like dank memer store your balance

heavy radish
#

Real quick. Whats the command to only listern to one person using id? @commands.has_something()

slate swan
#

How to make discord bot use python in visual studio code?

heavy radish
#

Lol

slate nymph
lyric moat
#

How i make when you mention the bot it shows the prefix

slate swan
#

Sorry i'm newbie

slate nymph
slate nymph
#

or go to yt search discord bots using python

slate swan
#

Where the docs?

untold token
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

untold token
#

Bruh

heavy radish
#

Wow

slate swan
untold token
#

!d discord.ext.commands.when_mentioned_or

unkempt canyonBOT
#

discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
lyric moat
untold token
#

When you mention the bot, it will consider as the prefix of bot

junior ore
#

(if relevant, its discord.py rewrite) trying to play audio through my discord bot in voice

FFMPEG_OPTIONS = {
    'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
    'options': '-vn'
}
voice.play(FFmpegPCMAudio('https://www.youtube.com/watch?v=dQw4w9WgXcQ', **FFMPEG_OPTIONS, executable='C:\\FFMPEG'))

im running it through pycharm in a venv and getting Permission Error: [WinError 5] Access is denied

the error is pretty nondescript so i dont know why im being blocked from doing this, all i know is that it is coming from the above line.. does anyone know a possible fix for this? i have tried running the script as an administrator, it still doesnt work. (also, i know pretty much nothing about ffmpeg, i got the options and what not from a stack overflow thread, so if the error is related to those please direct me to the correct values)

untold token
#

you don't want you bot to send messages when it mentioned in sentences

#

Like
This is our @bot

slate swan
untold token
#

^

#

As it mentions the bot in message too

untold token
slate swan
#

you can use when_mentioned_or("prefix") , as ! a told

and then you may have a command named prefix or something

when a user uses @yourbotmention prefix , it sends the prefix

untold token
#

Hmm

slate swan
#

its detailed , and better than yt vids

heavy radish
#

Guys, where can I find all the types of restrictions for commands??

slate nymph
#

whats the difference between args and *args?

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโ€™s robots.txt file; (b) with YouTubeโ€™s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
slate nymph
#

args is an argument right?

slate swan
slate swan
untold token
slate nymph
#

so like i wanted to make a command named "store" which will store users data or args as a variable variable will be named by the user itself

#

and that variable can further be used by the developer

heavy radish
slate swan
heavy radish
#

Perfect

slate swan
#

for a user , if its not the bot owner , use a customcheck

heavy radish
#

hm

#

for the id do i use 'ID'

slate swan
#

int

lyric moat
#

cooldown error

@help.error
async def help_error(self, ctx: commands.Context, error):
        if isinstance(error, commands.CommandOnCooldown):
            await ctx.send(f"This command is on cooldown, try again after {round(error.retry_after)} seconds.", delete_after=5)
        print(error)```
lyric moat
#

yeah not cog

#

remove self?

woeful fable
#

hi, what kinds of message.content.something can i use?

little ether
woeful fable
#

hmmmm so its a python thing not a discord exclusive thing

slate swan
heavy radish
#
@bot.event
@commands.has_role('Giveaway Boat')
async def on_message(message):
  if message.author == bot.user:
    return

  if message.content.startswith('Congratulations to'):
    await message.channel.send(f'`RPG Miniboss {message.content.split("Congratulations to ")[1]}`')
#

It listens to everyone

#

Like if anyone says 'Congratulations to' it replies

#

Yes

#

But it listens to everyone

#

I want it only to read from a certain user/bot

#

Can't we?

vocal terrace
#

sup, can somebody help me creating a file py with a print encrypted to people get the ASCII when turns bot on but like a dependecy, so they cannot delete that file

heavy radish
#

Ok, how do I channel restrict it?

#

yes

#

where do i add this

#

Swap for message.author == bot.user

#

Oh

#

then how

#
@bot.event
@commands.has_role('Giveaway Boat')
async def on_message(message):
  if message.author == bot.user:
    return
if message.channel == 123

  if message.content.startswith('Congratulations to'):
    await message.channel.send(f'`RPG Miniboss {message.content.split("Congratulations to ")[1]}`')
#

Like that, obv change 123

#

I will

drifting arrow
#
@commands.command(help='[sends the list of reminders from author.]')
async def reminderlist(self, ctx):
      authorid = ctx.author.id
      await ctx.send(f'Author id is: {authorid}')
      await ctx.send(f'that has a type of: {type(authorid)}')
      for row in self.cur.execute("SELECT * FROM reminder WHERE memberid='?'", authorid):
            print(row)

what am I doing wrong? error: parameters are of unsupported type D:

heavy radish
#

is this for me

#

oh okay

vocal terrace
#

sup, can somebody help me creating a file py with a print encrypted to people get the ASCII when turns bot on but like a dependecy, so they cannot delete that file

heavy radish
#

Will do once i get back

#

Thank you

spring flax
#

why if.?

slate nymph
#

why isnt lower() defined when scripting a bot?

slate swan
#

it is

slate nymph
heavy radish
#

@tawdry perch

#

I think I messed up

#
@bot.event
async def on_message(message):
  if message.author == bot.user:
    return
    if message.channel == 885810026613186590(message.content.startswith('Congratulations to'):
    await message.channel.send(f'`RPG Miniboss {message.content.split("Congratulations to ")[1]}`')):
upbeat otter
#

like

#

what are u trying to do

#

if u are trying to pass two values as true, u need to put and between them too

slate swan
upbeat otter
heavy radish
#
@bot.event
async def on_message(message):
  if message.author == bot.user:
    return
    if message.channel == 885810026613186590 and message.content.startswith('Congratulations to'):
    await message.channel.send(f'`RPG Miniboss {message.content.split("Congratulations to ")[1]}`'):
upbeat otter
#

yeah

slate swan
heavy radish
#

Whaat

slate nymph
#

also why cant i use 2 variables inside a function

slate swan
#

you can

heavy radish
#
@bot.event
async def on_message(message):
  if message.author == bot.user:
    return
    if message.channel.id == 885810026613186590 and message.content.startswith('Congratulations to'):
    await message.channel.send(f'`RPG Miniboss {message.content.split("Congratulations to ")[1]}`'):
``` Check now Sarthak and Black Goku
upbeat otter
heavy radish
#

Hm

slate swan
#

unindent the second if

upbeat otter
heavy radish
#

i'm using bot everywhere else

slate nymph
#

no

heavy radish
#

Indented

boreal ravine
slate nymph
#

i cant use 2 variables

#

like

heavy radish
#

Now I have a swiggle after the : last line

upbeat otter
#

bro, dont use the name id, its a keyword

boreal ravine
#

u cant have 2 variables with the same name

slate nymph
#

we can

#

it just changes the value of x

slate swan
#

yes

#

so what issue do you face doing it?

upbeat otter
#

whats the error

velvet mason
#

Hello! I want my bot to block all links without allowed. I was writted code but it doesn't work. The bot receive only allowed links without sub links by same website. How ca I fix this ?

   if message.content not in allowed_links:
       await message.delete()```
slate nymph
#

i cant assign more than 1 one variable inside def

slate swan
#

you can

#

?

slate nymph
#

how?

#

i cant i swear

slate swan
#

just like you do normally

#

x = 10
y = 15

slate nymph
upbeat otter
slate swan
#

issue is with your function name

#

you cannot name a function as id

upbeat otter
slate swan
#

yep

upbeat otter
#

id is a keyword for discord.utils

slate nymph
slate swan
#

!e py def id(): print(1) id()

heavy radish
#

@slate swan & @upbeat otter

reef shell
#

Colon where

slate nymph
#

ok then

#

i ll rename my command

slate swan
upbeat otter
slate nymph
#

i ll just remove id from commands

slate swan
heavy radish
#

Error gone. We shall see

slate swan
upbeat otter
heavy radish
#

Logged in

slate swan
#

and bot.command() has a name kwarg

#

same outcome

velvet mason
heavy radish
#

Doesn't work

slate swan
#

do you know what return does?

slate nymph
#

thats right something was wrong with my function

upbeat otter
upbeat otter
upbeat otter
heavy radish
slate swan
#

bruh

#

it returns from the function

slate nymph
#

thanks mate!

upbeat otter
slate swan
#

anything after return doesn't get triggered

upbeat otter
heavy radish
#

What do i do?

slate swan
#

!e

def func():
    return "hello" 
    print("nice") 

func() 
unkempt canyonBOT
#

@slate swan :warning: Your eval job has completed with return code 0.

[No output]
heavy radish
#
@bot.event
async def on_message(message):
  if message.author == bot.user:
    return

  if message.channel.id == 885810026613186590 and message.content.startswith('Congratulations to'):
      await message.channel.send(f'`RPG Miniboss {message.content.split("Congratulations to ")[1]}`')
upbeat otter
#

of your code

heavy radish
#

I intended it

upbeat otter
heavy radish
#

ye ye

upbeat otter
heavy radish
#

No error

#

This looks wrong

boreal ravine
heavy radish
#

which one

boreal ravine
#

the if statement

slate swan
boreal ravine
#

you should know lol

slate swan
#

whatchu doing

#

it just seems... crappy

#

becauss of the await

#

but it works

mortal thistle
#

can someone help me with a SQL Database?

heavy radish
#

Does this look good?

slate swan
#

unindent the await by a half

heavy radish
#

Ahh, works...

heavy radish
upbeat otter
upbeat otter
slate swan
#

but I like the idea of this....

#

๐Ÿค”

heavy radish
#

The thing is

#

Other commands don't work

#

Lol

#

Doesnt matter

slate swan
#

it does

heavy radish
#

Its a test BOT

slate swan
#

replace
@bot.event
with
@bot.listen()

heavy radish
#

ok

slate swan
#

or put bot.process_commands(message)

#

at the end where it still gets triggered

#

How to host bot 24/7 free? Use repl.it

heavy radish
#

Thank You! Works

slate swan
#

Use repl.it

heavy radish
#

BTW, What should I use to code/host? Like when I make it public

slate swan
#

I need free bot hosting

#

!vps

#

nop

slate swan
heavy radish
#

I currently use Repl.it and UpTimeRobot

#

What should I use?

slate swan
#

Imma search the pinned message for this

heavy radish
#

I'll DM the code

stark bobcat
#

why can't i do this

heavy radish
#

hOLY

stark bobcat
slate swan
#

!d discord.TextChannel.mention

unkempt canyonBOT
stark bobcat
slate swan
#

don't call it

#

my bad

slate swan
#

and don't put brackets

#

my bad

stark bobcat
slate swan
#

@slate swan @heavy radish

heavy radish
#

yES

slate swan
#

found the most efficient way to tell you

slate nymph
#

why is lower() not defined in vscode?

heavy radish
#

Where do I do the coding?

slate swan
#

str.lower()

#

not just lower...

slate swan
heavy radish
#

Wdym?

slate swan
#

the code stays the same

slate nymph
#

oh k thanks

heavy radish
#

Ye but where do I do it

#

U can't host from VSC

slate swan
#

anywhere you'd like, what's comfortable for you

#

you can't host a bot with an IDE

heavy radish
#

What are some options?

#

To code

#

and run

slate swan
#

VSCode, PyCharm

#

can't run on an IDE

#

still

heavy radish
#

IDE?

slate swan
#

where you edit the code

#

it's not for running

stark bobcat
#

@slate swan does not work

slate swan
stark bobcat
#
embed = discord.Embed(title="Setup",description=f"Created a private channel called {channel.mention'mailer-logs'} in Mailer category, use ``-accessrole[roles]`` give staff access to the channel.",color=0x1793FC)
        await ctx.send(embed=embed)```
slate swan
#

channel.mention

#

without the mailer logs

heavy radish
stark bobcat
slate swan
#

probably

stark bobcat
#

but i want to mention mailer-logs

slate swan
#

your channel should be saved in the channel variable

woeful fable
#

how do i do this

stark bobcat
#

ohh

#

got it

slate swan
woeful fable
#

um

slate swan
stark bobcat
#

@slate swan so like channel='mailer-logs'?

slate swan
#

channel = bot.get_channel(id)

#

or ctx.channel

#

message.channel

stark bobcat
slate swan
stark bobcat
#

ok

#

thanks

river walrus
slate swan
#

guys

#

how would i get a list of commands from a specific cog

woeful fable
river walrus
woeful fable
river walrus
#

This is simple Python syntax

#

Missing : obv

woeful fable
#

ummmm

slate swan
#

f

#

!d discord.ext.commands.Cog.get_commands

unkempt canyonBOT
slate swan
#

genius

woeful fable
river walrus
slate swan
#

indeed

#

I'm not sure if me dumb saw my response

#

do I ping him?

#

ping on reply is in his name

#

@slate swan

#

sup

slate swan
#

yeah it was my librarys fault i just found it out

#

oh

#

nice

#

maybe theyd have to update their func to get slash commands also lol

#

what a serverinfo code for Bot i mean i want the number of bots in that server ducky_angel

#

idk can u help me

maiden fable
#

?

#

I mean, from where u got it?

heavy radish
#

Pardon?

#

Whats the difference between VPS and PebbleHost

ionic wadi
#

Does anyone have a form for a good explanation of using and working with JSON?

#

Mostly about read json

slate swan
#

well, technically...

#

meh

#

he asked about what's good for a discord bot

slate swan
#

still

#

hosting a discord bot is kinda connected to developing a discord bot

slate swan
#

Check it

#

a helper here has once announced that he made a discord bot host

#

I think it's free

#

tho I don't remember what it was

maiden fable
slate swan
#

lmao

#

well heroku is not so bad with a base payment

dawn gale
#

how do i make a bot tell me who is online on a minecrft server

slate swan
#

for free? nah

maiden fable
heavy radish
lament mesa
maiden fable
maiden fable
slate swan
#

free heroku is actually good but only if your bot is a private bot only for your server

dawn gale
#

idk how to code

maiden fable
slate swan
#

How to make simple commands?

heavy radish
#

What should I host on? Like I don't want to keep code on my PC. Everyone on the web. Tell me a recommendation

slate swan
#

somebody link the dpy guide

dawn gale
#

make rock paper scissors @slate swan

slate swan
#

for alexzy

lament mesa
dawn gale
#

i havent read the document yet

#

i probably should

slate swan
#

Commands in The document not 100% working

#

then you surely did something

#

can you share what you did?

#

I'm sorry if my English is bad because I use chat translator

#

oof

#

it works fine till now