#discord-bots

1 messages · Page 615 of 1

jade crater
#

define client as discord.Client

lethal moat
#

oh yeah he forgot to do that too

slate swan
#

delete the image , it has your token ( in case you already didnt regen it)

#

thanks, just realized

lethal moat
#

🥲

lethal moat
slate swan
#

Nice profile picture haha

lethal moat
#

add
client = discord.Client
just below
import discord

#

also your indentation is still wrong... check the if statements

#

after fixing that, try running the bot then

jade crater
lethal moat
#

his name is a reference to the state of his code

velvet tinsel
#

how to get timezone of ctx.author using the pytz module?

slate swan
#

i cant sem to fix the indentation

velvet tinsel
#

it keeps saying I have to use UTC

quick gust
#

@slate swan I suggest learning the basic python syntax first....

velvet tinsel
#
@client.event
async def ...
slate swan
#

how did i not see that...

supple thorn
#

👁️

velvet tinsel
#

it's simple

#

you need to learn basic python syntax

slate swan
velvet tinsel
#

jumping to the harder stuff = not recommended

velvet tinsel
jade crater
slate swan
#

aight then, thanks for the help

jade crater
lethal moat
supple thorn
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.

quick gust
lapis frigate
#

Is there an on_member_connect_voice_channel event?

jade crater
#

!d discord.on_voice_state_update

unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
jade crater
lapis frigate
#

thnks

#

*thanks

simple surge
#

hello

#

i am trying to use slash commands

quick gust
simple surge
#

ok sorry

quick gust
simple surge
#

it only works in one server

#

but the others doesnt

jade crater
quick gust
#

what library first of all

lethal moat
#

!d discord.Interaction

unkempt canyonBOT
#

class discord.Interaction```
Represents a Discord interaction.

An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.

New in version 2.0.
lethal moat
#

!d discord.Interaction.user

unkempt canyonBOT
jade crater
simple surge
#

the slash commands one

lethal moat
jade crater
simple surge
#

client

jade crater
simple surge
#

one sec ill send code

#
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext

intents = discord.Intents.default()
intents.members = True
prefix = 'z!'
client = commands.Bot(command_prefix='z!', intents=intents)
slash= SlashCommand(client,sync_commands=True)

@slash.slash(
    name="test",
    description="description"
)
async def test(ctx:SlashContext):
    await ctx.send("it worked!!!")
client.run(token)
quick gust
#

well I don't know this library so can't help, but afaik slash commands take ~1 hour to update globally so maybe it's that

#

again, not sure

simple surge
#

cause it only works on 1 server

simple surge
jade crater
#

smh

summer flume
#

what im doing wrong?

      hl = ctx.guild.channels
      takeguild = discord.Guild.channels(list[hl])

      await takeguild.set_permissions(ctx.guild.default_role, send_messages = False)
      emb = discord.Embed(title = "Server Lockdown 🔒", description = f"**{ctx.guild.name}** is now locked.", color = discord.Color.red())
      emb.add_field(name = "Message", value = message, inline = True)
      emb.set_footer(text = f"Locked by {ctx.author}")
      await ctx.channel.purge(limit = 1)
      await ctx.guild.channels.send(embed = emb)
jade crater
#

your not supposed to use the class

#

your supposed to use the object/instance of discord.Guild.channels

summer flume
#

hm

jade crater
summer flume
#

alright

jade crater
#
for channel in ctx.guild.text_channels:
  ...
#

since discord.Guild.text_channels returns a list your bot is gonna change every text channel till it's done

summer flume
#

okay

daring olive
#

hello, there is no recruitment or offers/asking for paid work of any kind on the server. please check #rules

lapis frigate
#

when I leave the channel in on_voice_state_update the code does not recognize that I was in the channel
this is my code:

async def on_voice_state_update(member, before, after):
    if before.channel==None:
        before_members=[]
    else:
        before_members=before.channel.members
    if after.channel==None:
        after_members=[]
    else:
        after_members=after.channel.members
    print(before_members)
    print(after_members)
    print(before.channel)
    print(after.channel)
    if before_members!=after_members:
        if member in before_members and member not in after_members:
            channel=client.get_channel(889215576487120956)
            await channel.send(f"{member.mention} leave the voice")
        elif member in after_members and member not in before_members:
            channel=client.get_channel(889215576487120956)
            await channel.send(f"{member.mention} joined the voice")```
when i joined it's work
lone aurora
brave moth
sage otter
#

!d discord.Guild.roles

unkempt canyonBOT
#

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

The first element of this list will be the lowest role in the hierarchy.
simple surge
brave moth
simple surge
#

ig i need to wait

#

it only work in my server

#

doesnt work in others

ocean leaf
#

I saw many bots having ss command and it takes the screenshot of the url provided. I also wanna make a command like that. Can anyone tell me how should I start?

brave moth
#

when inviting the bot, does it show create commands in a server?

simple surge
#

one sec

brave moth
#

and does it hav the use application commands perm enabled?

simple surge
brave moth
#

what happened to the this will allow bot to page?

simple surge
#

idk

#

one sec again

#

idk

#

this shows up to me

slate swan
#

Add the applications.command scope to the invite link

simple surge
#

i did

slate swan
#

Apparently not

simple surge
#

with another one

#

ill send screenshot

slate swan
brave moth
#

@simple surge go to the dc app portal, go to application, go to your bot, go to auth2, go to general and select applications.command to the scope

simple surge
slate swan
#

Not this

brave moth
#

when i tried to add your bot, it didnt show an allow bot to page

slate swan
#

The message before

#

This one

simple surge
#

oh

#

no nothing showed up

brave moth
simple surge
#

it shows now

#

it works

#

thanks

brave moth
#

good, now wait for about an hour for the slash cmds to load up in the servers kekatsuki

simple surge
#

its only in around 34 servers it doesnt rlly matter

brave moth
#

wow, 34 and mine is in 25

slate swan
#

hmm well

#

If the bot wasn't invited with the applications.commands scope in these servers

#

It won't create any slash command

brave moth
#

oh yeah

brave flint
#

um so i got a problem, i want to convert time to second with this code :
and shown error TypeError: can't multiply sequence by non-int of type 'dict'
can anyone tellme where is the problem

brave moth
#

act like they hav to invite it

brave moth
# brave flint um so i got a problem, i want to convert time to second with this code : and sho...
time_dict = {"h": 3600, "s": 1, "m": 60, "d": 86400}

class TimeConverter(commands.Converter):
    async def convert(self, ctx, argument):
        args = argument.lower()
        matches = re.findall(time_regex, args)
        time = 0
        for v, k in matches:
            try:
                time += time_dict[k]*float(v)
            except KeyError:
                raise commands.BadArgument(
                    "{} is an invalid time-key! h/m/s/d are valid!".format(k))
            except ValueError:
                raise commands.BadArgument("{} is not a number!".format(v))
        return time```
#

this is from my bot's repo

brave flint
#

well you cant spoonfeed code bro

brave moth
#

also import re and asyncio and let me know if it works

brave flint
#

but tq ill see

brave moth
lone aurora
#

can anyone tell me how this would be used

brave flint
lone aurora
#

oh um i mean how would it be used within the code

brave flint
lapis frigate
#

when I leave the channel in on_voice_state_update the code does not recognize that I was in the channel
this is my code:

async def on_voice_state_update(member, before, after):
    if before.channel==None:
        before_members=[]
    else:
        before_members=before.channel.members
    if after.channel==None:
        after_members=[]
    else:
        after_members=after.channel.members
    print(before_members)
    print(after_members)
    print(before.channel)
    print(after.channel)
    if before_members!=after_members:
        if member in before_members and member not in after_members:
            channel=client.get_channel(889215576487120956)
            await channel.send(f"{member.mention} leave the voice")
        elif member in after_members and member not in before_members:
            channel=client.get_channel(889215576487120956)
            await channel.send(f"{member.mention} joined the voice")```
when i joined it's work
how i can fix that?
maiden fable
ocean leaf
#

How to get the user status using discord.py? Not online or dnd. I am talking about text status

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").
maiden fable
#

!d discord.CustomActivity

unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.

x == y Checks if two activities are equal.

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

hash(x) Returns the activity’s hash.

str(x) Returns the custom status text.

New in version 1.3.
ocean leaf
#

Ok thanks

slate swan
#
    if ctx.channel.category != "category name":
        return

why this if statement does not work?

lapis frigate
slate swan
#

i want a command to be ran only under 1 category

maiden fable
maiden fable
#

!d discord.ext.commands.check

lapis frigate
unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
maiden fable
#

Use this (;

#

Make a check. Easy

maiden fable
lapis frigate
maiden fable
unkempt canyonBOT
lapis frigate
maiden fable
#

U can use the after arg

lapis frigate
#

but i'm not in the voice channel after

maiden fable
#

Ok so let's start from the starting... What do u want to achieve?

lapis frigate
maiden fable
#

Yea

lapis frigate
#

but it's not working

maiden fable
#

So u just wanna check if a member left a channel?

#

And not if he joined one?

lapis frigate
maiden fable
#

Okay

lapis frigate
#

the code:

@client.event
async def on_voice_state_update(member, before, after):
    if before.channel==None:
        before_members=[]
    else:
        before_members=before.channel.members
    if after.channel==None:
        after_members=[]
    else:
        after_members=after.channel.members
    print(before_members)
    print(after_members)
    print(before.channel)
    print(after.channel)
    if before_members!=after_members:
        if member in before_members and member not in after_members:
            channel=client.get_channel(889215576487120956)
            await channel.send(f"{member.mention} leave the voice")
        elif member in after_members and member not in before_members:
            channel=client.get_channel(889215576487120956)
            await channel.send(f"{member.mention} joined the voice")```
maiden fable
#

!code

#

Thanks

maiden fable
lapis frigate
#

thanls

fair axle
#

using dislash.py

@inter_client.slash_command(guild_ids=test_guilds, description="Button test")
async def button(inter):
    row_of_buttons = ActionRow(Button(style=ButtonStyle.green, label="Yes", custom_id="green_button"),
                               Button(style=ButtonStyle.red, label="No", custom_id="red_button"))
    await inter.send("Yes or No?", components=[row_of_buttons])
    inter = await inter.wait_for_button_click()
    button_text = inter.clicked_button.label
    await inter.reply(f"oh you have chosen {button_text}")

error:

inter = await inter.wait_for_button_click()
AttributeError: 'SlashInteraction' object has no attribute 'wait_for_button_click'

@ me in response

lapis frigate
maiden fable
#

If the person changed VCs

maiden fable
#

Faster Than You @slate swan :D

slate swan
#

me mobile

maiden fable
#

Same haha

slate swan
#

fawk

maiden fable
#

That's why I was ready

slate swan
#

unfair

maiden fable
slate swan
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

Sorry, music bots against ToS :c

slate swan
#

haha

maiden fable
#

Not making one (:

slate swan
#

pretty sure you meant wait_for("button_click")

maiden fable
#

No

slate swan
#

or smth like this

#

I don't use disnake

fair axle
#

dislash

#
    row_of_buttons = ActionRow(Button(style=ButtonStyle.green, label="Yes", custom_id="green_button"),
                               Button(style=ButtonStyle.red, label="No", custom_id="red_button"))
maiden fable
slate swan
#

same thing

slate swan
#

and I'm probably gonna switch to djs

dapper cobalt
slate swan
#

no

dapper cobalt
slate swan
#

yes

maiden fable
slate swan
#

yes

sullen shoal
#

js syntax kinda frustrating tbh

slate swan
#

no syntax

dapper cobalt
#

I use djs for my bot's dashboard. I learnt it for only the purpose of getting the bot's guilds and other things, and it's actually great and easy.

slate swan
#

js is just syntaxless

maiden fable
#

Lmao

sullen shoal
#

wha

dapper cobalt
maiden fable
#

Anyways let's leave this. It's OT

slate swan
#

sure

dapper cobalt
#

Indeed.

#

How to print my bot's name?

maiden fable
#

Or str(bot.user)

slate swan
#

he knew that

dapper cobalt
sullen shoal
#

i hope something adds function decorators to it at some point

fair axle
#
inter = await inter.wait_for("green_button")
    button_text = inter.clicked_button.label
    await inter.reply(f"great u slected {button_text}")
    inter = await inter.wait_for("red_button")
    button_text = inter.clicked_button.label
    await inter.reply(f"great u slected {button_text}")

now?

slate swan
dapper cobalt
#

Even this, you're bad at it. @maiden fable

unkempt canyonBOT
#
Not in my house!

No documentation found for the requested symbol.

maiden fable
#

Oh, weird

#

Hahahahahahahahaha

slate swan
#

huh

maiden fable
unkempt canyonBOT
#

property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
sage otter
# maiden fable No

What’s wrong with ffmpeg. It doesn’t do anything wrong like yt-dl. It’s just an audio transcoder

maiden fable
#

This is there tho

slate swan
#

yep

maiden fable
sullen shoal
#

because thats the docs

dapper cobalt
#

Ok I'm bad.

sullen shoal
#

.user returns discord.User

slate swan
#

hah

maiden fable
slate swan
#

me like: 😹

maiden fable
#

True

sullen shoal
#

it scrapes the webpage doesnt check like typehints and stuff of the actual code

sage otter
#

I though that’s what YouTube-dl does tho. You use the two in tandem because they do seperate things. yt-dl downloads and ffmpeg for audio.

maiden fable
#

Where else do u get the audio from

sage otter
#

I mean some people use ffmpeg "legally". I’ve had a friend use it for a school project. Just because its commonly used with yt-dl doesn’t mean the software itself is bad.

slate swan
#

you can use ffmpeg when not downloading music from youtube nor spotify

#

I use ffmpeg with gtts to make tts commands in voice channels

maiden fable
sage otter
#

Ah I see. I misunderstood your sentence then. Mb.

slate swan
maiden fable
maiden fable
#

Yea

#

I was just tryna tell them to use a check

slate swan
maiden fable
#

It's easier, ya know

slate swan
#

well

#

do you learn checks or if statements first

#

😳

maiden fable
#

It's a basic judgement if u r using a lib like dpy, as long as the person doesn't himself tells the true thing

slate swan
#

hm

#

I see more people without python knowledge here

#

than with it

maiden fable
#

I was one of them

maiden fable
slate swan
#

I still am

maiden fable
#

🤣 I started dpy when I didn't know what were functions used for and there's a thing like decos or classes and objects

slate swan
#

ok

sage otter
#

stackoverflow

maiden fable
# sullen shoal how did you learn about them

Random articles. Read on multiple websites, asked from people in dpy server and I somewhat understood it. Then I would read help channels, see a new thing, like dunder methods, search for them and stuff. This is how I learnt

sullen shoal
#

would you suggest others to do the same 🤔

slate swan
#

no

echo wasp
#

anyone know how to fix this? code:

slate swan
#

code

#

where code

quick gust
#

fail to see ze code

slate swan
#

do people really think we can read their minds

maiden fable
slate swan
#

can someone help me with checking if the message is under a category?

unkempt canyonBOT
#

Hey @echo wasp!

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

maiden fable
maiden fable
#

Seems like os.getenv() is returning None

echo wasp
slate swan
slate swan
#

u told me my answer did not work

echo wasp
slate swan
maiden fable
#

Add these lines on the top of the file

slate swan
#

so what's the error

echo wasp
#

read the code

maiden fable
#
from dotenv import load_dotenv
load_dotenv() 
echo wasp
#

I have it

maiden fable
#

Oh, u r doing that

devout iris
slate swan
#

not u pusdk

devout iris
#

Damn

slate swan
#

this does not work

#

bru

#

do you really have category name in your code

#

wdym

#

I mean exactly what I asked

slate swan
sullen shoal
# maiden fable Never

yeah, my story was somewhat like that, i wanted to make a custom help command so asked people how to do it they linked me Stella's gist, i didn't understand shit and then i started from the beginning and searched a discord.py tutorial luckily, i watched a tutorial from a experienced guy that knew what he was doing, i skipped to the second part where they gave users a list of which things they need to learn prolly because of those dumb comments, i saved it and started reading them and creating small projects from then i think im improving day by day

#

the list was of decorators, classes and stuff like that

echo wasp
#

So what can i do

#

it is replit

pliant gulch
#

Makes sense as it has to touch upon inheritance and classes, but it you learnt that before discord.py it would be super super easy to do

slate swan
#

even if i write under "category name" category

#

it still blocks the command

sullen shoal
#

i was like 13

pliant gulch
#

Just feels like to me most people are skipping a few steps sometimes but what am I to say about that

sullen shoal
#

yeah

pliant gulch
#

I do understand why people would do it though as I can see discord bots being a fun project for beginners

tawny knoll
#

when using the discord.Member type hint, is there any way to check if the given input is a member object, if not use the string version of the input?

maiden fable
tawny knoll
#
    async def plays(self, ctx, user : discord.Member = None):
        """Defaults user_id to author, but checks if a user is provided. If so, change user_id to targeted users"""
        embed = Embed(color = Color.green())
        guild_id = ctx.guild.id
        target = ctx.author
        try:
            target = self.client.get_user(user.id)
        except AttributeError:
            user = str(user)
#

i tried this but it still tried to use the member object

maiden fable
slate swan
tawny knoll
sullen shoal
echo wasp
#

How can i fix my discord token error?

maiden fable
maiden fable
devout iris
#

Why we shouldn't use replit for host?

tawny knoll
#

the goal would be the except block tells the program its NOT a member instance, therefore use the raw version

slate swan
slate swan
maiden fable
#

It won't be a discord.Member instance only if the person isn't in the guild or is an invalid person

sullen shoal
#

im preparing myself before making my own discord api wrapper (just a simple one) i looked up the docs of the socket and http module i think im doing too much lol

tawny knoll
#

the member instance is used to search my DB for that user's socials. so if no user is given, itll target the author instead OR use the raw input as the username

maiden fable
#

if not isinstance(member, discord.Member):

#

!d str.isnumeric

unkempt canyonBOT
#

str.isnumeric()```
Return `True` if all characters in the string are numeric characters, and there is at least one character, `False` otherwise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property value Numeric\_Type=Digit, Numeric\_Type=Decimal or Numeric\_Type=Numeric.
maiden fable
#

This will return True if it's an ID

sullen shoal
#

it will return True even if its some random numbers tho

maiden fable
#

Yea

#

But that's upto him to figure out how to use it, since discord.py would always convert a correct ID to discord.Member instance

tawny knoll
#

then try and convert the number found to a user object, and if returns none i can assume its a random # input

maiden fable
#

Yesssss

#

That's what I was gonna say 😂

sullen shoal
#

!d discord.Object

unkempt canyonBOT
#

class discord.Object(id)```
Represents a generic Discord object.

The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.

There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.

x == y Checks if two objects are equal.

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

hash(x) Returns the object’s hash.
tawny knoll
#

yeah the logic behind it all makes sense its just too early in the morning to make any sense rn

#

so im struggling to put everythjing into words

echo wasp
tawny knoll
#

lmfao

vocal shoal
#
if member.id == ctx.bot.id:
  return await ctx.send("no")

does ctx.bot.id mean the bot's ID?

maiden fable
#

No

sullen shoal
maiden fable
vocal shoal
#

oh ok thx

echo wasp
#

can someone dm a .env file? that has like hi or something in it?

sullen shoal
#
HI = Your value
MYXI = thats me
TOKEN = your token```
carmine pilot
#

If I had a regular embed command could I just import slash commands and etc and add the slash commands into the embed command code?

sullen shoal
#

what lib are u using tho

carmine pilot
#

Wdym?

sullen shoal
velvet kindle
#

Ho how can i create a mod mail bot whit python

carmine pilot
#

Yes they do.

sullen shoal
#

what

#

where

carmine pilot
#

They have slash commands. lol

sullen shoal
#

link me the docs

carmine pilot
#

There is proof.

sullen shoal
#

i said docs

carmine pilot
#

I know.

#

And I said “proof”.

sullen shoal
#

ik slash commands exist

slate swan
#
        if guild.get_member(member.id) is not None:
            acts = member.activities
            act = [i for i in acts if isinstance(i, discord.CustomActivity)]
            if act:
                act = act[0]
            playing = ""
            listening = ""
            streaming = ""
            watching = ""
            competing = ""
            act = 'None'
            if discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities):
                act = "Listening to {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")".format(member.activity.name.replace("(UNREGISTERED)", ""))
            elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities):
                act = "Playing {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")".format(member.activity.name.replace("(UNREGISTERED)", ""))
            elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities):
                act = "Streaming {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")".format(member.activity.name.replace("(UNREGISTERED)", ""))
            if member.activity is None:
                act = [i for i in acts if isinstance(i, discord.CustomActivity)]
                if act:
                    act = act[0]
                if not act:
                    act = 'None'
            else:
                if member.activity.type == ActivityType.listening:
                    act = ("Listening to {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name.replace("(UNREGISTERED)", ""))
                elif member.activity.type == ActivityType.watching:
                    act = ("Watching {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name.replace("(UNREGISTERED)", ""))
                elif member.activity.type == ActivityType.competing:
                    act = ("Competing in {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name.replace("(UNREGISTERED)", ""))
        else:
            pass```
i think my bot might be racist
#

¯_(ツ)_/¯

carmine pilot
#

Bro what.

sullen shoal
carmine pilot
#

Omg.

slate swan
#

BD momentum

sullen shoal
#

you might be using "third party extensions" or "forks" of it which is not a part of discord.py directly

carmine pilot
#

It literally is.

slate swan
sullen shoal
#

its not officially supported, it will not be in the docs of the original library

sullen shoal
slate swan
safe fulcrum
#
@client.event
async def on_message(message):
  if message.content.startswith('s'):
    web = message.content
    await web.delete()

How to delete an user message using discord.py?

carmine pilot
safe fulcrum
#

what is web = message.content

slate swan
#

Gives the message content

safe fulcrum
#

await web.delete() will work?

slate swan
#

No

carmine pilot
#

@slate swan are slash commands supported officially on discord.py?

viral mirage
#

can someone recommend me a database that can be accessed by more than one bot and won't break the bot's cache or anything?

carmine pilot
#

But they CAN still be used right?

safe fulcrum
#

tx

slate swan
#

It's not built-in but there are third (actually kind of fourth) party libraries to make slash commands work with discord.py

carmine pilot
#

Okay ty.

slate swan
#

bot doesnt show when users are 'playing', only other bots, anyone wanna help?

carmine pilot
#

What?

slate swan
#

what

#

i thought i was discreet with the way i said it is there something thats not understood or

#

Do you have the presence intent enabled?

#

mhm

#

and all intents

#

i hate intents with a passion
discord should take the decision to add intents back, it fixes absolutely nothing

safe fulcrum
#

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

What is your code

safe fulcrum
#
@client.event
async def on_member_join(member):
    await member.send(f'Welcome {member.user.name}')

it gives me error

slate swan
#
        if guild.get_member(member.id) is not None:
            acts = member.activities
            act = [i for i in acts if isinstance(i, discord.CustomActivity)]
            if act:
                act = act[0]

            act = 'None'
            
            if discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities):
                act = "Listening to {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")".format(member.activity.name.replace("(UNREGISTERED)", ""))
            
            elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities):
                act = "Playing {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")".format(member.activity.name.replace("(UNREGISTERED)", ""))
               
            elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities):
                act = "Streaming {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")".format(member.activity.name.replace("(UNREGISTERED)", ""))
            

            if member.activity is None:
                act = [i for i in acts if isinstance(i, discord.CustomActivity)]
                if act:
                    act = act[0]
                if not act:
                    act = 'None'
            else:
                if member.activity.type == ActivityType.listening:
                    act = ("Listening to {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name.replace("(UNREGISTERED)", ""))
                elif member.activity.type == ActivityType.watching:
                    act = ("Watching {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name.replace("(UNREGISTERED)", ""))
                elif member.activity.type == ActivityType.competing:
                    act = ("Competing in {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name.replace("(UNREGISTERED)", ""))

        else:
            pass```
safe fulcrum
#

member hasn't attribute user

#

i k but how do i get member username

slate swan
#

u didnt classify member

slate swan
safe fulcrum
#

am stupid

slate swan
safe fulcrum
#

ik how to do it with webhooks but

slate swan
safe fulcrum
#

lol

slate swan
#

why would u need to send files to dms

raw cove
#

why a field value cannot be a string?

safe fulcrum
#

just answer lemon_angrysad

safe fulcrum
#

lol

slate swan
#

i forgot what it was rip

slate swan
safe fulcrum
#

ik

sullen shoal
slate swan
safe fulcrum
#

d discord.abc.Messagable.send.file

slate swan
#

!d discord.abc.Messageable.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**.
sullen shoal
slate swan
#

See the file kwarg

safe fulcrum
#

its the same thing for a webhook LOL

slate swan
slate swan
#

Lmao

safe fulcrum
#

lol

sullen shoal
slate swan
safe fulcrum
slate swan
#

Hello oki btw KryptonWave

slate swan
#

Tired, you? KryptonTired

safe fulcrum
#

!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
sullen shoal
slate swan
#

woops

safe fulcrum
#
@client.event
async def on_member_join(member):
  await member.send(files='path??') 
safe fulcrum
slate swan
#

Just use it like you used with webhooks

#

It's exactly the same

safe fulcrum
#

so the path works?

slate swan
safe fulcrum
slate swan
safe fulcrum
slate swan
#

Yeah, what a shame..

#

Anyways, going back at writing awesome documentation bravemmlol

lethal moat
#

is there a way so i can make it that buttons are only interactable for the person who ran the command?

slate swan
#

Kraots is tho hes mr.disnake

lethal moat
#

i want to check if the interaction user id is the same as ctx.author.id but i cant figure out how
if interaction.user.id != ctx.author.id: this is what i am using, but it says that ctx is not defined

slate swan
#

Good to see you infernumpithink

quick gust
#

how would I allow users to dm a file to my bot, and then I'd receive the file in my log channel?

my current one only takes in the text message. Just need help with getting the file

slate swan
#

@sullen shoal how are you doing?🤔

quick gust
sullen shoal
#

doing great

#

you?

slate swan
#

Good to hear from both of you🤔

lethal moat
quick gust
lethal moat
slate swan
sullen shoal
#

nice

slate swan
slate swan
#

Disnake = best fork

lethal moat
#

🥲

slate swan
#

Im not forcing you i just recommend it

lethal moat
#

ik you arent forcing me
im just looking for a way to do it in nextcord

quick gust
#

did u try asking the nextcord staff

slate swan
#

Cant help you sorry i only use disnake

lethal moat
quick gust
#

oh

sullen shoal
#

lol

quick gust
#

damn lol

sullen shoal
#

great support btw

lethal moat
#

i would say support here is better than in their discord server

sullen shoal
#

i met one of their devs even they advertise disnake joe_kitchener

quick gust
#

LOL

slate swan
unkempt canyonBOT
quick gust
#

thank you I'll take a look!

velvet kindle
#

Hi

#

I need a site of hosting

summer flume
#

use replit

manic wing
#

no.

#

not at all.

quick gust
#

no...

velvet kindle
#

What site i can use for hosting?

manic wing
#

buy a vps

summer flume
#

then idk

stone moon
#

anyway I can add roles via their role name? For context I have a ton of roles that are just 1 number increasing, and member’s roles ascend in numbers the more they interact. I can add a role based on their current role number + 1

lethal moat
#

use railway.app

#

its good

slate swan
lethal moat
#

no you arent, replit just still exists, thats all

#

why people still use it? now thats the real question

summer flume
#

why wouldnt

lethal moat
#

replit is complete doo doo

slate swan
manic wing
#

!d discord.utils.get

unkempt canyonBOT
#

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

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

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

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

Examples

Basic usage...
summer flume
slate swan
#

@velvet kindle best free option is heroku not good compared to vps but best option over replit

slate swan
#

If you like it well,well you like itjam_cavedude

summer flume
#

ok

quick gust
#

or maybe because you haven't seen real hosting

slate swan
#

Why yall recommending random websites from the internetlemonpeek

sullen shoal
#
act = f'Listening to {activity_name} {rich_presence}"```
#

ugh discord not letting me put the emoji name correctly

lethal moat
#
class ChooseClass(nextcord.ui.View):
    def __init__(self):
        super().__init__(timeout=30)
        self.value = None

        # button for knight class
    @nextcord.ui.button(label="Knight", emoji="⚔️", style=nextcord.ButtonStyle.blurple)
    async def knight(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
        self.value = "knight"
        self.stop()

        # button for archer class
    @nextcord.ui.button(label="Archer", emoji="🏹", style=nextcord.ButtonStyle.blurple)
    async def archer(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
        self.value = "archer"
        self.stop()

        # button for wizard class
    @nextcord.ui.button(label="Wizard", emoji="🔮", style=nextcord.ButtonStyle.blurple)
    async def wizard(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):   
        self.value = "wizard"
        self.stop()

is there ANY way on this holy earth that i could check if the user id is same as the interaction user id

sullen shoal
#

codeblock it correctly

#

```py
```

sullen shoal
unkempt canyonBOT
#

utils/paginator.py lines 87 to 88

async def interaction_check(self, interaction: disnake.MessageInteraction) -> bool:
    return interaction.author.id == self.ctx.author.id```
lethal moat
sullen shoal
#

just pass the Context to the class?

lethal moat
#

when i pass ctx to the class it says it doesnt have a value

unkempt canyonBOT
#

cogs/imagesearch/_cog.py lines 20 to 23

paginator = Paginator(ctx, embeds=embeds)
paginator.message = await ctx.send(
    embed=paginator.current_embed, view=paginator
)```
lethal moat
sullen shoal
#

that is not even related to disnake

#

more of something to do with OOP

#

Paginator(ctx, embeds=embeds)
im passing the ctx instance to my paginator

#

this is something which was added in discord.py 2.0 iirc, so it should be same for disnake and nextcord

echo wasp
#

how do i make sure i have these library?

#

import os
import discord
import time
import datetime
import asyncio
from discord.ext import commands
from discord.utils import get
from dotenv import load_dotenv

sullen shoal
#

run it

rare saddle
#

How do I make %x show the date like (de_DE)?

sullen shoal
#

or catch ModuleNotFoundError

echo wasp
#

ok how do i install from command line?

sullen shoal
#

using your package manager

#

which for most people is pip

echo wasp
#

pip

sullen shoal
#

pip install pakage_name

lethal moat
#
class ChooseClass(nextcord.ui.View, ctx):

the moment i give ctx to the class this happens -

NameError: name 'ctx' is not defined
sullen shoal
#

bro

lethal moat
#

im DUMB okeh?

#

i know im dumb

#

i accept the fact that i am dumb

sullen shoal
#

we inherit from other classes there

#

add the parameter to __init__

#

and add it to the instance

lethal moat
#
def __init__(self, ctx):

like that?

sullen shoal
#

!e

class foo():
    def __init__(self, ctx: commands.Context) -> None:
        self.ctx = ctx
        # the first parameter of every non static method is the instance of the class. it can be named anything, but please name it self.
ctx = 'oof'
f = foo(ctx)
print(f.ctx)```
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

oof
slate swan
#

Or womenjam_cavedude

sullen shoal
slate swan
slate swan
sullen shoal
#

also makes it easy for others to contribute

sullen shoal
#

oh

slate swan
#

😔

sullen shoal
#

did i answer your question tho or im confused

slate swan
sullen shoal
#

now im even more confused-

slate swan
velvet kindle
#

One site of hosting on mobile?

sullen shoal
#

alright then

slate swan
velvet kindle
#

Sad

sullen shoal
slow fog
#

amogus

slate swan
velvet kindle
sullen shoal
#

you gotta keep your phone on tho

#

alt

manic wing
#

this is self promotion

slow fog
manic wing
#
  • can't you just test yourself?
lethal moat
#

well no..

sullen shoal
lethal moat
#

i am testing the button thing in which only the command user can interact with the button

#

so i need 2 people, one who will issue the command and one who will try to click the buttons

slow fog
#

better for hosting things

lethal moat
#

its fine tho i will just go ask my 0 friends for help

sullen shoal
#

expensive tho why not buy vps

slate swan
manic wing
slow fog
#

not *

manic wing
#

vps are cheaper and more powerful

slow fog
manic wing
#

my pi can hardly handle it

slow fog
manic wing
slate swan
#

Vps are better in my opinion cuz they have their own internet and its fast and a rpi is good but you need to rely on your internet and power

slow fog
#

everything is on my own

sullen shoal
#

ok use whatever you want

slow fog
#

should be working fine

sage otter
slow fog
#

yea

slate swan
#

A rpi is like 100 bucks when digitals ocean lowest pack is like 5 bucks a month so you can get a year and a half

slow fog
#

just a small script have to be running all the time

stone moon
#

how to get the name of the user's role

manic wing
#

try having a bot on 200k servers that works its ass off

sage otter
#

That’s why I said mid level bot

manic wing
unkempt canyonBOT
slow fog
#

how are you using the bot

sage otter
#

200k is not mid-level that’s over 100 shards

slow fog
#

i dont understand anything

manic wing
#

it wasnt used by it

#

but it had to read the messages

slate swan
#

A bot with like 100guilds takes like 40 to 60 mb so no you don't need a gig of ram even

manic wing
#

it was just on big servers

slow fog
sage otter
#

Yes it’s recommended to get a high level vps or dedicated machine at that point

manic wing
#

i took it off the servers to give my pi a chance at life

manic wing
#

poor little boy was crying

slow fog
#

who

slate swan
slow fog
#

exe.bot

slate swan
#

Nothing its offline rn

manic wing
#

is it open source

slow fog
#

i mean what is the bot about

slate swan
#

Wdym by open source

slow fog
#

general moderation

sullen shoal
#

github repo

manic wing
#

is the code. ope

slate swan
slow fog
slate swan
slow fog
#

and who the hell gonna working hard then let the code an open source

manic wing
#

anyone need help with their bot?

sullen shoal
#

no

slate swan
#

If people need, they ask..

slow fog
#

then some kids come and use your code like its nothing

manic wing
#

well some

slate swan
manic wing
#

just shows you're selfish

slow fog
#

dont be stupid

slate swan
#

Idc if my bot is open source tbh jam_cavedude

slate swan
slate swan
sullen shoal
#

most devs dont really care about their code, theyre proud of it, and thats enough for them

stone moon
#

!d discord.Object

unkempt canyonBOT
#

class discord.Object(id)```
Represents a generic Discord object.

The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.

There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.

x == y Checks if two objects are equal.

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

hash(x) Returns the object’s hash.
manic wing
slate swan
sage otter
slate swan
#

if you bot is open source , other people may try to improve it as well

sullen shoal
#

i will

slow fog
sullen shoal
#

i cant handle myself when i see dumb code

manic wing
slate swan
#

Tbh i dont care if people copy my code i take it like a complimentpithink

manic wing
#

'its mine mine and noone but mines'

stone moon
slow fog
sullen shoal
slow fog
manic wing
#

in github

slow fog
#

what do you think

manic wing
#

90% of the time the liscence means nothing

slow fog
pliant gulch
sage otter
#

That’s false

manic wing
sage otter
#

Have you seen licenses like Apache

pliant gulch
sage otter
#

Or GNU

slow fog
manic wing
#

i mean my bots liscenced

pliant gulch
#

Some licenses allow you to take the code, some don't

stone moon
#

how to get the names of all the user's roles

pliant gulch
#

Like MIT your basically allowed to do whatever with it

sullen shoal
#

discord.Member.roles will return the list of user's roles, each is a discord.Role object

manic wing
#

but with bots like these, noones going to try and sell it or distribute it

pliant gulch
#

Sometimes you cannot but licenses always mean something

slow fog
pliant gulch
#

Open source is amazing

sage otter
slate swan
#

I like teaching others so i let my code be public sometimes

pliant gulch
dapper cobalt
#

I wouldn't make my code open source unless I fully am okay with others copying it and not even giving me credits. That's how you become a good member of the dev community.

slow fog
# slate swan Me

as i said If you have the full possibility to make your project restricted to property rights but most people do not do so

dapper cobalt
#

We going a bit off-topic, eh?

slate swan
sullen shoal
manic wing
pliant gulch
#

It's sometimes hard to believe

#

But not really at the same time

#

People have no respect over intellectual property

sage otter
#

it do be that way :l

slate swan
#

Theirs always that someone🤷‍♂️

dapper cobalt
#

I don't like being that person, but.

#

!ot

unkempt canyonBOT
slate swan
slate swan
sullen shoal
unkempt canyonBOT
stone moon
manic wing
#

uh oh

sullen shoal
stone moon
#

😿

manic wing
slow fog
stone moon
#

send help

slow fog
#

jk jk

stone moon
#

poeklase

#

please

dapper cobalt
#

!d discord.Guild.get_role

unkempt canyonBOT
slate swan
dapper cobalt
#

This will return a discord.Role object, then you can use the name attribute.

sullen shoal
#

they have the member

#

and they probably gonna end up actually doing discord.Guild.get_role()

neon pawn
#

im anyone would like a discord bot hmu. im bored and would like a project to do

stone moon
dapper cobalt
unkempt canyonBOT
#

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

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

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

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

Examples

Basic usage...
stone moon
#

get

#

get what

sage otter
#

Lmao

dapper cobalt
tawdry perch
#

can bots use emojis from guilds they are in, like from server x use that emoji in server y?

stone moon
#

im being as iqless as possible

dapper cobalt
tawdry perch
stone moon
#

??????????????????????????????????????

dapper cobalt
slate swan
#
        act = 'None'
        if guild.get_member(member.id) is not None:
            acts = member.activities
            act = [i for i in acts if isinstance(i, discord.CustomActivity)]
            if act:
                act = act[0]

            for activity in member.activities:
                if isinstance(activity, discord.Game):
                    act = ("Playing {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name)
                
                elif isinstance(activity, discord.Spotify):
                    act = ("Listening to {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name)
                
                elif isinstance(activity, discord.Streaming):
                    act = ("Streaming {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name)

                elif member.activity.type == ActivityType.listening:
                    act = ("Listening to {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name)
                elif member.activity.type == ActivityType.watching:
                    act = ("Watching {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name)
                elif member.activity.type == ActivityType.competing:
                    act = ("Competing in {} ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")").format(member.activity.name)```
for whatever reason, the bot only displays the status' of other bots. doesnt seem to work on users (only the playing status)
dapper cobalt
#

E.g. get(guild.roles, name="admin")

stone moon
#

like i want to add their current role + 1 since roles are numbers

river kindle
#

I am creating a "product review" command I want that when I call the command I can enter the quality and rating, for example:! review 5 stars test

if I try to write this it prints the message on stars and rating, but I want it to print the message 1 of the star and 2 for the rating

async def review(ctx, *, message):
  embed = discord.Embed (
        title = 'Product Review',
        description = f'Stars: {message} \ n Rating: {message} '
    )
  await ctx.send(embed = embed)```
sullen shoal
#

and fix the formatting so that its human readable

sullen shoal
dapper cobalt
slate swan
#

¯_(ツ)_/¯

queen jewel
#

is it possible to see .exe source code? or transfer it to .py?

slate swan
#

no lol

sullen shoal
sullen shoal
#

but could be possible if

#

it was converted to exe from python file

dapper cobalt
sullen shoal
#

also its not the right channel to ask it

slate swan
stone moon
#

like the current role they have

#

then add a role that is 1 more than their current role

dapper cobalt
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.
sullen shoal
#

it always helps to debug faster when the code is clean

stone moon
dapper cobalt
#

There's no need to say that, please.

#

Can you show your code?

stone moon
#

lol

slate swan
stone moon
#
role = discord.utils.get(message.guild.roles, name=str(int(discord.utils.get(message.guild.roles name#wtf)) + 1))
        await message.author.add_roles(role)```
stone moon
#

sorry i dont know any of this lol

slate swan
dapper cobalt
maiden fable
stone moon
#

i have 50 roles

#

1,2,3,4,5 etc.

#

and like the more they interact the higher their number

dapper cobalt
#

You want to add a role?

stone moon
#

add a role higher than their current one

sullen shoal
dapper cobalt
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

Yea that

slate swan
# sullen shoal show code after fixing the formatting

ive put it on a test command for now

    @commands.command()
    async def bb(self, ctx, member : discord.Member = None):
        if member is None:
            member = ctx.author

        rich_presence = "![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")"
        acts = member.activities
        activity_name = member.activity.name.replace('(UNREGISTERED)', '')

        act = f'Listening to {activity_name} {rich_presence}'

        await ctx.send(act)```
maiden fable
#

It can also take in a snowflake

stone moon
maiden fable
#

So u can also add the role ids

dapper cobalt
stone moon
#

no

#

add a role thats 1 more than their current one

slate swan
#

...(position= )

dapper cobalt
#

If you want to add a role to a user, its hierarchy depends on its hierarchy in the server itself.

stone moon
#

the name of my roles are 1, 2, 3, 4, 5, 6, 7, 8 up to 50

slate swan
#

💀

dapper cobalt
#

I'm losing brain cells.

sullen shoal
stone moon
#

😃

stone moon
# dapper cobalt I'm losing brain cells.

so i have 50 roles named 1, 2, 3, 4, 5 so on. i want to add a role thats 1 more than a user's current role, if the user has no roles then it adds the role "1"

dapper cobalt
slate swan
#

right

sullen shoal
slate swan
stone moon
#

i will ask later i suppose

slate swan
#

how am i meant to get the activity type then?

stone moon
#

i will try repharsing if needed

slate swan
#

without repeating code

dapper cobalt
sullen shoal
#

i would check the attributes of discord.Activity

#

!d discord.Activity

stone moon
slate swan
#

is discord.Activity.type a thing?

dapper cobalt
#

!d discord.Activity.type

unkempt canyonBOT
stone moon
#

i want to delete the role "34" and add the role "35"

#

over a certain condition (ive already got that covered)

slate swan
#

and would that show for watching, competing, streaming, listening to, listening to spotify (yes 2 different things), playing

dapper cobalt
sullen shoal
#

tias

stone moon
dapper cobalt
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

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

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

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

thats my only question

dapper cobalt
#

You want to get the list of the member's roles?

stone moon
#

i guess yeah

#

but like

slate swan
#

ive gone and done this

        actype = member.activity.type

        act = f'{actype} {activity_name} {rich_presence}'``` but the output is "ActivityType.playing Sublime Text ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")"
stone moon
#

i want to add a role to the user thats 1 more than their current one

#

how do i get their current role as a string object

sullen shoal
#

!d discord.ActivityType

unkempt canyonBOT
#

class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
sullen shoal
#

check attributes of it

slate swan
#

so actype = member.ActivityType?

#

or actype = member.ActivityType.type pepeugh

sullen shoal
slate swan
#

wait nvm i just ran it through my head it wouldnt work

sullen shoal
#

actually i think youre using the wrong attribute, one sec

sullen shoal
slate swan
#

a dict?

stiff nexus
#

how can i know whether the attachment is a image or a video??

slate swan
#

not familiar with technical terms

slate swan
#

extension*

sullen shoal
#

something like,

a = ActivityType
d = {
a.playing: "playing", a.listening:"listening"
}```
#

something like that

slate swan
#

ohhhh

#

i see

sullen shoal
#

i gotta go now, afk

cloud dawn
tawdry perch
#

how do I send a emoji from another server?

echo wasp
#

How would you do a token part of the bot i do this and get this error

tawdry perch
#

install the module?

echo wasp
#

i tried

tawdry perch
#

pip install python-dotenv did you install that?

echo wasp
#

i needs to be redone it doesn't support dotenv

cloud dawn
#

Yeah it's python-dotenv

stiff nexus
#

thx

tawdry perch
echo wasp
#

thanks i did pip install dotenv

slate swan
tawdry perch
#

ah

cloud dawn
#

Also calling your own main file Bot.py is very confusing not to mention potential break points.

tawdry perch
#

thank you

slate swan
#

it needs to have a colon before the name too

tawdry perch
#

oh I see

slate swan
#
    @commands.command()
    async def bb(self, ctx, member : discord.Member = None):
        if member is None:
            member = ctx.author

        rich_presence = "![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")"
        acts = member.activities
        activity_name = member.activity.name.replace('(UNREGISTERED)', '')
        a = ActivityType
        d = {
        a.playing: "Playing", a.listening:"Listening to", a.watching: "Watching",
        a.streaming: "Streaming", a.competing: "Competing in"
        }

        act = f'{d} {activity_name} {rich_presence}'

        await ctx.send(act)```
stone moon
#

so i have 50 roles named 1, 2, 3, 4, 5 so on. i want to add a role thats 1 more than a user's current role, if the user has no roles then it adds the role "1"

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

there @stone moon

abstract kindle
#

hey devs

#

got a question

stone moon
#

how

slate swan
#

ppl dont spoonfeed code here

#

thats what githubs for

abstract kindle
#

can you call a function inside another one?

stone moon
#

okay

abstract kindle
#

im wokring in a cog for my discord bot, and its saying the function im trying to call isn't defined

#
    #party creator
    @commands.command()
    async def party(self, ctx, user: discord.User):
        with open("users.json", "r") as f:
            data = json.load(f)
        party = []
        party.append(str(ctx.author.id))
        party.append(str(user.id))
        if not set(party).issubset(data):
            await ctx.send("One or more users is not registered.")
            party.remove(str(ctx.author.id))
            party.remove(str(user.id))
        else:
            print(party)
            await ctx.send(f"Party made!\nMembers: {party}")
            gen_party_id() #THIS FUNCTION RIGHT HERE OFFICER
            data[party][f"Party: {partyid}"]
        with open("users.json", "w") as f:
            json.dump(data, f, indent=4)
#

I defined gen_party_id above in the code

slate swan
#

redefine it in the command maybe?

abstract kindle
#

redefine the whole function?

#

I supposed I could try that

slate swan
#

¯_(ツ)_/¯

sullen shoal
#

!d dict.get

unkempt canyonBOT
#

get(key[, default])```
Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](https://docs.python.org/3/library/exceptions.html#KeyError "KeyError").
sullen shoal
#

d is the dict

#

d.get(key)

#

key needs to be the activity type in your case