#discord-bots

1 messages ยท Page 552 of 1

slate swan
#

wait no that wont work

placid skiff
#

I'm not at home so i can't show you, i try to find them online, wait a second

slate swan
#

it will only return one role

placid skiff
#

Yes you have to iterate through it

crystal cave
#

which site should i use to host my bot? (as in sites like heroku)

slate swan
#

yes, but I dont want to print one role, I want to print the names of everyrole in the guild

barren isle
#

???

heavy folio
#

how do i get a member's roles

slate swan
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [โ€˜@everyone](mailto:'%40everyone)โ€™ role.

These roles are sorted by their position in the role hierarchy.
crystal cave
#

which site should i use to host my bot? (as in sites like heroku)

placid skiff
# slate swan !d discord.Member.roles
@bot.command(pass_context=True)
    @commands.has_role("Admin")
    async def unmute(ctx, user: discord.Member):
        role = discord.utils.find(lambda r: r.name == 'Member', ctx.message.guild.roles)
        if role in user.roles:
            await bot.say("{} is not muted".format(user))
        else:
            await bot.add_roles(user, role)
```py
placid skiff
#

It was utils.find btw you have to use lambda

slate swan
#

As said, I don't want to search for one role?

#

I need every role in the guild?

cloud dawn
#

ctx.guild.roles

slate swan
#

i need to access the names

#

and idk how to do that since roles doesn't have the name attribute

barren isle
#

anyone able to help me fix a bump bot?

cloud dawn
placid skiff
#

Yes use this, role is equals to that list, so role.name is equals to role name and you can memtion it

slate swan
#

im confused

cloud dawn
slate swan
cloud dawn
slate swan
cloud dawn
slate swan
#

hmm where in the docs can I find this

cloud dawn
#

inside guild.roles are role classes so we can just do role.name

cloud dawn
placid skiff
#

Bro just listen:

role = discord.utils.find(lambda r: r.name, ctx.guild.roles)

This returns you a list like the one you get from guild.roles

cloud dawn
unkempt canyonBOT
placid skiff
#

So you just iterate through them and send the role

slate swan
placid skiff
#

But role is just the name of that list cuz is lambda r: r.name

cloud dawn
#

!source

unkempt canyonBOT
slate swan
placid skiff
#

Cuz you have to iterate through guild.roles

sick birch
placid skiff
#

Yes you could do in that way too

slate swan
#
roles = " ".join([r.name for r in ctx.guild.roles])

```How do I remove the everyone role and how can I mention the others?
placid skiff
#

Start from the second element in the list

slate swan
#

use r.mention instead of r.name

slate swan
placid skiff
slate swan
#

and you can do what @placid skiff said

barren isle
#

I dont know what is wrong but it is not working, all this is it to set the invite for the servers bump ( its for a bump bot btw ) so If you know what wrong please state

  # Broken
@bot.command()
@commands.has_permissions(manage_guild=True)
async def setinvite(ctx,*,desc):
  file = open("data/invites.txt","r")
  current = ast.literal_eval(file.read())
  file.close()
  try:
    await ctx.send(f"Getting information for {desc} .")
    invite = await bot.get_invite(desc)
    print("Invite 1")
  except:
    await ctx.send("The invite is invalid. 1")
  try:
    if invite.guild == ctx.guild:
      current[str(ctx.guild.id)] = desc
      await ctx.send("Invite Set!")
      file = open("data/invites.txt","w")
      file.write(str(current))
      file.close()
      print("Invite 2")
    else:
      await ctx.send("The listed invite is not for your server.")
      print("Invite 3")
  except:
    await ctx.send("The invite is invalid. 2")```
slate swan
#

we won't know what's wrong

slate swan
#

using the remove() method?

placid skiff
# slate swan wdym?

The everyone role is always the first element in the list when you get the list of all roles
So if you start from the second element you will skip it

slate swan
#

oh ok, do I use pop() or remove() in this case?

sick birch
#

you can splice it

#

i think that's the right terminology

slate swan
#

or you can even set an if statement for the for loop

sick birch
#
a = [1, 2, 3, 4, 5]
print(a[1:])
[2, 3, 4, 5]
#

gist of it

placid skiff
#

There is no need, use list slicing
!e

list[0,1,2,3,4]
print(a[1:])
slate swan
#

you didn't specify a....

placid skiff
#

!e
list[0,1,2,3,4]
print(a[1:])

sick birch
#

hehe

#

!e

a = [1, 2, 3, 4, 5]
print(a[1:])
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

[2, 3, 4, 5]
placid skiff
#

Lol i'm drunk

sick birch
#

there

placid skiff
#

Thanks

slate swan
#

!e
a = ["hi", "lol"]
print(a[1:]

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print(a[1:]
003 |          ^
004 | SyntaxError: '(' was never closed
slate swan
#

!e
a = ["hi", "lol"]
print(a[1:])

unkempt canyonBOT
#

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

['lol']
slate swan
#

y'all drunk lmao

sick birch
#

there

slate swan
#

oh ok, how come its not [0:]? isn't the first element in a list 0?

sick birch
#

we don't want the first element remember

#

[0:] is the same thing as the actual list itself, it's not doing anything

cloud dawn
sick birch
#

name checks out

placid skiff
slate swan
#

Ahh I see

#

but now this issue came up

sick birch
#

i think i know what it is

slate swan
#

so

roles = " ".join([r.mention for r in ctx.guild.roles][1:])
#

removing the method u guys told me, now instead of mentioning the everyone role, it sends the ID

#

?

slate swan
#

in an embed?

#

yes

#

you can't mention in the title

sick birch
slate swan
#

i never did?

slate swan
#

but it always has everyone

placid skiff
sick birch
#

if it has everyone doing [1:] will freak out but i think that's more of an off-case

slate swan
#

!e

a = ["hello"]
print(a[1:])
unkempt canyonBOT
#

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

[]
placid skiff
#

One role except everyone

slate swan
#
roles = " ".join([r.mention for r in ctx.guild.roles][1:])
            if not roles:
                roles = "None"

This will work?

placid skiff
#

By the way it just print None lol

slate swan
#

exactly

placid skiff
#

Yes

sick birch
#

it shouldn't be an issue then

slate swan
#

well

#

it would error

#

nothing has no mention

slate swan
sick birch
#

mmm fair enough

slate swan
#

I don't think an empty list activates the if not

placid skiff
sick birch
sick birch
slate swan
#

if len(list) == 0

slate swan
sick birch
#

works but if not list also works since it's a falsy value

#

personal preference

placid skiff
slate swan
#

but roles is a string rn

#

not a list

placid skiff
#

Every empty value return False

sick birch
#

you don't even need the if statement afterwards

#

if you try to iterate through an empty list it won't even run once

pure plover
#

Hlo

bright palm
sick birch
#

!e

emptylist = []
for i in emptylist:
  print(i)
unkempt canyonBOT
#

@sick birch :warning: Your eval job has completed with return code 0.

[No output]
pure plover
#

Can anyone help me adding token of bot in python

sick birch
#

ye

slate swan
sick birch
pure plover
#

!e
emptylist = []
for i in emptylist:
print(i)

unkempt canyonBOT
#

@pure plover :warning: Your eval job has completed with return code 0.

[No output]
pure plover
sick birch
#

it doesn't even enter the loop

#

so you'll be fine

pure plover
#

!e print 666 on top

unkempt canyonBOT
#

@pure plover :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print 666 on top
003 |           ^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
slate swan
#

then the if statement is already fine

pure plover
#

!e help

unkempt canyonBOT
#

@pure plover :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'help' is not defined
sick birch
#

this is not python 2

#

we use ()

slate swan
#

!d discord.Member.activity

unkempt canyonBOT
#

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

Note

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

Note

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

How can I get just the name?

placid skiff
#

!e

i = ""
print(i)
unkempt canyonBOT
#

@placid skiff :warning: Your eval job has completed with return code 0.

[No output]
sick birch
slate swan
#

activity

sick birch
slate swan
#

I'm sorry. I don't know how to do this.
Can you tell me more about it?

#

nope

sick birch
#

d.py has good semantics imo

slate swan
#

pro tip, you can click on the embed title in !d and it will bring you to the docs

#

i am owner of bot ryzen it is is 75+ server and it anti nuke so intents are on i applied for verification also but unfortunately i close it intents and it is not enable now what Should i do?

#

showing every attribute

sick birch
#

not quite understanding you

slate swan
#

So how do I get the name of an activity?

unkempt canyonBOT
#

Hey @pure plover! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

#

@pure plover :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'bot' is not defined
sick birch
#

might wanna not

#

change your token pls

boreal ravine
slate swan
#

doesn't exist

#

LMAO

unkempt canyonBOT
sick birch
#

welp

boreal ravine
#

๐Ÿค”

tawdry perch
#

what does ctx.send_help this do? Is this literally what it says?

sick birch
#

said again, good semantics

slate swan
#

hmm so I have to do the same thing to activity as I did for roles huh?

pure plover
sick birch
boreal ravine
#

oh

tawdry perch
#

so, which one is correct

reef shell
tawdry perch
#

or I can just make a quick function and test it out

sick birch
#

it sends either the default help or a custom class if you have one

#

i assume it calls the send_bot_help() of bot.help_command

#

(assuming it's set)

slate swan
reef shell
tawdry perch
#

what is that ;-;

sick birch
#

he's not wrong

#

it technically does return that

#

the location in memory may be different but that's beside the point

slate swan
sick birch
#

member.activity returns discord.Activity yes?

#

so you should be able to do member.activity.name

slate swan
#

nope doesnt work

sick birch
#

what error are you getting?

slate swan
#

that discord.Member.activity has no attribute name

slate swan
unkempt canyonBOT
#

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

Note

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

Note

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

hmm

#

returns discord.activity.Activity

#
            embed.add_field(name="Activity:", value=f"{arg.activity.name}", inline=True)
#

!d discord.activity.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

โ€ข [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")

โ€ข [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
reef shell
sick birch
#

i mean, it's type

slate swan
#

a discord.User or a discord.Member

sick birch
#

i see

slate swan
tawdry perch
#

it did send a help command!

sick birch
#

ah i know why

#

nvm no i don't

tawdry perch
#

but now I need to figure out how to send it for specific command

slate swan
slate swan
#

doesn't work

sick birch
#

that's what i said but they said it doesn't work

slate swan
#

what's the error

sick birch
#

so now i'm confused

reef shell
slate swan
#

ive said it multiple times now

tawdry perch
#

iirc, yes

placid skiff
sick birch
#

yeah they said discord.Activity has no attribute name

#

a traceback would be nice yes

slate swan
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

reef shell
slate swan
reef shell
unkempt canyonBOT
slate swan
#

has no attribute

#

bro you used the class?

#

?

tawdry perch
# reef shell are you using the default help command? (subclassed)
class MyNewHelp(commands.MinimalHelpCommand):
    async def send_pages(self):
        
        destination = self.get_destination()
        for page in self.paginator.pages:
            emby = discord.Embed(description=page)
            await destination.send(embed=emby)

bot.help_command = MyNewHelp()
``` I use this
sick birch
#

member.activity should return an instance

slate swan
#

member.activity != discord.Member.activity

reef shell
slate swan
#

ah wait I see the issue

#

discord.Member is the main class

reef shell
#

to customize it

#

for specific commands help

sick birch
#

you should never work with the base classes themselves with d.py

#

only instances

tawdry perch
#

but how?

slate swan
#

nah nvm I fixed it, the typehint for the arg was a little fucked

sick birch
#

explains it

slate swan
#

yup it works now

placid skiff
slate swan
#

meaning you didn't read the error properly, nor sent it

reef shell
placid skiff
#

My bot is a customized Bot class for example

sick birch
#

i mostly mean the base discord models like discord.Member and such

reef shell
#

and there is a good gist for subclassing default help command

tawdry perch
placid skiff
#

Yes those are useless to work with the base class

sick birch
#

oh yeah there was a tag on d.py server for that

#

it was a really good gist

reef shell
sick birch
#

ah yeah

slate swan
sick birch
#

you can print it, send it over discord, store it, whatever

unkempt canyonBOT
#
Out of the question.

Sorry, you can't do that here!

reef shell
tawdry perch
#

;-;

slim whale
#

why is it looking like this? i want the photo at the right

#
@bot.command()
async def serverinfo(ctx):
  guild = ctx.guild
  a= len([m for m in ctx.guild.members if not m.bot])
  b= len([r for r in ctx.guild.roles])
  c= len([c for c in ctx.guild.text_channels])
  d= len([d for d in ctx.guild.voice_channels])
  e= len([e for e in ctx.guild.emojis])
  f= len([f for f in ctx.guild.categories])
  g= ctx.guild.mfa_level
  h= "a"
  if g == 0:
    h = "No"
  else:
    h = "Yes"
  embed = discord.Embed(colour=0x87CEEB)
  embed.set_author(name=f"{guild.name} Information!", icon_url = guild.icon_url)
  embed.set_image(url=guild.icon_url)
  embed.add_field(name="Server Owner", value=f"{guild.owner}", inline=True)
  embed.add_field(name="Server ID", value=f"{guild.id}", inline=True)
  embed.add_field(name="Server Region", value=f"{guild.region}", inline=True)
  embed.add_field(name="Categories", value=f, inline=True)
  embed.add_field(name="Text channels", value=c, inline=True)
  embed.add_field(name="Voice channels", value=d, inline=True)
  embed.add_field(name="Rules channel", value=f"{guild.rules_channel}", inline=True)
  embed.add_field(name="AFK channel", value=f"{guild.afk_channel}", inline=True)
  embed.add_field(name="Updates channel", value=f"{guild.public_updates_channel}", inline=True)
  embed.add_field(name="Members", value=a, inline=True)
  embed.add_field(name="Roles", value=b, inline=True)
  embed.add_field(name="Created at", value=f"{guild.created_at} **UTC Time**", inline=True)
  embed.add_field(name="Boosts", value=f"{guild.premium_subscription_count}", inline=True)
  embed.add_field(name="Emojis", value=e, inline=True)
  embed.add_field(name="Emojis limit", value=f"{guild.emoji_limit}", inline=True)
  embed.add_field(name="Verification Level", value=f"{guild.verification_level}", inline=True) 
  embed.add_field(name="2FA", value=h, inline=True)
  await ctx.send(embed=embed)```
slate swan
reef shell
#

np

reef shell
slim whale
#

okk

reef shell
#

!d discord.Embed.set_thumbnail

unkempt canyonBOT
#

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

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

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

so its a flooding machine XD

reef shell
#

inline thing doesn't work on mobile client

placid skiff
#

They actually do lol

slim whale
#

do u like this?

reef shell
placid skiff
reef shell
#

looks cool on desktop , but eww on mobile

placid skiff
#

It's something like this:

ti
tle
Som
e te
xt

#

๐Ÿ˜‚๐Ÿ˜‚

slate swan
#

I am trying to make a bot by watching video on YouTube but IDK what mistake I made, it is not working and I have 0 idea about programming language so please help me someone

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

Start by learning python first

#

As it says, your token is wrong

#

ok how much time it will take?

slate swan
#

Depends on how fast you learn

#

Pretty sure it's not otherwise you wouldn't have that error, copy paste it again

slate swan
#

And make sure you don't have any typos to it

placid skiff
reef shell
#

Code?

slate swan
#

Then idk, are you simply putting your token in the .run or are you getting it from a .env

slate swan
slate swan
river hollow
#

i know its not the best way

reef shell
#

You didnโ€™t define the TOKEN var.

slate swan
#

You're not actually passing "TOKEN" when running right?

slate swan
slate swan
reef shell
#

Oh

#

smh

slate swan
slate swan
river hollow
river hollow
#

i just deleted it out bc i dont want to share it

slate swan
reef shell
#

@river hollow if you have your bot's token stored in env variables then load it in your script first

river hollow
#

but in my code have it

slate swan
slate swan
slate swan
slate swan
placid skiff
# slate swan I mean its good but its better to stick with a programming language know allot a...

Yes oc
When i started i learned C, i studied till i learned memory management then i moved to other languages
The C gives you a good knowledge so even if you code on other language you will have a good idea on what you are doing, I personally think it's essential cuz if you start with python which is simple for beginners but when you move to use external package it will be pretty caothic if you don't know some things

reef shell
river hollow
reef shell
#

In .run

unkempt canyonBOT
#

Hey @river hollow! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

reef shell
#

bruh

river hollow
#

i removed a part out

#

to send it

slate swan
placid skiff
slate swan
bright palm
#

He could make the bot in C :D

slate swan
#

That would take a lot more time rather than doing it in python ๐Ÿ˜‚

placid skiff
bright palm
#

Yeah and it would blow up from the slightest mistake

barren isle
#

Why is it sending the message so many times?

@bot.command()
@commands.has_permissions(manage_guild=True)
async def setchannel(ctx,*,desc,given_name=None):
  file = open("data/channels.txt","r")
  current = ast.literal_eval(file.read())
  file.close()
  for channel in ctx.guild.channels:
    if channel.name == given_name:
      await ctx.send("Please mention a channel next time.")
    else:
      wanted_channel_id = channel.id
      current[str(ctx.guild.id)] = wanted_channel_id
      await ctx.send("Bump Channel Set!")
      file = open("data/channels.txt","w")
      file.write(str(current))
      file.close()
      print(wanted_channel_id)```
bright palm
#

It's quite good

slate swan
slate swan
barren isle
slate swan
#

Remove the for loop

barren isle
#

ok

slate swan
#

That's really basic python

placid skiff
#

Programming isn't always write code following some path
Most of the time programming is create a problem, solve it and then process it
Python will give you the necessary so you will not have to solve directly the problem
But when you have to do complicated things, like doing a bot, you have to know how to solve some algorithm problems

bright palm
#

lmao

slate swan
slate swan
barren isle
placid skiff
#

I think that if i wouldn't learnt C i will be a lot in trouble with the bot i'm creating

bright palm
slate swan
#

For example, I've never had any knowledge of any other language but python and got my bot some dope advanced and complex commands

bright palm
#

Mmm most of the things C teachs you are irrelevant for discord bots

slate swan
#

^

bright palm
#

But in general it is good practice

placid skiff
bright palm
#

Teachs you the way to do things without relying on anything

placid skiff
#

Exactly

slate swan
#

Learning a language that you might never need doesn't hurt, but if you're not gonna get that far into programming nor plan on keep going and just doing it for the moment then it's pretty useless

bright palm
placid skiff
bright palm
#

Like what is this

#

Just use getattr D:

placid skiff
#

Well not exactly
I'm just sharing modified code so they will look more common and find simple ways to solve problem ๐Ÿ˜‚๐Ÿ˜‚

placid skiff
# bright palm Like what is this

As i said i've C mentality so i'll solve problems in my own way ๐Ÿ˜‚๐Ÿ˜‚
Btw the code is pretty old now, i've not uploaded it yet ๐Ÿ˜‚

placid skiff
bright palm
#

For python the C mentality isn't the best approach

placid skiff
#

Till now it worked fine

bright palm
#

It works it just isn't the best

slim whale
#
@bot.command()
async def serverinfo(ctx):
  guild = ctx.guild
  a= len([m for m in ctx.guild.members if not m.bot])
  b= len([r for r in ctx.guild.roles])
  c= len([c for c in ctx.guild.text_channels])
  d= len([d for d in ctx.guild.voice_channels])
  e= len([e for e in ctx.guild.emojis])
  f= len([f for f in ctx.guild.categories])
  g= ctx.guild.mfa_level
  h= "a"
  if g == 0:
    h = "No"
  else:
    h = "Yes"
  i= round(ctx.guild.created_at)
  embed = discord.Embed(colour=0x87CEEB)
  embed.set_author(name=f"{guild.name} Information!", icon_url = guild.icon_url)
  embed.set_thumbnail(url=guild.icon_url)
  embed.add_field(name="Server Owner", value=f"{guild.owner}", inline=True)
  embed.add_field(name="Server ID", value=f"{guild.id}", inline=True)
  embed.add_field(name="Server Region", value=f"{guild.region}", inline=True)
  embed.add_field(name="Categories", value=f, inline=True)
  embed.add_field(name="Text channels", value=c, inline=True)
  embed.add_field(name="Voice channels", value=d, inline=True)
  embed.add_field(name="Rules channel", value=f"{guild.rules_channel}", inline=True)
  embed.add_field(name="AFK channel", value=f"{guild.afk_channel}", inline=True)
  embed.add_field(name="Updates channel", value=f"{guild.public_updates_channel}", inline=True)
  embed.add_field(name="Members", value=a, inline=True)
  embed.add_field(name="Roles", value=b, inline=True)
  embed.add_field(name="Created at", value=i + "**UTC Time**", inline=True)
  embed.add_field(name="Boosts", value=f"{guild.premium_subscription_count}", inline=True)
  embed.add_field(name="Emojis", value=e, inline=True)
  embed.add_field(name="Emojis limit", value=f"{guild.emoji_limit}", inline=True)
  embed.add_field(name="Verification Level", value=f"{guild.verification_level}", inline=True) 
  embed.add_field(name="2FA", value=h, inline=True)
  await ctx.send(embed=embed) ```i want to round the created at
#

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: type datetime.datetime doesn't define __round__ method

placid skiff
slim whale
#

!d round

unkempt canyonBOT
#

round(number[, ndigits])```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.

For the built-in types supporting [`round()`](https://docs.python.org/3/library/functions.html#round "round"), values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.

For a general Python object `number`, `round` delegates to `number.__round__`.
slate swan
#

dose anyone have a reason why this is not working

placid skiff
#

What error it throw?
By yhe way there is no need, try this:

async def on_member_join(member)
    await ctx.member.send(message)
cloud dawn
#

isn't len(ctx.guild.roles) good enough?

slate swan
#

ah thx

slim whale
cloud dawn
bright palm
#

Why are you trying to round a datetime?

slim whale
slim whale
bright palm
#

What do you want it to be instead?

slim whale
cloud dawn
#

!d datetime.datetime.strftime

unkempt canyonBOT
#

datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
placid skiff
slim whale
cloud dawn
#

Did you click on the link?

slim whale
#

yes

bright palm
cloud dawn
#

This will still have decimals and please don't spoonfeed

slate swan
#

How to get a member's custom status and about me?

bright palm
#

!e ```py
from datetime import datetime

print(datetime.now())
print(datetime.now().replace(microsecond=0))

unkempt canyonBOT
#

@bright palm :white_check_mark: Your eval job has completed with return code 0.

001 | 2021-10-22 16:15:39.989997
002 | 2021-10-22 16:15:39
cloud dawn
#

Well time to go to the js server

devout iris
#

How can i host my bot for free?

slim whale
warm torrent
#

hello I'm a python beginner and i'm developping a discord bot buit i have a problem : I want my bot to send a message every day on a fixed hour and i did not find a way to achieve it despite my researchs on stack overflow. can you please help me ?

devout iris
slim whale
# bright palm `created = ctx.guild.created_at.replace(microsecond=0)`

where? doesnt workpy @bot.command() async def serverinfo(ctx): guild = ctx.guild a= len([m for m in ctx.guild.members if not m.bot]) b= len([r for r in ctx.guild.roles]) c= len([c for c in ctx.guild.text_channels]) d= len([d for d in ctx.guild.voice_channels]) e= len([e for e in ctx.guild.emojis]) f= len([f for f in ctx.guild.categories]) g= ctx.guild.mfa_level h= "a" if g == 0: h = "No" else: h = "Yes" created = ctx.guild.created_at.replace(microsecond=0) embed = discord.Embed(colour=0x87CEEB) embed.set_author(name=f"{guild.name} Information!", icon_url = guild.icon_url) embed.set_thumbnail(url=guild.icon_url) embed.add_field(name="Server Owner", value=f"{guild.owner}", inline=True) embed.add_field(name="Server ID", value=f"{guild.id}", inline=True) embed.add_field(name="Server Region", value=f"{guild.region}", inline=True) embed.add_field(name="Categories", value=f, inline=True) embed.add_field(name="Text channels", value=c, inline=True) embed.add_field(name="Voice channels", value=d, inline=True) embed.add_field(name="Rules channel", value=f"{guild.rules_channel}", inline=True) embed.add_field(name="AFK channel", value=f"{guild.afk_channel}", inline=True) embed.add_field(name="Updates channel", value=f"{guild.public_updates_channel}", inline=True) embed.add_field(name="Members", value=a, inline=True) embed.add_field(name="Roles", value=b, inline=True) embed.add_field(name="Created at", value=f"{ctx.guild.created_at} **UTC Time**", inline=True) embed.add_field(name="Boosts", value=f"{guild.premium_subscription_count}", inline=True) embed.add_field(name="Emojis", value=e, inline=True) embed.add_field(name="Emojis limit", value=f"{guild.emoji_limit}", inline=True) embed.add_field(name="Verification Level", value=f"{guild.verification_level}", inline=True) embed.add_field(name="2FA", value=h, inline=True) await ctx.send(embed=embed)

slim whale
devout iris
#

Ah

slim whale
#

xd

#

@bright palm a

#

ah

#

XD

#

now i know

warm torrent
slate swan
slim whale
#

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'str' @bright palm

#

embed.add_field(name="Created at", value= created + "**UTC Time**", inline=True) did this

bright palm
pure plover
#

How to add custom status in bota like playing a game

#

???

bright palm
slim whale
pure plover
pure plover
#

Plss tell

#

๐Ÿฅบ๐Ÿฅบ

slim whale
bright palm
#

No

slim whale
#

listening*

#

spoonfeeding u ๐Ÿ˜ก

warm torrent
pure plover
#

@bot.event
async def on_ready():
command_prefix="!"
await bot.change_presence(activity=discord.Activity(
type=discord.ActivityType.listening,
name=f"{command_prefix}help"))

#

This?

slate swan
#

@pure plover

await bot.change_presence(activity=discord.Game(name="a game"))

slate swan
warm torrent
slate swan
#

@slim whale activity

bright palm
slate swan
#

Lol

slim whale
#

bRUH

slate swan
#

Haha

slate swan
viral pebble
#

how can I count the voice time that the users have done?

brittle ingot
#

get the datetime they join the VC and the datetime they leave and find the difference, store that in a Database?

boreal ravine
#
    @commands.Cog.listener()
    async def on_message(self, message: disnake.Message):
        guild = self.bot.get_guild(880030618275155998)
        owner = guild.get_role(884679735366533151)

        if len(message.mentions) > 5:

           # if owner in message.author.roles:
            #    print(f"Owner mentioned {message.mentions} people.")
            #    return

            await message.delete()
            await message.channel.send(
                f"Too many mentions! {message.author.mention}", delete_after=7
            )

``` no errors, but why does this not work?
slate island
#

somebody who can help me with a piece of code made in Discord? Might be the easiest for you! ๐Ÿ˜› pm if possible?

slate swan
#

what did you do in discord kayle

boreal ravine
boreal ravine
#

primarily me

slate swan
#

maybe set an else to the if statement with something

boreal ravine
#

ohhhh

slate swan
#

maybe that returned false

boreal ravine
#

i figured out why

#

if you pinged yourself

#

it doesn't trigger

#

BUT if you pinged 5 other people then it'll work

slate swan
#

it would count as one if you ping the same person multiple times

#

innit

boreal ravine
#

hm

slate island
#

How come the top part of the code gets disabled (the client.command)s. When I add the client.event

slate swan
#

!d discord.Message.mentions

slate island
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

sick birch
slate swan
#

doesn't say anything about that

sick birch
#

you have to add client.process_commands(message) as the last line in the on_message

slate island
#

Then what do I do?

slate swan
#

change @bot.event to @bot.listen()

sick birch
#

that works too

slate swan
#

above on_message

slate island
#

so client.listen()?

sick birch
#

i find using listeners easier but use client.event if you want

slate swan
#

yes

slate island
#

Let me try!

#

It says command doesnt exist. the !add command.

#

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "add" is not found

boreal ravine
sick birch
#

can we see your code for that command?

slate island
#

When doing client.listen().

#

Its in the link I sent.

boreal ravine
#

you should probably

#

make a command, not an event for that type of thing

#

iirc on_message doesn't receive args but im not sure

slate island
#

Then I have to change it completely.. so it would be better if it could just work.

sick birch
#

you should use the commands extension

boreal ravine
#

^

slate island
#

?

boreal ravine
#

the commands extension lets you have multiple arguments in a command

#

like what you did earlier

sick birch
#

you're just gonna keep running into more and more issues like this

#

better switch now and save yourself the headache down the line

slate island
#

But I don't know how I would change it. I tried, but I hit a wall everytime I try change it to a command.

boreal ravine
#

it's like making a function

sick birch
#

perhaps you haven't read the documentation yet

boreal ravine
#

but in discord

sick birch
#

it has excellent command examples

boreal ravine
#

^ or just read the examples folder

sick birch
#
@bot.command()
async def echo(ctx, arg1):
  await ctx.send(arg1)
#

very simple echo function

boreal ravine
#

yes

slate island
#

Would the client.process_commands(message) maybe work?

boreal ravine
#

you can add more parameters to it

boreal ravine
slate island
#

I know how to make a bot.command function, but with the current code and what I want it to do, it gives tons of errors.

sick birch
#

like what?

boreal ravine
#

show us

#

didn't you already have commands earlier?

#

just use that as an example

sick birch
#

yeah you already have commands in your code

#

i'm looking at the pastebin one

#

why not just make more of that

slate island
#

Robin J, as you can see the client.event one is for a google sheet api

#

So thats why with command I would have issues doing what im doing.

sick birch
#

i don't see why you would have issues with that

#

you can still interact with the API from within commands

#

nothing is limiting you from doing so

slate island
#

Let me show you errors I get.

sick birch
#

do

slate island
#

How do I put it in quote here?

#

Like in a box the piece of code error?

sick birch
#
you mean like this?
slate island
#

Yep!

sick birch
#

```
stuff
```

slate island
#
Traceback (most recent call last):
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Sebastian\Desktop\DiscordBot\bot.py", line 92, in add
    if message.content.startswith('!add '):
AttributeError: 'Context' object has no attribute 'content'

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

Traceback (most recent call last):
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'content'
sick birch
#

yeah the first argument of a command is the context

#

not the message

slate island
#

So what do I do?

sick birch
#

use the context object rather than the message

slate swan
#

ctx.mesage.content

boreal ravine
#

oh

slate island
#

Its the:

#

message.content.startswith

slate swan
#

Yup

#

Just add ctx

slate island
#

So I made it? message.context.startswith ?

sick birch
#

no the issue here is they're doing startswith inside of a function

slate island
#

ok

sick birch
#

you can remove that whole part d.py handles that behind the scenes for you

slate swan
#

add ctx at first

boreal ravine
#

why not just make a command wtf

slate island
#

so ctx.message.context.startswith ?

#

It is a command im making.

slate swan
#

Yup

sick birch
#

just get rid of all your startswith and use commands

slate swan
#

Wait...

boreal ravine
#

its this easy

async def function(ctx, first, second, third, fourth):
```??
slate swan
#

@slate island you using Client()?

sick birch
#

exactly

boreal ravine
slate swan
#

Ohh

slate island
#
async def add(ctx):
    if message.author == client.user:
        return

    # Command to insert data to excel
    if ctx.message.content.startswith('!add '):
        SPREADSHEET_ID = 'idhere' # Add ID here
        RANGE_NAME = 'A1'
        FIELDS = 2 # Amount of fields/cells

        # Restrict the command to a role
        # Change REQUIREDROLE to a role id or None
        REQUIREDROLE = None
        if REQUIREDROLE is not None and discord.utils.get(message.author.roles, id=int(REQUIREDROLE)) is None:
            await message.channel.send('You don\'t have the required role!')
            return
    
        # Code
        msg = message.content[3:]
        result = [x.strip() for x in msg.split(',')]
        if len(result) == FIELDS:
            # Add
            print(message.created_at)
            DATA = [message.author.name] + [str(message.author.id)] + [str(message.created_at)] + result
            sheet.add(SPREADSHEET_ID, RANGE_NAME, DATA)
            await message.channel.send('Your data has been successfully submitted!')
        else:
            # Needs more/less fields
            await message.channel.send('Error: You need to add {0} fields, meaning it can only have {1} comma.'.format(FIELDS,FIELDS-1))```
sick birch
slate island
#

This is what I have so far.

slate swan
#

I had a heart attack lmao

sick birch
#

message isn't a variable

#

the 3rd line

#

use ctx.message instead

slate island
#

so its if ctx.author ?

#

ok ctx.message.author ?

sick birch
#

also why do you need startswith if it's inside the command

boreal ravine
sick birch
#

you're effectively checking if the message contents starts with "!add" twice

slate island
#

So everywhere in the code it says message.somethinghere

#

has to be: ctx.message.somethinghere

sick birch
#

correct

slate island
#

Let me try.

oblique adder
#

how do i get the invite code and the inviter in an on_member_join event ?

brazen seal
#

why this not work when user isn't on the server?

sick birch
boreal ravine
brazen seal
sick birch
#

error handler?

boreal ravine
oblique adder
brazen seal
boreal ravine
#

i dont know

boreal ravine
sick birch
#

then you know which invite they used to join

slate island
#

Doesn't work. Nothing happens. No errors either.

sick birch
#

not helpful

slate island
#
async def add(ctx):
    if ctx.message.author == client.user:
        return

    # Command to insert data to excel
        SPREADSHEET_ID = 'idhere' # Add ID here
        RANGE_NAME = 'A1'
        FIELDS = 2 # Amount of fields/cells

        # Restrict the command to a role
        # Change REQUIREDROLE to a role id or None
        REQUIREDROLE = None
        if REQUIREDROLE is not None and discord.utils.get(ctx.message.author.roles, id=int(REQUIREDROLE)) is None:
            await ctx.message.channel.send('You don\'t have the required role!')
            return
    
        # Code
        msg = ctx.message.content[3:]
        result = [x.strip() for x in msg.split(',')]
        if len(result) == FIELDS:
            # Add
            print(ctx.message.created_at)
            DATA = [ctx.message.author.name] + [str(ctx.message.author.id)] + [str(ctx.message.created_at)] + result
            sheet.add(SPREADSHEET_ID, RANGE_NAME, DATA)
            await ctx.message.channel.send('Your data has been successfully submitted!')
        else:
            # Needs more/less fields
            await ctx.message.channel.send('Error: You need to add {0} fields, meaning it can only have {1} comma.'.format(FIELDS,FIELDS-1))
brazen seal
sick birch
sick birch
#

ah you know why

slate island
#

lines 3 and 4?

sick birch
#

everything afterwards is indented

#

so the whole code will only run if you send the command

brazen seal
sick birch
#

which you never will

slate island
#

Sooo?

sick birch
sick birch
# slate island Sooo?

fix your indent, and remove the part where it checks if the bot is the one sending the message

slate island
#

So just remove line 3 and 4?

sick birch
#

and fix your indents, yes

slate island
#

which indents?

sick birch
#

everything in the command is indented into the if block

#

so everything only runs if ctx.message.author == client.user

brazen seal
#

what i should to in do the bot can see the user?

sick birch
#

actually you should be getting unreachable code error

slate island
#

Yeah, but what lines for example. I just removed line 3 and 4.

slate swan
#

please don't use ableist language here

sick birch
sick birch
slate island
sick birch
#

you see where it says # Command to insert data to excel

#

deindent starting from there to the end of the command

slate island
#

I don't see the indents you are talking about. Sorry. :S

#

Because it seems to work fine now.

#

After I removed line 3 and 4.

#

Anything I have to be aware of? Because it seems to work sir.

brazen seal
dapper cobalt
brazen seal
slate swan
#

discord.User

dapper cobalt
#

My bad, it's a capital U. My keyboard lagged.

zenith zinc
#

hii

brazen seal
#

not

dapper cobalt
#

Show your full code?

brazen seal
dapper cobalt
#

Use await ctx.guild.ban(user, reason=reason).

#

And also you can do member.mention instead of BannedUser = f"<@{member}>".

zenith zinc
#

HII

dapper cobalt
#

!d discord.User.mention

unkempt canyonBOT
#

property mention: str```
Returns a string that allows you to mention the given user.
dapper cobalt
#

Still what?

brazen seal
#

still not work

sick birch
#

it can't convert to a discord.User if it can't see the user

dapper cobalt
#

Define 'doesn't work'.

#

What error do you get?

valid niche
brazen seal
dapper cobalt
#

Do you have any error handlers?

brazen seal
#

what is it?

sick birch
dapper cobalt
#

Ah, can you please put your code inside a try...except and raise the exception?

valid niche
dapper cobalt
#

Well, instead of making a whole error handler, they want to just know what's wrong with this command.

slate island
#

@sick birch the code works when I removed line 3 and 4. How come it works when I didnโ€™t change the indents?

valid niche
#

most people will have their error handler in a separate cog, and unloading that cog would do the trick

dapper cobalt
#

I don't think they know how to use cogs.

brazen seal
#

yes, i'm still beginner so thats why i ask you for help

dapper cobalt
#

except Exception as e: raise e

lament mesa
#

What's the use of a try block if you are only re-raising the same exception?

slate swan
#

I have a question if there is any other way to check the permissions than @has_permission(permission=True)?

#

why

ancient olive
#

TypeError: Cannot read property '1' of null
at Object.<anonymous> (/root/bot/heroku/app.js:7:113)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47

const version = new RegExp("VERSION.{0,}=.{0,}'(.*)'").exec(fs.readFileSync(path.join(__dirname, '/../bot.py')))[1] // Get DiscordGSM verison from bot.py
#

I can't figure out why this is happening can you help me

slate swan
ancient olive
#

Ah sorry

brazen seal
unkempt canyonBOT
#

Hey @half tide!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

half tide
slate swan
#
            activity_type = ""
            try:
                if arg.activity.type == "ActivityType.watching":
                    activity_type = "Watching "
                elif arg.activity.type == "ActivityType.listening":
                    activity_type = "Listening "
                elif arg.activity.type == "ActivityType.playing":
                    activity_type = "Playing "
                elif arg.activity.type == "ActivityType.streaming":
                    activity_type = "Streaming "
                elif arg.activity.type == "ActivityType.custom":
                    activity_type = "Custom "
                elif arg.activity.type == "ActivityType.competing":
                    activity_type = "Competing"
            except AttributeError as e:
                print(e)
                activity_type = ""

            embed.add_field(name="Activity:", value=f"{activity_type}{arg.activity.name}", inline=True)

Hi, this is a info command, so when I do -info @mention it's going to send an embed with the mentioned users information. arg is either a discord.Member or discord.User. I'm trying to get the name of the activity type, but when I run the command on someone who has a activity, it sends only the arg.activity.name and not the type, which means that except is ran no matter what, and if the user doesn't have an activity, I get this following error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'name'
Traceback:

embed.add_field(name="Activity:", value=f"{activity_type}{arg.activity.name}", inline=True)
AttributeError: 'NoneType' object has no attribute 'name'

I've tried few ways to solve this but it doesn't work, any1 who could help me with this?

hasty iron
#

arg.activity is None

slate swan
#

Yes I know that

hasty iron
#

then it should be pretty easy to fix no?

slate swan
#

I have this, How do I make it so it deletes the 7 day old logs (ping me)

#

I said I tried, but I couldn't fix this, otherwise why would I ask for help? You need to understand this, I've seen u a few times trying to "help" but what you're really doing @hasty iron is making people regret asking because YOU expect us (newbies) to know every thing. Keep it nice instead and help, or if you don't want to help then shut up and move on

hasty iron
#

the library doesnโ€™t expect you (newbies) to use it

#

it expects you to have some knowledge

#

and the fix requires a single if statement

#

i donโ€™t know if thatโ€™s hard or not

slate swan
#

Oh really, so newbies shouldn't learn? Because that's how everyone starts right? You're logic is that if you don't know, don't do it. Right, but what if I try my best? And if I can't make it, I ask for help, this is what this channel is for. You're not welcoming people that's new to this library which literally is against the #code-of-conduct

#

Anyways, I'll ask in another server, ty tho

hasty iron
#

what? newbies shouldnโ€™t learn?

#

youโ€™re literally avoiding the whole point

#

to use discord.py you need knowledge and you apparently donโ€™t have it

slate swan
#

I don't have it because I couldn't find a solution to my issue? This is the first time I ran to this issue how am I supposed to know? This is the first time I coded a discord bot? What you have been saying to me the whole day, even when I asked for help before, is questioning my skill? I told you I'm new, all I'm trying is to get help

hasty iron
#

dude

dapper cobalt
#

Well, you should help yourself at the start.

hasty iron
#

learn python before using it

#

!resources

slate swan
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

hasty iron
#

and as i said, this requires a literal single if statement

dapper cobalt
#

You didn't help yourself, because you haven't learnt Python before jumping into a higher level than newbie level library.

slate swan
#

I literally took a basic python course in school, I'm completely new to this library and I'm asking for help wtf?

hasty iron
#

wow and you still donโ€™t get the point

slate swan
#

So what you're saying is basic python isn't enough for discord.py?

hasty iron
#

yes it isnโ€™t

slate island
#
async def add(ctx):

    # Command to insert data to excel
        SPREADSHEET_ID = 'idhere' # Add ID here
        RANGE_NAME = 'A1'
        FIELDS = 2 # Amount of fields/cells

        # Restrict the command to a role
        # Change REQUIREDROLE to a role id or None
        REQUIREDROLE = None
        if REQUIREDROLE is not None and discord.utils.get(ctx.message.author.roles, id=int(REQUIREDROLE)) is None:
            await ctx.message.channel.send('You don\'t have the required role!')
            return
    
        # Code
        msg = ctx.message.content[3:]
        result = [x.strip() for x in msg.split(',')]
        if len(result) == FIELDS:
            # Add
            print(ctx.message.created_at)
            DATA = [ctx.message.author.name] + [str(ctx.message.author.id)] + [str(ctx.message.created_at)] + result
            sheet.add(SPREADSHEET_ID, RANGE_NAME, DATA)
            await ctx.message.channel.send('Your data has been successfully submitted!')
        else:
            # Needs more/less fields
            await ctx.message.channel.send('Error: You need to add {0} fields, meaning it can only have {1} comma.'.format(FIELDS,FIELDS-1))```
#

How come this piece of code

#

when i type !add test test

dapper cobalt
slate island
#

it adds into the spreedsheet d test test

#

it adds a d into field 1? Where is the d from?

dapper cobalt
slate island
#

I know, but it shouldnt only for certain situations.. so thats why I left it in and put none on it atm.

#

But into the spreedsheet when i type !add test test

#

it adds into field 1: d test and field 2: test

#

Where does the d come from?

slate swan
#

I don't understand this logic, how do you guys expect someone to learn the library if they don't try? They will fail somewhere and I failed here, and I need help and you don't provide it because I have basic python knowledge and not intermediate? There is literally something I don't know how to fix, and this happens to everyone even if you're pro in pything

hasty iron
#

right if statements are related to the discord.py lib only

slate island
#

You know why @dapper cobalt ?

dapper cobalt
#

What do you save in the spreedsheet? Which variable?

slate island
#

When I type !add test, test

dapper cobalt
#

Can you please use syntax highlighting? I can't read your code properly.

#

!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 island
#

it adds:

#

I did use that.

#

The "d" shouldnt be there.

dapper cobalt
#

msg = ctx.message.content.replace("add", "") try that.

#

It takes the d at the end of 'add'.

slate island
#

Should i add it or change it with something?

hasty iron
#

or you can strip it too

dapper cobalt
#

Index starts from 0 and not 1.

slate island
#

You talking to me?

dapper cobalt
#

No, I'm talking to my cat, his name is Soly.

slate island
#

Atm it is:

msg = ctx.message.content[3:]

#

Oh hi Soly!

dapper cobalt
#

Change it to msg = ctx.message.content.replace("add", "").

slate island
#

Let me try. ๐Ÿ˜„

slate island
#

It kinda worked KeyError.

#

now it just adds the !

#

So when i type !add hey, hey it says:
field 1: ! hey
field 2: hey

#

Fixed it!

#

Thanks โค๏ธ

zenith zinc
#

nice

half tide
#

@hasty iron

slate island
#

I could also just have changed the 3: to 4: โค๏ธ

#

Cheers โค๏ธ

dapper cobalt
slate swan
#

scoopy?

#

nice

half tide
#

Someone please i need help

dapper cobalt
dapper cobalt
half tide
dapper cobalt
#

Line?

#

Or just show the full traceback?

manic wing
#

scoopy I love your website

slate swan
#

i hate the kids in dpy, he said i was a skid because of my about me

#

as soon as i called him a skid he got butt hurt and made a mod ban me

manic wing
#

lol

dusky elk
#

Is anyone aware of a public fork of discord py that is being actively updated and has interactions implemented?

hasty iron
slate swan
#

there are mad forks of discordpy

hasty iron
dusky elk
#

ah..

slate swan
#

disnake? never hurd of it

dusky elk
#

oh man I was hoping I could just migrate to a fork

#

pain

dapper cobalt
pliant gulch
#

If you have knowledge of the API you can also just impl interactions yourself,

dapper cobalt
unkempt canyonBOT
pliant gulch
#

I mean dpy already dispatches the interaction event

#

Just need to parse that data

dusky elk
dusky elk
slate swan
#

it's a fork

#

usually when they fork they don't change stuff they just add stuff

manic wing
#

if you hate the dpy kids why are you here?

slate swan
#

i meant the kids that assume your a skid because od your about me on discord.com

hardy yoke
slate swan
#

^

#

lol

hardy yoke
slate swan
#

Do like me, switch language

#

I already switched language when it started to get an update every century

hasty iron
#

i donโ€™t think switching a language because of discord bots is worth it

rare saddle
#

How to make a change that will represent the guild?

manic wing
#

elaborate

rare saddle
#

How to make sure that if a person does not change the prefix for the bot, then use the standard prefix, and if changed the custom one

slate swan
#

I love that custom_prefix variable

manic wing
#

its spelt default

slate swan
#

how i can do it ? how to remove the line? like in the picture? on python

slate swan
#

maybe set the color to the embed color

manic wing
#

the embed line?

slate swan
#

i don't wanna this line

#

that probably only works without betterdiscord

manic wing
#

you just do defaultcolor

#

3553599

slate swan
edgy lion
manic wing
#

i dont know why it is nonetype at all, and im just gonna throw this out there - maybe bot isn't ready?

thick sigil
#

api wrapper

manic wing
#

he stopped his ages ago

#

๐Ÿ™‡ to andy

slate swan
#

Do you guys know how to translate html color into python, that is, I have the color 2f3136 and when I insert it into embed, an error appears SyntaxError: invalid syntax

hardy yoke
slate swan
#

sure

#

emb = discord.Embed(color=2f3136)

#

0x2f3136

slate swan
hardy yoke
mortal dove
#

Can someone give me the right format for a commands.Cog.listener()? I totally forgot what the correct arguments for it are, and I don't have any examples on hand in my code.

@commands.Cog.listener()
    async def on_message(message): # <- What else here?
    ...
    await bot.process_commands(message)
#

Currently gets TypeError: on_message() takes 1 positional argument but 2 were given

slate swan
#

self, message

mortal dove
#

huh

#

alr ty

slate swan
#

In the parameters, add self

hardy yoke
# rare saddle okay, thanks

make sure you have a backup inside get_prefix as well if you go that route. If your bot joins a server while the bot is offline, the on_guild_event won't run. So in the event that a guild is not found in the db, you can add it within get_prefix

Does this make sense? IDK, but that's how I do it

thick sigil
manic wing
#

Caeden, who are you?

thick sigil
#

your idol's teacher

manic wing
#

mhmmmm

#

who said scoopy was my idol

#

he's just a nice dude

slate swan
#

hey! Anyone here familiar with discord buttons?

#

Bro, I found this:

2021-10-22 13:48:46,243:INFO:nextcord.gateway: Websocket closed with 1000, cannot reconnect.
2021-10-22 13:48:46,243:ERROR:nextcord.client: Attempting a reconnect in 470.44s
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/nextcord/client.py", line 515, in connect
    await self.ws.poll_event()
  File "/home/container/.local/lib/python3.9/site-packages/nextcord/gateway.py", line 585, in poll_event
    raise ConnectionClosed(self.socket, shard_id=self.shard_id, code=code) from None
nextcord.errors.ConnectionClosed: Shard ID None WebSocket closed with 1000
valid niche
#

so it just lost connection for a bit

slate swan
#

Ah

#

so thats been happening this entire time

valid niche
#

and as you can see at the top it says attempting reconnect in 470 seconds hence why you see it reconnect after a while

slate swan
#

yup

valid niche
#

but yeah it's an unknown error so idk how to solve it

slate swan
#

got a solution or do I need to deal with it?

#

ok

valid niche
#

you can ask discord if they have more insight, but i doubt it

slate swan
#

ok

#

is it jsut me or on mobile i can't open the dev portal

valid niche
#

works fine for me

slate swan
#

it lets me login i do the captcha and then takes me back to login

#

๐Ÿค”

#

disable your adblocker

#

i'm on mobile

#

Doesn't prove anything

#

I have ad blocker on mobile 3HC_waitwhat

#
@avatar.error
async def avatar(ctx, error, member : discord.Member = None):
    if isinstance( error, discord.ext.commands.errors.MemberNotFound ):
        memberavatar = member.avatar_url

        emb = discord.Embed(color=0x2f3136)
        emb.set_image(url = memberavatar)
        emb.set_author(name = f"{member.name}", icon_url = memberavatar)
        emb.timestamp = datetime.utcnow()

    await ctx.send(embed = emb)```help?
error:
`discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'avatar_url'`
#

If the member is not found, why do you try to get it's avatar

hasty iron
#

its an error handler anyways

slate swan
#

And yeah, error handlers don't take custom parameters

slate swan
slate swan
#
@avatar.error
async def avatar(ctx, error, member : discord.Member = None):
    if isinstance( error, discord.ext.commands.errors.MemberNotFound ):
        emb = discord.Embed(color=0x2f3136)
        emb.set_author(name = f"s", icon_url=member.avatar_url)
        emb.timestamp = datetime.utcnow()

    await ctx.send(embed = emb)```
`discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'avatar_url'`
help?
manic wing
#

i'm pretty sure someones already told you what to do

#

do you mean if not isinstance?

slate swan
#

what?

#

...

#

You're kind of checking if it's none and if it's none then you send stuff

#

I want the bot to show the author's avatar_url

#

And error handlers don't take any parameter you wish

slate swan
#

You should use @commands.command for sending the answer to your command and use @avatar.error to check for possible errors

#

Use a normal @commands.command decorator

#

What you're doing now is basically only send the avatar when the member is not found, which makes no sense at all and obviously throws a NoneType error

#

so how do I get the bot to show the author's avatar.url?

#

what i need use?

#

i need use embed.add_field?

kindred epoch
#

embed.set_image

rain olive
#

do u have member intents

kindred epoch
#

!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.
shy roost
#

can't find any proper examples of code in the docs of discord.py

#

of creating a thread

#

for a message, as I'm trying to create my own modmail bot

#

could someone send me some code on just the basics of creating a thread when a command is called?

#

so like, I want the bot to send the actual message to the moderators or people with mod+ perms in my server, which I don't understand how I can do.

slate swan
#

!d help

unkempt canyonBOT
#

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

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

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

ok

placid skiff
#

How to combine two lists of strings?

slate swan
#

how do you make your bot dm people

slate swan
unkempt canyonBOT
#

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

Creates a public thread from this message.

You must have [`create_public_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_public_threads "discord.Permissions.create_public_threads") in order to create a public thread from a message.

The channel this message belongs in must be a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel").

New in version 2.0.
slate swan
slate swan
shy roost
#

ah okay, @slate swan is there also a method to reply to a thread? I want a moderator to be able to respond to a thread that a person has created.

slate swan
#

Wdym

shy roost
#

like is there a method so that a user that runs a command that replies to a thread, can pass a message argument to a method to automatically do that ?

#

like if I were to use a method to make a command pass a message onto a user who started a thread

slate swan
#

So you want the user that created the thread?

slate swan
slate swan
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**.
shy roost
# slate swan So you want the user that created the thread?

no, I want another person, a moderator+, to be able to reply to the person who started the thread's thread. So if a user runs a command to start a thread in dms with the bot, that message will be passed onto the moderator/staff of that server, and the moderator can reply to that thread

#

that's my end goal, I could just copy some code from github, but I want to write this kind of stuff on my own, since I haven't work with d.py in ages lmao

slate swan
#

Oh i see

#

The moderator can just join that thread?

shy roost
#

is there a method for that?

slate swan
#

Yeah, he goes to the thread and clicks join ๐Ÿ˜‚

shy roost
#

no, I want the mod to receive a dm with the message, and this way they can reply to the specific user through the bot, such as passing their message in dms with the bot, and the bot will then pass the message back to the user who sent the report.

#

that's the point of dms in moderation right? So you can report in private without others seeing your issue.

slate swan
#

You can't create threads in dms

shy roost
#

ah okay, so how can I achieve this end goal?

#

i might've seen wrong earlier on a os project on github, since I thought you had to create a thread in dms lmao

slate swan
#

Simply make it so whatever the user sends a message in the bot's dm it takes the message and sends it somewhere else, either in a staff channel or in a moderator's dms

#

ok well ... nevermind

slate swan
shy roost
slate swan
#

As i already told the guy from earlier, .send on the member

shy roost
#

I don't think I have to check whether it's in dms or a public channel, since the user can decide that, and with bots that run on d.py's built-in ability to run their commands with someone calling them in cdms.

slate swan
#

!d discord.Member.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**.
shy roost
slate swan
#

Yw

shy roost
#

how can I check if a bot has received a dm?

#

that's where I'm kinda confused lmao

slate swan
#

Check if the channel is a dm channel

shy roost
#

and how can I do that?

slate swan
#

Using on_message

#

And isinstance

shy roost
#

ah okay

#

what instance would a dm message be?

slate swan
#

!d discord.DMChannel

unkempt canyonBOT
#

class discord.DMChannel```
Represents a Discord direct message channel.

x == y Checks if two channels are equal.

x != y Checks if two channels are not equal.

hash(x) Returns the channelโ€™s hash.

str(x) Returns a string representation of the channel
slate swan
#

oh sorry i ment its fine

#

imma just rewrite my code

shy roost
slate swan
#

Yw

slate swan
shy roost
#

so in the on_message event, I can simply check for whether or not the message sent is a dm message, or a channel message right?

#

and if it's a dm message, I can run the command?

slate swan
#

Yeah

#

Wait you want it in a command?

shy roost
#

yeah

slate swan
#

Oh

shy roost
#

the report feature

slate swan
#

Then use ctx.channel

wicked atlas
#

There is also a check im pretty sure for if a command is run in a dm

slate swan
#
if isinstance(ctx.channel, discord.DMChannel):
   ...
shy roost
#

couldn't I just do that in a command itself

slate swan
#

That's where you're doing it

shy roost
#

okay, let me give it a shot. I will tell you how it goes.

wicked atlas
#

!d discord.ext.commands.dm_only

unkempt canyonBOT
#

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

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

New in version 1.1.
slate swan
#

ok now that might help me

shy roost
shy roost
#

@wicked atlas

wicked atlas
#

Just make sure they go under the command() decorator

kindred epoch
#

its @commands.dm_only()

wicked atlas
#

Well, unless you import the decorator

shy roost
wicked atlas
#

But you could do that

kindred epoch
#

ohk

shy roost
wicked atlas
#

Well, that was poorly worded, I just meant you could do either of the following

from discord.ext.commands import dm_only

from discord.ext import commands
commands.dm_only()
shy roost
slate swan
#
@bot.command()
async def avatar(ctx, member : discord.Member = None):
    async with ctx.typing():
         await asyncio.sleep(0.5)
    if member == None:
        member = ctx.author
        memberavatar = member.avatar_url


        emb = discord.Embed(color=0x2f3136)
        emb.set_image(url = memberavatar)
        emb.set_author(name = f"{member.name}", icon_url = memberavatar)
        emb.timestamp = datetime.utcnow()

    await ctx.send(embed = emb)

how do I create an animation of a bot so that it type after the command await await asyncio.sleep(0.5) and after that it has already written the code itself.