#discord-bots

1 messages · Page 701 of 1

shrewd inlet
#

so how

sick birch
#

await ctx.send("message")

shrewd inlet
#

OH

#

await

sick birch
#

ye

#

and pass in the embed kwarg

quick gust
#

await ctx.send(embed=your_embed)

sick birch
#

along with the embed object

#

yep been a while since i did discord.py bot development so my knowledge is quite rusty haha

shrewd inlet
#

THANK U

sick birch
#

i find myself referring back to the docs for menial things i knew off the top of my head before xD

sick birch
#

been getting out of my comfort zone with javascript bots a bit, mostly javascript frontend frameworks though

slate swan
#

That's nice

sick birch
#

yep though i've done discord.py for almost 2 years before so i keep coming back here to help haha

slate swan
#

I mostly do dpy but i think i hit a block i havent learned as much as i did and i want to do complicated stuff but idk what mostly trying to learn about dbs but i havent gone the excitement/passion for it

sick birch
#

yeah i feel you i used to get like that too, i take a break and i come back a few weeks later fresh with ideas, always seemed to help me

slate swan
sick birch
#

can't believe that was almost 2 years ago haha

slate swan
#

Ive grown allot of knowledge about oop and asynchronous programming and with dpy i still remember 9 months ago i didnt even knew what was a coro

#

Or a kwarg

sick birch
#

that's one of the best feelings, looking back and remembering how much you've grown as a developer

slate swan
#

Yeah

sick birch
#

maybe in another year you'll look back at yourself right now and think the same thing

slate swan
#

Hope so

#

When i was starting python i always went to these channels

sick birch
#

interactive help channels are probably one of the best ways to grow and learn new things, yeah

slate swan
#

And ill always see people like andy,kayle,robin,hunter,infernum and much others that really had allot of knowledge and it was intimidating but it gaved me passion to be like them and now ive grown in knowledge about the topic and i mostly help others here with you guys but i still like seeing you guys talk about topics i have 0 knowledge about it really makes me excited to see that i can learn more

sick birch
slate swan
#

Mostly learn python because of my future and because i love programming by itself but i always come here because theres allot of knowledgeable people here but helping others and making there day is good to always makes me happy

sick birch
#

for sure, i gotta say helping people and interacting with others here is always the better part of my day :P

shrewd inlet
#

i appreciate everyone who helps others :)

sick birch
#

That makes it much easier for us to give help, though not everyone goes by that philosophy D:

slate swan
slate swan
#

@sick birch this is probably ot but i enjoyed the talk we had and merry Christmas

#

Sorry for the ping.

sick birch
#

You too! Unfortunately it's almost 1 am for me and i'm off to bed, good day/night wherever you are :D

slate swan
shrewd inlet
#

is there any way to have aliases for commands

#

like if i have ;image but also wanna have it be ;img

slate swan
#

Yes

@bot.command(aliases=["",""])
shrewd inlet
#

ty

slate swan
#

Yw

#

Can anybody explain what this does i cant quite rap it around my head

class MyButton(disnake.ui.View):

     def __init__(self, author: disnake.Member):
        self.author = author
        super().__init__()
    
     # your code

@bot.slash_command()
async def button(inter: disnake.AppCmdInt):
  view = MyButton(inter.author)
  await inter.response.send_message("hi", view=view) 

mostly how
inter.author
Works with the class

#

Other stuff i get it

outer violet
arctic gyro
#
@bot.command()
@commands.has_permissions(ban_members=True)
async def mute(ctx,member: disnake.Member,time=None,*,reason=None):
  if reason == None:
    reason = 'Quiet! '
  await member.timeout(duration=time,reason=reason)
  await ctx.channel.send(f'member has been muted')```

Hi ! is this timeout code correct?
slate swan
arctic gyro
slate swan
#

So it would be

time:float = None
arctic gyro
#

but umm ..

torn sail
#

Could you show the message that you sent the command with?

#

Cause it’s not converting the member

slate swan
#

Weird

arctic gyro
torn sail
#

Huh I don’t see anything wrong

arctic gyro
#

same

slate swan
#

Thats weird i dont see an issue

arctic gyro
#

I have installed disnake 2.3.0

#

thats fine right?

torn sail
#

I’ve never used disnake

#

So idk

arctic gyro
#

oh alr

#

im gonna try to install a different one

#

lets see if that works

#

anyone thanks a lot everyone for your help

slate swan
arctic gyro
#

ohh

#

then idk whats wrong

#

: (

torn sail
#

Maybe cause mention has spaces in it so it separates it?

#

Try quotes around mentions. If not that then idk

arctic gyro
torn sail
arctic gyro
#

Wait it worked

#

thx a lott

slate swan
torn sail
arctic gyro
#

yeah

slate swan
#

Ic

arctic gyro
#

Ig it wasnt cuz of spaces

#

I just changed my disnake to discord-disnake and it worked

#

I added back the space and its still working

torn sail
#

Yeah probably wasn’t cause spaces because I think a ping is really only <@id> (one word) even when the name is many words

arctic gyro
slate swan
small igloo
#

helo
ok, so why my SBtext says no module eventhough i aready pip install that module (in different file folder tho) and when i try pip install that module again, CMD says that it's already satisfied

slate swan
boreal ravine
#

just tell me what you dont understand about it

quick gust
#

is that what you're asking

slate swan
#
     def __init__(self, author: disnake.Member):
        self.author = author
        super().__init__()

And

  view = MyButton(inter.author)
#

Just that

slate swan
quick gust
#

still don't understand wym

boreal ravine
#

^^

slate swan
#

Just what this does

  view = MyButton(inter.author) 
quick gust
#

passing the interaction author ig?

slate swan
#

Yes

slate swan
#

Something like that

quick gust
#

yeah

slate swan
#

How does it pass the interaction author?

quick gust
#

What.

#

u have an arg inter here, the author of that interaction is the member passed

slate swan
#

How does it pass a member?

boreal ravine
#

@slate swan read your class

slate swan
#

Sorry its 3am im having a brainfart

boreal ravine
#

you passed in a parameter next to self

quick gust
#

u have author : disnake.Member

boreal ravine
#

that allows you to pass in arguments to the class

slate swan
#

Yes but how does it know what member to pass

#

Is what im saying

boreal ravine
quick gust
#

...

slate swan
# boreal ravine what give more context

Okay so inter is interaction and author is a member obj so how does

MyButton(inter.author)

Work
im viewing a class and what else is exactly what im not getting

boreal ravine
slate swan
boreal ravine
#

hm ok

boreal ravine
#

👌

slate swan
#

Because yes author is a member obj but how does inter get the interaction author if interaction is typehinted as a interaction?

placid skiff
#

Are you talkin about application commands?

slate swan
#

Correct

small igloo
steady phoenix
#

I'm attempting to add a message that sends when a new user joins. I have been able to get the message to send in a embed and now I would like for the bot to grab the pfp of the new member and add it to the embed. ```PY

@client.event
async def on_member_join(member):
channel = client.get_channel(854988021711896586)
await channel.send(
embed=discord.Embed(
colour = (discord.Colour.green()),
Title = "welcome",
description = f'Welcome {member.mention}, enjoy your stay!',)

)```
Here is the code

placid skiff
# slate swan Correct

So usually with a bot, when someone cast a command, the context of the command is the message that the user sent, instead, with an application bot, the context cannot be the message of the user cuz it will interact directly with the bot so instead that interaction is the context of the command, from that interaction you can retrieve the application command of the user

slate swan
placid skiff
#

no no the ApplicationInteraction can retrieve all the data of the command, i will send you the part of code where the data are retrieved in disnake

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.
upbeat otter
#

!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.
placid skiff
#
    def __init__(
        self,
        *,
        data: ApplicationCommandInteractionDataPayload,
        state: ConnectionState,
        guild: Optional[Guild],
    ):
        self.id: int = int(data["id"])
        self.name: str = data["name"]
        self.type: ApplicationCommandType = try_enum(ApplicationCommandType, data.get("type"))
        self.resolved = ApplicationCommandInteractionDataResolved(
            data=data.get("resolved", {}), state=state, guild=guild
        )
        target_id = data.get("target_id")
        self.target_id: Optional[int] = None if target_id is None else int(target_id)
        self.target: Optional[Union[User, Member, Message]] = self.resolved.get(self.target_id)  # type: ignore
        self.options: List[ApplicationCommandInteractionDataOption] = [
            ApplicationCommandInteractionDataOption(data=d, resolved=self.resolved)
            for d in data.get("options", [])
        ]

This is the init function of ApplicationCommandInteractionData in disnake

upbeat otter
#

use the, member.avatar_url or member.avatar.url to retrieve the pfp

slate swan
steady phoenix
upbeat otter
#

you are probably getting an error due to a parantheses

steady phoenix
#

I am Im just confused on where to place it

upbeat otter
steady phoenix
placid skiff
#

keep_alive() is nothing... it is not a function and is not a builtin python function

steady phoenix
#

I think I also forgot to add embed.set_image

steady phoenix
#

And if I delete it it just brings up the same error with client.run\

upbeat otter
serene lynx
#
@commands.command()
    async def daftar(self, ctx):
        await ctx.send(f"masukkan username")
        def check1(msg):
            return msg.author == ctx.author and msg.channel == ctx.channel
        user_choice_username = (await self.bot.wait_for('message', check=check1)).content
        await ctx.send(f"masukkan game id")
        def check2(msg):
            return msg.author == ctx.author and msg.channel == ctx.channel
        user_choice_game_id = (await self.bot.wait_for('message', check=check2)).content
        await ctx.send(f"masukkan role")
        def check3(msg):
            return msg.author == ctx.author and msg.channel == ctx.channel
        user_choice_role = (await self.bot.wait_for('message', check=check3)).content
        await ctx.send(f"masukkan gambar")
        def check4(msg):
            return msg.author == ctx.author and msg.channel == ctx.channel
        user_choice_url = await self.bot.wait_for('message', check=check4)
        if user_choice_url.content.attachments:
            file = user_choice_url.attachments
            print(file.url)```
#

how to check if user input attachment or no?

steady phoenix
upbeat otter
placid skiff
serene lynx
# serene lynx how to check if user input attachment or no?
Traceback (most recent call last):
  File "d:\dittttbotbeta\.env\lib\site-packages\discord\ext\commands\core.py", line 88, in wrapped
    ret = await coro(*args, **kwargs)
  File "d:\dittttbotbeta\data\mlbb.py", line 63, in daftar
    if user_choice_url.content.attachments:
AttributeError: 'str' object has no attribute 'attachments'```
visual island
steady phoenix
steady phoenix
placid skiff
serene lynx
steady phoenix
upbeat otter
placid skiff
# steady phoenix Yes its right there

You have to remove them lol
the enviromenth variables are saved like in a file, the os.getenv function read from that file so it will convert atuomatically that to string

#

essentially you are send your token like "your_token"

upbeat otter
steady phoenix
#

The token is not the problem

placid skiff
upbeat otter
steady phoenix
placid skiff
steady phoenix
upbeat otter
upbeat otter
steady phoenix
upbeat otter
#

;-;

steady phoenix
#

nvm

upbeat otter
#

thats what I said first

steady phoenix
#

No like nvm thats not the issue

#

Or the placement might be

upbeat otter
#

oh lol, send an ss again

#

latest

#

code

steady phoenix
#

Wait am I supposed to do await channel.send():

upbeat otter
steady phoenix
sour lodge
#

no?

upbeat otter
sour lodge
#

Also why is it inside the send

steady phoenix
sour lodge
#

It’s not suppose to be inside

steady phoenix
upbeat otter
steady phoenix
#

Ok

placid skiff
#

It is a good use to first create the embed and then send it

upbeat otter
#

good practice

placid skiff
#

essentially there you are creating an embed and then call that embed but it is not created yet lol

steady phoenix
#

Ah lol

#

So what should I put inside the send() because other wise it creates errors

#

The embed is now above the send

steady phoenix
upbeat otter
#

;-;

quick gust
#

the send method takes in an embed kwarg so, .send(embed=embed)

quick gust
upbeat otter
#

!d discord.TextChannel.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
placid skiff
#

should be like this:

embed = Embed(title="abc", description="abc", colour=(255,255,255)
embed.set_thumbnail(url=ctx.author.image_url)
await ctx.send(embed=embed)
upbeat otter
#

dont spoonfeed

placid skiff
#

lol we were confusing him bro

upbeat otter
#

bro

steady phoenix
#

Thanks for the help

placid skiff
quick gust
upbeat otter
#

..........

steady phoenix
#

@upbeat otter My apologizes for pinging you directly but is there a way to position the picture in the embed? currently it is right aligned but I'm trying to get it center aligned on the next line

maiden fable
#

@steady phoenix u can't align pics

upbeat otter
#

Thanku

#

You can use .set_image tho

maiden fable
steady phoenix
maiden fable
#

set image then

#

Or use the description

steady phoenix
#

Ok

obsidian ledge
#

how do i make a pin command where if i send the command on a replied message it pins it?

unkempt canyonBOT
#

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

Pins the message.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to do this in a non-private channel context.
obsidian ledge
#

alr

thin kelp
#

is there a way to check if a user is present in a guild?

#

I have the user's id and the guild's id

boreal ravine
#

you could check if the member is in the guild discord.Guild.members returns a list of member objects

unkempt canyonBOT
thin kelp
#

ok

boreal ravine
#

iterate through what

quick gust
#

no need

sour lodge
#

is it possible to get disnake on repl

minor ether
#

i gave my mute command permissions

#

yet it says i dont have those perms

obsidian ledge
#

whats moderate_members

#

i dont think thats a permission name on discord..?

tawdry perch
#

It is

minor ether
obsidian ledge
#

oh

tawdry perch
#

It came just a while ago when timeout arrived

minor ether
#

came along with timeout

#

and no i checked it on the api reference of the rewrite i use its there

velvet tinsel
slate swan
#

😳 imagine libraries forcing users to use python 3.9+ , rip replit users

hoary cargo
#

Is there any documentation from discord of how to implement your bot into your website? Iike yk having a website displaying bot's guild conter and such

velvet tinsel
boreal ravine
sour lodge
#

Alright thanks

placid skiff
#

There is a check which tells me if the user who cast a command is the bot owner? or I have to check it manually?

boreal ravine
slate swan
slate swan
#

!d discord.ext.commands.is_owner

unkempt canyonBOT
#

@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/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/master/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/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
placid skiff
#

thx

silver iris
#

Anyone good with cogs

river kindle
#

what

boreal ravine
silver iris
#

My discord bot is gonna be quite lengthy and gonna need a fair amount of scripts 😂

boreal ravine
#

why not make it yourself though

echo heart
#
@client.event
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message == 923516305322176592 :
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)

        if payload.emoji.name == 'boy':
            role = discord.utils.get(guild.roles, name='boy')
        elif payload.emoji.name == 'girl':
            role = discord.utils.get(guild.roles, name='girl')
        else:
            role = discord.utils.get(guild.roles, name=payload.emoji.name)
        
        if role is not None:
            member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
            if member is not None:
                await member.add_roles(role)
                print("added")
            else:
                print("Member not found")
        else:
            print("Role not found")```
#

why is this not giving roles? what am I doing wrong ?

river kindle
#

I am creating an advanced write command, that is, when the user writes "!write everyone" the bot does not send the message and gives a reply.
I tried to do this, there are no errors, but it doesn't work anyway

code:

async def write (ctx, *, arg, content, allowed_mentions):
    await ctx.send (arg)
    allow_mentions = discord.AllowedMentions(everyone = False)
    await ctx.send(content, allow_mentions = allowed_mentions)```
echo heart
boreal ravine
sullen shoal
silver iris
boreal ravine
sullen shoal
dapper cobalt
boreal ravine
dapper cobalt
silver iris
# boreal ravine ask away then

I need to make it so my web scraping script is on a separate file that my bot can read from I will grab an example in a second just eating rn

ashen locust
#

i made a meme command and used reddit praw for it
it works but it takes like 20 seconds
is there a way to fix that?

echo heart
#

how do I get the user who reacted to my message ?

unkempt canyonBOT
#

Async PRAW, an abbreviation for `Asynchronous Python Reddit API Wrapper`, is a python package that allows for simple access to reddit's API.

ashen locust
#

thank u

dapper cobalt
sullen shoal
#

!d discord.Reaction.users

unkempt canyonBOT
#

async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.

The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

Examples

Usage

```py
# I do not actually recommend doing this.
async for user in reaction.users():
    await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
sullen shoal
#

multiple users can react to one reaction so

dapper cobalt
#

The user kwarg represents a discord.Member/discord.User whom interacted.

dapper cobalt
# unkempt canyon

That returns an array, I believe what they want is only the user who reacted.

sullen shoal
#

it returns an array of people who reacted

river kindle
boreal ravine
#

the allowed_mentions parameter

river kindle
#

oh

river kindle
sullen shoal
boreal ravine
upbeat otter
#

thats what they meant

sullen shoal
#

it eats all the arguments in discordpy and normally it eats all the positional ones

boreal ravine
#

in dpy only

river kindle
# sullen shoal space?

yes because otherwise I can not write for example: hello how are you
I can't use spaces

sullen shoal
#

after consuming every thing

#

you gotta do,
(arg, allowed_mentions, *, content)

#

i gotta go afk

river kindle
#

k ty

drifting tulip
#

object 'datetime.datetime' has no atribute delta?

boreal ravine
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

['__add__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', 'astimezone', 'combine', 'ctime', 'date', 'day', 'dst', 'fold', 'fromisocalendar', 'fromisoformat', 'fromordinal', 'fromtimestamp', 'hour', 'isocalendar', 'isoformat', 'isoweekday', 'max', 'microsecond', 'min', 'minute', 'month', 'now', 'replace', 'resolution', 'second', 'strftime', 'strptime', 'time', 'timestamp', 'timetuple', 'timetz', 'today', 'toordinal', 'tzinfo', 'tzname', 'utcfromtimestamp', 'utcnow', 'utcoffset', 'utctimetuple', 'weekday', 'year']
boreal ravine
#

you probably meant something elsw

#

!e
import datetime
print(dir(datetime))

unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

['MAXYEAR', 'MINYEAR', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'date', 'datetime', 'datetime_CAPI', 'sys', 'time', 'timedelta', 'timezone', 'tzinfo']
boreal ravine
hoary cargo
dapper cobalt
boreal ravine
#

!pypi discord-ext-ipc

unkempt canyonBOT
boreal ravine
#

that?

placid skiff
#

How to handle errors from custom checks?

stark geyser
#

how can i fix this ?

dire folio
placid skiff
dire folio
#

I have no clue what you mean

slate swan
maiden fable
slate swan
tawdry perch
slate swan
#

or you can raise your own error

maiden fable
#

!d discord.ext.commands.CheckFailure

unkempt canyonBOT
#

exception discord.ext.commands.CheckFailure(message=None, *args)```
Exception raised when the predicates in [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks") have failed.

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

^

maiden fable
#

Use this

stark geyser
velvet tinsel
# dire folio An error handler?

an error handler is something that handles discord errors, because normal try/except statements won't catch the errors. You would have to make a error handler, for example,

@my_command.error
async def error(ctx, error: commands.CommandError):
  if isinstance(...):
    # code...

if you do try/except it would ignore it and instead raise the same error. It happened to me when I was making a cooldown command.

However, for normal errors you can use a try/except.

tawdry perch
velvet tinsel
#

I only put ctx there if you wanted to send something

velvet tinsel
tawdry perch
#

You can't use discord.Client for commands

velvet tinsel
#

bot = commands.Bot(command_prefix=None ...) (don't put None for command_prefix it was only an example)

stark geyser
#

import discord
from discord import client
from discord.ext import commands

class Commands(commands.Cog):
def init(self, client):
self.client = client

@client.command()
async def ping(ctx):
await ctx.send(f'Your ping is {round(client.latency * 1000)}ms')

@client.command()
async def server(ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)

owner = str(ctx.guild.owner)
id = str(ctx.guild.id)
region = str(ctx.guild.region)
memberCount = str(ctx.guild.member_count)

icon = str(ctx.guild.icon_url)

embed = discord.Embed(title=name + " Server Information",
                      description=description,
                      color=discord.Color.blue())
embed.set_thumbnail(url=icon)
embed.add_field(name="Owner", value=owner, inline=True)
embed.add_field(name="Server ID", value=id, inline=True)
embed.add_field(name="Region", value=region, inline=True)
embed.add_field(name="Member Count", value=memberCount, inline=True)

await ctx.send(embed=embed)

def setup(client):
client.add_cog(Commands(client))

velvet tinsel
#

*you don't have to use it, my mistake

stark geyser
#

thats the 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.

slate swan
# stark geyser thats the code

try:

import discord
from discord import Client
from discord.ext import commands


class Commands(commands.Cog):
  def init(self, client):
      self.client = Client 

  @client.command()
  async def ping(ctx):
    await ctx.send(f'Your ping is {round(client.latency * 1000)}ms')


  @client.command()
  async def server(ctx):
    name = str(ctx.guild.name)
    description = str(ctx.guild.description)

    owner = str(ctx.guild.owner)
    id = str(ctx.guild.id)
    region = str(ctx.guild.region)
    memberCount = str(ctx.guild.member_count)

    icon = str(ctx.guild.icon_url)

    embed = discord.Embed(title=name + " Server Information",
                          description=description,
                          color=discord.Color.blue())
    embed.set_thumbnail(url=icon)
    embed.add_field(name="Owner", value=owner, inline=True)
    embed.add_field(name="Server ID", value=id, inline=True)
    embed.add_field(name="Region", value=region, inline=True)
    embed.add_field(name="Member Count", value=memberCount, inline=True)

    await ctx.send(embed=embed)


def setup(client):
    client.add_cog(Commands(client))
velvet tinsel
#

try removing from discord import client or do what excelgames said, from discord import Client (notice the capital C)

#

also if you're removing import Client then add a commands.bot

tawdry perch
#

But client will not work for commands, right?

velvet tinsel
#

client = discord.Client()

#

however I would use commands.Bot()

#

plus client isn't a good name, use bot instead

velvet tinsel
#

instead of name + "server information"

slate swan
#

I know

meager fractal
#

can someone help me acheive embeds like img1
ive tried and failed as in img2 the width of the embeds are not same

velvet tinsel
#

f"{name} + Server Information" (I know you know I was talking to unknown)

stark geyser
#

i have 2 sets of code 1 for the normal commands and then the 1 for music then combining them together if that could be problem

meager fractal
velvet tinsel
#

really?

seems like a perk of djs

#

however you can just add an image

#

!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.
slate swan
velvet tinsel
slate swan
meager fractal
velvet tinsel
#

!d discord.ext.commands.Bot || please work

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
velvet tinsel
#

LET'S GOO!!

maiden fable
#

what y'all even doing

velvet tinsel
#

hurrr

discord bot stuff

#

morning hunter!

maiden fable
#

Hi

velvet tinsel
#

anyways command_prefix, and stuff are all kwargs

maiden fable
#

No

slate swan
#

@stark geyser If it's a cog, try this:

import discord
from discord import Client
from discord.ext import commands


class Commands(commands.Cog):
  def init(self, client):
      self.client = Client 

  @commands.command()
  async def ping(ctx):
    await ctx.send(f'Your ping is {round(client.latency * 1000)}ms')


  @commands.command()
  async def server(ctx):
    name = str(ctx.guild.name)
    description = str(ctx.guild.description)

    owner = str(ctx.guild.owner)
    id = str(ctx.guild.id)
    region = str(ctx.guild.region)
    memberCount = str(ctx.guild.member_count)

    icon = str(ctx.guild.icon_url)

    embed = discord.Embed(title=name + " Server Information",
                          description=description,
                          color=discord.Color.blue())
    embed.set_thumbnail(url=icon)
    embed.add_field(name="Owner", value=owner, inline=True)
    embed.add_field(name="Server ID", value=id, inline=True)
    embed.add_field(name="Region", value=region, inline=True)
    embed.add_field(name="Member Count", value=memberCount, inline=True)

    await ctx.send(embed=embed)


def setup(client):
    client.add_cog(Commands(client))
velvet tinsel
#

if you want to remove a help command do help_command=None

#

and the other one I forgot

velvet tinsel
#

commands.Bot() isn't a nightmare

stark geyser
#

the bot works but the command isnt recognised now

meager fractal
slate swan
velvet tinsel
slate swan
#

@stark geyser try this:

import discord
from discord import Client
from discord.ext import commands


class Commands(commands.Cog):
    def init(self, client):
        self.client = Client 

    @commands.command()
    async def ping(self, ctx):
        await ctx.send(f'Your ping is {round(self.client.latency * 1000)}ms')


    @commands.command()
    async def server(self, ctx):
        name = str(ctx.guild.name)
        description = str(ctx.guild.description)

        owner = str(ctx.guild.owner)
        id = str(ctx.guild.id)
        region = str(ctx.guild.region)
        memberCount = str(ctx.guild.member_count)

        icon = str(ctx.guild.icon_url)

        embed = discord.Embed(title=f"{name} Server Information",
                            description=description,
                            color=discord.Color.blue())
        embed.set_thumbnail(url=icon)
        embed.add_field(name="Owner", value=owner, inline=True)
        embed.add_field(name="Server ID", value=id, inline=True)
        embed.add_field(name="Region", value=region, inline=True)
        embed.add_field(name="Member Count", value=memberCount, inline=True)

        await ctx.send(embed=embed)


def setup(client):
    client.add_cog(Commands(client))
meager fractal
velvet tinsel
#

that's my boy

maiden fable
#

No won't work

#

Lemme give u a hint

#

It's something in the init that won't work

stark geyser
slate swan
velvet tinsel
stark geyser
#

idk i can dm u the whole bot code if u want

velvet tinsel
#

possibly it's in setup

#

just show us the error

slate swan
#

here's init, not _init_

stark geyser
slate swan
#

@stark geyser Now try this:

import discord
from discord import Client
from discord.ext import commands


class Commands(commands.Cog):
    def __init__(self, client):
        self.client = Client 

    @commands.command()
    async def ping(self, ctx):
        await ctx.send(f'Your ping is {round(self.client.latency * 1000)}ms')


    @commands.command()
    async def server(self, ctx):
        name = str(ctx.guild.name)
        description = str(ctx.guild.description)

        owner = str(ctx.guild.owner)
        id = str(ctx.guild.id)
        region = str(ctx.guild.region)
        memberCount = str(ctx.guild.member_count)

        icon = str(ctx.guild.icon_url)

        embed = discord.Embed(title=f"{name} Server Information",
                            description=description,
                            color=discord.Color.blue())
        embed.set_thumbnail(url=icon)
        embed.add_field(name="Owner", value=owner, inline=True)
        embed.add_field(name="Server ID", value=id, inline=True)
        embed.add_field(name="Region", value=region, inline=True)
        embed.add_field(name="Member Count", value=memberCount, inline=True)

        await ctx.send(embed=embed)


def setup(client):
    client.add_cog(Commands(client))
velvet tinsel
#

stop spoonfeeding him

stark geyser
#

ping doesnt work

#

server one works

slate swan
stark geyser
#

yh tried it

slate swan
#

Hmm, I don't know.

velvet tinsel
#

stop spoonfeeding him

slate swan
visual island
velvet tinsel
#

you're just giving code

#

not teaching him

heavy folio
#

@stark geyser can you send main.py code

velvet tinsel
#

EEVEE!!!

#

HAI!!!

upbeat otter
#

haiiiii

obsidian ledge
#

can u make a embed value blank or no

upbeat otter
#

as the value

obsidian ledge
#

okay

slate swan
upbeat otter
slate swan
#

🙂

velvet tinsel
#

you can make a class and instead of commands.command() you can do something like

class discordbot(Bot):
  def __init__(self):
    super.().__init__(command_prefix=...)

    @self.command()
    async def command(ctx):
      # code...

bot = discordbot()
bot.run(TOKEN)
slate swan
#

@stark geyser try:

class Commands(commands.Cog):
    def __init__(self, client):
        self.client = client
velvet tinsel
obsidian ledge
#

theres still some space between it

upbeat otter
obsidian ledge
#

oh, alright

slate swan
upbeat otter
slate swan
obsidian ledge
#

also is there a way to do something like this in an embed :
"
1 = optional
2 = required
"

#

like 1 message with 2 lines in it

velvet tinsel
# velvet tinsel why can't you do this

grammatically that's incorrect, since can't is basically "can not", so this says "why can not you do this" which is bad English. However, "why can you not do this" is better English, but using "can't" is a contraction, but "why can't you do this" is correct, but if you split it up it's incorrect.

How interesting...

neat gale
#

hey guys, i would need some help with a discord bot that im coding atm because it doesnt seem to work c:

velvet tinsel
#

bruh

#

where's the code
where's the error

#

we're not mind readers

neat gale
#

import discord
from discord import channel
from discord.ext import commands
from discord.flags import Intents

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

client = commands.Bot(command_prefix= '!', Intents=Intents)

@client.event
async def on_ready():
print("Bot is ready")
print("------------")

@client.command()
async def hello(ctx):
await ctx.send("hi")

@client.event
async def on_member_join(member):
channel = client.get_channel(763454059931107372)
await channel.send("Welcome")

client.run('BotToken')

#

there it is

#

it doesnt detect when someone joins

#

idk why

visual island
#

enable intents.members

neat gale
#

nope

visual island
#

oh you did

neat gale
#

ye

velvet tinsel
#

hurr

#

theres an arg but you never used it

neat gale
#

uhm

little ether
neat gale
#

yeah i did

velvet tinsel
#

weird

neat gale
#

yeah it is

velvet tinsel
#

did you get someone to join?

neat gale
#

yeah, multiple times

tawdry perch
neat gale
#

i tried to do that but that doesnt work either

tawdry perch
#

So not triggered?

neat gale
#

nope

tawdry perch
#

And you sure someone did join?

neat gale
#

yep

#

i have tried it with a bot and 3 normal ppl

#

multiple times.

tawdry perch
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

try printing it

neat gale
#

@client.event
async def on_member_join(member):
print("hi")

#

like this?

velvet tinsel
#

yeah

neat gale
#

well i did

velvet tinsel
#

and?

neat gale
#

nothing happened

velvet tinsel
#

huh

neat gale
#

idfk

velvet tinsel
#

this is kind of stupid, but try @client.listen()

#

ANDY HELP

pliant gulch
neat gale
#

uh

#

ok

velvet tinsel
#

or maybe use listen()

neat gale
#

@client.listen ?

velvet tinsel
#

@client.listen**()**

neat gale
#

kk

meager fractal
#

All embeds with text (so not the header images) have an full width hidden image

velvet tinsel
#

ok

velvet tinsel
neat gale
#

it...

#

doesnt work

velvet tinsel
#

both?

#

huh

neat gale
#

uhm

velvet tinsel
#

hurrr weird

#

put event above command()

#

maybe that works

(please work)

neat gale
#

above?

velvet tinsel
#

yeah

neat gale
#

oh

velvet tinsel
#
@client.event
# ...


@client.command()
# ...
neat gale
#

k

neat gale
#

uhm

#

where do i have to put that?

pliant gulch
#

Before client.run, in the first indentation level

neat gale
#

did that

#

got this now

#

import discord
from discord import channel
from discord.ext import commands
from discord.flags import Intents

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

client = commands.Bot(command_prefix= '!', Intents=Intents)

@client.event
async def on_ready():
print("Bot is ready")
print("------------")

@client.event
async def on_member_join(member):
print("hi")

@client.command()
async def hello(ctx):
await ctx.send("hi")

dict(client.intents)

client.run('BotToken')

velvet tinsel
#

alr

neat gale
#

still doesnt work

neat gale
#

nope

pliant gulch
#

I'm asking you to print

neat gale
#

wha

pliant gulch
#

You didn't do print(dict(client.intents))

neat gale
#

oh

#

i see

#

uh

velvet tinsel
#

uh

neat gale
#

am i suposed to see something special?

#

this?

#

'guilds': True, 'members': False, 'bans': True, 'emojis': True, 'integrations': True, 'webhooks': True, 'invites': True, 'voice_states': True, 'presences': False, 'guild_messages': True, 'dm_messages': True, 'guild_reactions': True, 'dm_reactions': True, 'guild_typing': True, 'dm_typing': True

pliant gulch
neat gale
#

ohhhh

#

soooooo

pliant gulch
#

As you can see it says members

#

Is false

velvet tinsel
#

andy's smart

slate swan
#

Don't use the Class name as variable name

neat gale
#

he werry smort

cold sonnet
#

intents = discord.Intents.default() -> intents = discord.Intents.all()

velvet tinsel
cold sonnet
#

default doesn't contain members intent

#

nor presence, tho presence is not always needed

cold sonnet
#

andy was gonna explain that

velvet tinsel
#

copy and pasta 😋

pliant gulch
pliant gulch
#

Intents -> intents

cold sonnet
neat gale
#

so i just have to put that in my code?

cold sonnet
neat gale
#

oh wow ty guys

#

i was desperate lol

drifting tulip
maiden fable
#

Discord Dev Portal -> OAuth2 -> General

drifting tulip
#

okay

#

thanks

velvet tinsel
#

Astro

royal jasper
#

my bot was hosted on heroku, but after a while it went offline and doesnt want to come back anymore... can some1 help me?

silver wolf
velvet tinsel
#

Errors? @slate swan

#

Screenshot please

#

It’s better to see it

visual island
#

you missed )

velvet tinsel
#

You forgot a closing )

#

In set_footer

velvet tinsel
visual island
#

pithink I got better eyes

velvet tinsel
#

I am short sighted

visual island
#

nah, I'm actually far sighted and I use discord on my tv

tawdry perch
#

On tv, you are joking right?

visual island
#

ofc pithink

#

no one does that..

velvet tinsel
#

I dont even have a TV -.-

visual island
#

..

#

fr?

tawdry perch
#

!ot :D

unkempt canyonBOT
visual island
#

😭

#

anyway, why do they send 1 ot channel only?

velvet tinsel
velvet tinsel
unkempt canyonBOT
velvet tinsel
#

They changed the name of the command

visual island
#

oh~

velvet tinsel
#

Oh~

visual island
#

imagine impersonating me

velvet tinsel
#

I don’t want to change my name into “icy” and my profile picture is perfectly suitable, thanks.

#

It’s cool how you can change your name and your profile picture and be a completely different person

velvet tinsel
#

LunaTheGod

cold oyster
manic wing
#

@spring flax

#

you showed a method to get the perms a command requires

#

how?

granite yew
#
import discord 
import keep_alive
import os

client = discord.Client()

token = os.environ.get("Hecker")

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

if message.content.startsWith('$sudo heck'):
  user = next(iter(message.mentions, None))
  if not user:
       return
      await message.channel.send(f'content {user.mention} more content')
                                                                       ^ error
#

help

granite yew
thin kelp
#

the indentation is messed up

granite yew
#

what do i do

#

@thin kelp

#

@cedar stream

thin kelp
#

correct the indentation?

cedar stream
#

!indent

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

cedar stream
#

@granite yew

#

Read this

granite yew
#

i did

#

but i still don't understand the error

#

i tried everything

cedar stream
granite yew
#

i tried

cedar stream
#

Send ss

spring flax
#

be right back 30 minutes sorry

granite yew
spring flax
#

@manic wing permission needed for ctx.command? or do you want this for something like a help command?

granite yew
#

@cedar stream

cedar stream
granite yew
#

which line

#

@cedar stream

cedar stream
cedar stream
granite yew
#

i did

#

i read it
i still dk what to do

cedar stream
#

Indent once

spring flax
# manic wing ctx.command
{', '.join(map(lambda perm: f'`{perm}`', ctx.command.missing_perms))} permission{'' if len(error.missing_perms) <= 1 else 's'} to execute the `{ctx.command.name}` command." ```
granite yew
#

@cedar stream

granite yew
#

why was i born so fuckin dumb

manic wing
#

the try one

spring flax
spring flax
cedar stream
granite yew
#

i don't think repl.it has an error handler

spring flax
manic wing
#

enslo you dont know what youre talking about

cedar stream
spring flax
#

can you please not comment on my message i wasn't asking for help

cedar stream
granite yew
#

bruh

#

i give up

spring flax
#

@manic wing

import tracceback
try:
                check = command_object.checks[0]
                check(0) 
            except Exception as e:
                try:
                    *frames, last_frame = traceback.walk_tb(e.traceback) 
                    frame = last_frame[0] 
                    first = (frame.f_locals['perms'])
                    joined_first = (" ".join(first))
                    first_replaced = joined_first.replace("", " ")
                    final = first_replaced.title()
                except:
                    final = "No perms required"
#

indents are messed up

granite yew
#

i fixed the error
but why wouldn't it come online
@cedar stream

spring flax
#

also don't mind my var names I know they suck

cedar stream
sinful pasture
#

how do you use timeout?

#

im using disnake btw

manic wing
sinful pasture
sinful pasture
#

ty

graceful mulch
#

I want help


@client.command()
@commands.check(check_Mod)
async def OFF(ctx, seconds:float):

    embed = discord.Embed(title = "OFF", description = f"{ctx.message.author.mention} turned off me for {round(seconds)} seconds",)
    await ctx.send(embed = embed)
    await client.close()
    await asyncio.sleep(seconds)
    await client.connect()
    embed = discord.Embed(title = "Turned on", description = f"I came back after {round(seconds)}")
    await ctx.send(embed = embed)

AIM - SENDING MESSAGE AFTER BOT RESTARTED USING A COMMAND
PROBLEM- SENDS ONLY TILL OFF EMBED
I KNOW IT SOMEWHERE THAT IT WONT WORK THIS WAY , THEN HOW WILL IT WORK

daring olive
#

chill with the caps, and don't try to ping at-here or at-everyone please

maiden fable
graceful mulch
#

Yeah

#

but cant we avoid that

#

i want to restart with cache

maiden fable
#

Nope

graceful mulch
#

and all

#

I thought of a json or txt file which will store the message id of my restart command's output and edit it on_ready will that work

maiden fable
#

Sure

cedar stream
manic wing
#

@spring flax it aint workin

#
try:
            check = command.checks[0]
            check(0) 
        except Exception as e:
            try:
                *frames, last_frame = traceback.walk_tb(e.traceback) 
                frame = last_frame[0] 
                first = (frame.f_locals['perms'])
                joined_first = (" ".join(first))
                first_replaced = joined_first.replace("", " ")
                final = first_replaced.title()
            except:
                final = "No perms required"
cedar stream
#

But on_ready is not guaranteed to only be called once

spring flax
manic wing
#

'AttributeError' object has no attribute 'traceback when I catch the second exception

#

this is on a command that requires perms

#

Index error on a command that doesnt require perms - i assume thats how it should be

manic wing
wanton jacinth
#

Hello, I'm trying to create a guess-the-number game with a bot. Even if I put if message.author == client.user: return, the bot answers itself. Any idea?

#

Here the code:

#

`@client.event
async def on_message(message):
if message.author == client.user:
return

msg = message.content

if msg.startswith("£hello"):
    greeting = random.choice(hellos_list)
    await message.channel.send(greeting)

if msg.startswith("£support"):
    response = random.choice(possible_responses)
    await message.channel.send(response)

if msg.startswith("£guess"):
    number = random.randrange(20)
    await message.channel.send("Guess the number! (0-20)")
    if msg == str(number):
        await message.channel.send("Right!")
    else:
        await message.channel.send("Wrong. Try again!")`
shrewd inlet
#

!codeblacks

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.

wanton jacinth
#
async def on_message(message):
    if message.author == client.user:
        return

    msg = message.content

    if msg.startswith("£hello"):
        greeting = random.choice(hellos_list)
        await message.channel.send(greeting)

    if msg.startswith("£support"):
        response = random.choice(possible_responses)
        await message.channel.send(response)

    if msg.startswith("£guess"):
        number = random.randrange(20)
        await message.channel.send("Guess the number! (0-20)")
        if msg == str(number):
            await message.channel.send("Right!")
        else:
            await message.channel.send("Wrong. Try again!")
cedar stream
wanton jacinth
#

Already done,

cedar stream
#

This will return if any bot is the author

wanton jacinth
#

Maybe I'm only missing where to put it

sly current
cedar stream
sly current
#

if theres nothing wrong maybe try comparing the ids

cedar stream
#

Put a breakpoint at start of event

sly current
wanton jacinth
sly current
cedar stream
wanton jacinth
sly current
#

show where your client is defiend @wanton jacinth

cedar stream
wanton jacinth
#

client = discord.Client()
TOKEN = "censured"

possible_responses = encourage_list.list
hellos_list = hello_all_languages.list

@client.event
async def on_ready():
    print("Logged as {0.user}".format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    if author.bot:
        return

    msg = message.content

    if msg.startswith("£hello"):
        greeting = random.choice(hellos_list)
        await message.channel.send(greeting)

    if msg.startswith("£support"):
        response = random.choice(possible_responses)
        await message.channel.send(response)

    if msg.startswith("£guess"):
        number = random.randrange(20)
        await message.channel.send("Guess the number! (0-20)")
        if msg == str(number):
            await message.channel.send("Right!")
        else:
            await message.channel.send("Wrong. Try again!")

client.run(TOKEN)```
#

this is the whole thing

cedar stream
#

Ok It’ s a client

wanton jacinth
#

Actually now i tried to put author.bot and it's saying that author is not definied

sly current
#

try printing them

slate swan
mellow gulch
#

What r u trying to do?

cedar stream
# wanton jacinth discord.Client

Since u are trying to make commands you should consider using commands.Bot, it can do everything client can + some other stuff like commands

cedar stream
mellow gulch
#

Why not this?
If message.author != client.user:
Code…

cedar stream
wanton jacinth
cedar stream
#

Nicer to look at

slate swan
#

how i use api to send gif

wanton jacinth
#

when i print the id are the same

cedar stream
cedar stream
slate swan
wanton jacinth
slate swan
#

mistake type

cedar stream
#

So it wont respond to any bot

wanton jacinth
#

Ok

wanton jacinth
cedar stream
wanton jacinth
#

Nothing?

cedar stream
#

Can u send a ss

#

Of code

honest vessel
#

@wanton jacinthpep8 ```Imports should be grouped in the following order:

Standard library imports.
Related third party imports.
Local application/library specific imports.
```py
import random
import discord
import encourage_list
import hello_all_languages
mellow gulch
#

How would I be able to have a bot send this as one msg instead of multiple for each row?

wanton jacinth
#

client = discord.Client()
TOKEN = 

possible_responses = encourage_list.list
hellos_list = hello_all_languages.list

@client.event
async def on_ready():
    print("Logged as {0.user}".format(client))

@client.event
async def on_message(message):
#   if message.author == client.user:
#       return
    if message.author.bot:
        return

    msg = message.content

    if msg.startswith("£hello"):
        greeting = random.choice(hellos_list)
        await message.channel.send(greeting)

    if msg.startswith("£support"):
        response = random.choice(possible_responses)
        await message.channel.send(response)

    if msg.startswith("£guess") and message.author.id != 921476286193483786:
        number = random.randrange(20)
        await message.channel.send("Guess the number! (0-20)")
        if msg == str(number):
            await message.channel.send("Right!")
        else:
            await message.channel.send("Wrong. Try again!")

client.run(TOKEN)```
cedar stream
wanton jacinth
#

what do u mean

slate swan
#

remove token first

cedar stream
honest vessel
#

whats the error?

mellow gulch
# cedar stream Use \n for new line

but the way this works is that it sends one line then sends another how would i set each row into a list or smth like that so that i can then send as one msg from the bot

slate swan
#

lmao i am very bad in explaination

wanton jacinth
honest vessel
#

@wanton jacinthwhats the error?

#

or what aint working

slate swan
#

why # there

honest vessel
#

caseu he changed n commented it out

slate swan
#

hmm

wanton jacinth
#

I am trying to create a guess the number game but the bot responds to itself

honest vessel
wanton jacinth
#

But in the other cases it doesnt

wanton jacinth
sinful pasture
#
NameError: name 'timeout' is not defined

do i need to import smth for this

sinful pasture
sinful pasture
cedar stream
sinful pasture
#

did i even use it properly

slate swan
#

define it

sinful pasture
#
await timeout(duration=10, reason=None)
cedar stream
honest vessel
mellow gulch
slate swan
cedar stream
#

!d disnake.Member.timeout

unkempt canyonBOT
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
cedar stream
#

You do member.timeout()

honest vessel
#

@wanton jacinthyou also get new random number each time u do £guess, i would put in something like wait_for()

cedar stream
#

await member.timeout()

quick gust
#

no, what...

honest vessel
#

@wanton jacinthhttps://discordpy.readthedocs.io/en/stable/api.html#discord.Client.wait_for

slate swan
wanton jacinth
#

I think I'm going to read some more documentation

slate swan
#

best website to get anime gif api

honest vessel
slate swan
#

ty

honest vessel
#

i think discord itself uses that, not sure tho

slate swan
#

tensor

#

discord use tensor

honest vessel
#

ah yeah tenor

sinful pasture
honest vessel
sinful pasture
honest vessel
#

oh shit

slate swan
#

yes

#

lol

sinful pasture
#

i tried out disnake, just put my code into google docs, ctrl+h and replaced discord with disnake and code works just fine idk

honest vessel
#

whye they dont display info about it on website

slate swan
sinful pasture
slate swan
#

yah

#

but it still work

honest vessel
slate swan
#

on vsc

gilded phoenix
#

hi

slate swan
maiden fable
#

@slate swan @sinful pasture read this gist

sinful pasture
#

ty

final iron
maiden fable
#

Yea. With message content too it's gonna work

final iron
#

But yes, updates have ceased

maiden fable
#

!d discord.Intents.messages still exist :D

unkempt canyonBOT
maiden fable
#

It still needs to be enabled in order to get message content

slate swan
#

lol danny is not professional

maiden fable
#

???

honest vessel
#

@maiden fablethanks bro, to bad no one wanted to continue on that project

upbeat otter
slate swan
upbeat otter
slate swan
#

lmao

upbeat otter
#

respect

maiden fable
honest vessel
manic wing
#

@spring flax i reckon that traceback scraping doesnt work with 2.0 or something

#

hunter

honest vessel
maiden fable
#

Same

manic wing
#

do you know how to get the permissions a command requires?

maiden fable
manic wing
#

o.O

slate swan
#

danny is pro

manic wing
#

whyyyy nottttt

maiden fable
#

Since discord.py doesn't know which error the Discord API gonna raise/send in a single line of code. There can be numerous errors

maiden fable
unkempt canyonBOT
#

exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
honest vessel
#

exception discord.ext.commands.MissingPermissions(missing_perms, *args)

maiden fable
#

error.missing_permissions exist

manic wing
#

just the permissions a command has

#

in a help command

maiden fable
honest vessel
manic wing
#

how do i do that in a help command pithink

honest vessel
#

like if u normal user and use help, it wont show kick ban etc

#

even if command exists

maiden fable
#

!d discord.ext.commands.HelpCommand.on_help_command_error @manic wing

unkempt canyonBOT
#

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

The help command’s error handler, as specified by [Error Handling](https://discordpy.readthedocs.io/en/master/ext/commands/commands.html#ext-commands-error-handler).

Useful to override if you need some specific behaviour when the error handler is called.

By default this method does nothing and just propagates to the default error handlers.
maiden fable
#

Use this (:

slate swan
#

kick,ban commands is ez

maiden fable
#

Ik

#

I can make it in 2 lines too lol

slate swan
#

lmao true

honest vessel
#

who said anything was hard?

maiden fable
#

me No one

slate swan
#

nothing is impossible in this world LMAO

honest vessel
#
    @commands.command(aliases=["k"])
    @commands.has_permissions(kick_members=True)
    async def kick(self, ctx, member:discord.User, *, reason="No reason provided"):
        user = await self.bot.fetch_user(member.id)
        try:
            await user.send(f"You have been **kicked** from the {ctx.guild.name}\nreason: {reason}")
        except:
            pass
        await ctx.send(f"{user.mention} **has been kicked.**\n*reason: {reason}*")
        await ctx.guild.kick(user, reason=reason)```
i did this so u can both use @mention and their id
slate swan
fringe harness
#

Can someone help me work on a discord bot that graphs server statistics

honest vessel
#

😛

maiden fable
unkempt canyonBOT
honest vessel
fringe harness
#

Ignition

#

*aight

maiden fable
honest vessel
maiden fable
#

No

slate swan
#

Code

honest vessel
#

@maiden fableyes otherwise i would't need fetch right 😉

slate swan
#

With ban and unban too

honest vessel
maiden fable
#

Whatever u specify, a name, a user id, or a mention, it will always convert it as long as it's a valid one (;

slate swan
#

And tempban

maiden fable
#

Also consider using get instead of fetch repeatedly

honest vessel
maiden fable
#

!d discord.Guild.get_member

unkempt canyonBOT
maiden fable
#

fetch makes an API request, get gets the object from the cache

honest vessel
#

trust me when i say i had to do this way to be able

#

or i would't even add that fetch

maiden fable
#

I just told u, rest your wish 🤷‍♂️

honest vessel
#

ama check it out later 😉

maiden fable
honest vessel
#

OT: have u guys seen matrix4 yet? (now that u posted neothumbup)

maiden fable
#

!ot and idk what's that

unkempt canyonBOT
honest vessel
slate swan
#

@honest vessel hey can u send a structure code for anime gif
Like : kick
Punch
With api

#

how do I do something like: the person says !help hello
the bot wants to include the thing that was said after the command, how do I do this?

mellow gulch
#
    class board:
        def __init__(self):
            self.spaces = [
                [".", ".", ".", ".", ".", ".", ".", ],
                [".", ".", ".", ".", ".", ".", ".", ],
                [".", ".", ".", ".", ".", ".", ".", ],
                [".", ".", ".", ".", ".", ".", ".", ],
                [".", ".", ".", ".", ".", ".", ".", ],
                [".", ".", ".", ".", ".", ".", ".", ],
            ]

        def display(self):
            for row in self.spaces:
                for space in row:
                    print(space, end=" ")
                print()
            print("1 2 3 4 5 6 7")
            print(" ")```
#

how would i make that

#

print as one msg

#

in discord from the bot

maiden fable
slate swan
fringe harness
#

how do u get the number of people in the server

#

in dpy

mellow gulch
fringe harness
#

like I just need like a number of members

honest vessel
#

len(guild.members)

maiden fable
fringe harness
mellow gulch
#

variable = len(guild.members)

mellow gulch
honest vessel
#
memberscount = len(guild.members)
await ctx.send("There are {} members in this server!".format(memberscount))```
or 
```py
await ctx.send(f"There are {memberscount} members in this server!")```
#

something like that

fringe harness
#

also how am I supposed to set time

slate swan
#

don't use format and f strings togetherpithink

slate swan
fringe harness
#

I want time to be on the y axis and # of numbers on the x axis

maiden fable
#

!e

a = 1
print(f"{}".format(a))
unkempt canyonBOT
#

@maiden fable :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print(f"{}".format(a))
003 |                ^
004 | SyntaxError: f-string: empty expression not allowed
maiden fable
#

See

vague sundial
#

In a bot how do I make sure that you can't kick urself?

boreal ravine
#

add a check to see if its the author

echo heart
#
@client.command()
async def rules(ctx,cmd,no):
    print(cmd,no)
    if cmd == "rule" :

        rules = ["","1) Be respectly to everyone in this server irrespective of their age, gender and beliefs ",

"2) Irrelevant content in an unrelated channel is prohibited - don't spam in general or use music commands in spam",

" 3) Respect DM roles of a member - ask for permission if they have set to \"Ask for DMs\" and don't text them at all if its \"DMs Closed\" ",

"4) Only attach links in self promotion - links will be highly moderated and scanned for phising links or advertising",

"5) Targeted insults, slurs either personal or directed towards a group will not be tolerated",

"6) Abusing is allowed if both parties involved are okay with it",

"7) Don't tag Mods or Admins without any legitimate reasons ",

"8) Take roles which applies to you in real life - false picking of gender and age roles will lead to permanent ban from this server",

"9) Server staffs will not be responsible for any fraudment transactions"]
        print(cmd,no)
        text = rules[no]
        print(text)
        await ctx.send(text)```
#

what am I doing wrong ?

honest vessel
#

@maiden fablei fixed it hto above

echo heart
#

event the print statements at top are not exexuting

mellow gulch
#

how would i look into a msg that someone sent and find out if they said a specific word like...words...

maiden fable
honest vessel
gray star
#

is this a virus

#

ptb.discord??

honest vessel
#

thats 100% virus

#

i own the subdomains 😄

gray star
#

oh my bad, it looked so freaking sus

honest vessel
#

ptb=public test build

#

i run 2 clients, so i use one PTB and one normal discord

boreal ravine
#

good for you

fringe harness
#

can someone help me figure out how to get time

#

I am trying to make a bot that the time goes on the y axis and the number of members is on the x axis

dire folio
#

when i send my embed it looks like inline is true when it is false, so the fields are in a row when they shouldn't be

rare saddle
#

How to determine the number of deleted messages if there are messages older than 14 days in the chat?

honest vessel
#

and loop it and have a list of words u wanna check if match react

#
@bot.event
async def on_message(message):
    words = ["jesus", "god"]
    msg = message.content.lower()
    for m in msg.split(" "):
        if m in words:
             # Do something
dire folio
#

my embed looks like:

#

when it should look like: