#discord-bots

1 messages · Page 577 of 1

rugged delta
#

you defined client two times with two different methodes
chose one of them
i would go with

client =  commands.bot(command_prefix= '!', intents = intents)
slate swan
#

don’t tell me ur using replit 😔

rugged delta
#

keep_alive maaahn pithink

slate swan
#

is that a replit thing lmao

#

whats the keep alive?

rugged delta
#

i would say it's an online vscode

slate swan
#

why not remove it lemon_eyes

rugged delta
#

just a bad way to keep your bot hosted lol

slate swan
#

useless code should be removed, like defining something more than once when its not needed

rugged delta
#

not very eligible

#

sometimes it breaks , and slows down

slate swan
#

You should not use Repl.it to host your bot.

While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:

  • The machines are super underpowered.

    • This means your bot will lag a lot as it gets bigger.
  • You need to run a webserver alongside your bot to prevent it from being shut off.

    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.

    • This means any file you saved via your bot will be overwritten when you next launch.
  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please avoid using repl.it to host your bot. It's not worth the trouble.
See ?tag vps in #381963689470984203 if you want a list of decent hosts (there are no free hosts).

https://intuitiveexplanations.com/tech/replit/

slate swan
#

so what should i use then

#

not heroku

reef shell
#

vps

slate swan
#

aws

rugged delta
#

or you could pay for hacker mode and your repl will stay online 24/7

slate swan
rugged delta
#

didn't try it btw ,

slate swan
#

AWS , if your planning to buy, still would say AWS

slate swan
reef shell
rugged delta
#

i used GCP

slate swan
#

somethin thats free?

slate swan
slate swan
reef shell
#

Needs credit card

rugged delta
slate swan
reef shell
#

And only 1st year is free

slate swan
slate swan
#

thats enough

rugged delta
#

after that year you have to pay 10+ $ to host

slate swan
#

yeah , then u can switch to a vps

#

or buy a RPi

kindred epoch
reef shell
slate swan
#

so vps is the best choice

#

a raspberry pi

rugged delta
#

vps is digital ocean right ?

slate swan
#

but for now use AWS or whatever u wish

slate swan
reef shell
#

vps = virtual private server

kindred epoch
slate swan
steady flume
#

what i need put instead of this yellow frames ?

rugged delta
#

oh ok

waxen granite
#
    async def unmutetime(self):
        for key in self.blackList.keys():
            guild = self.bot.get_guild(int(key))
        try:
            for key in self.blackList[guild].keys():
                userid = key
            user = self.bot.get_user(userid)
            print(user)
            msgid = self.blackList[str(guild.id)][key]["msgid"]
            chid = self.blackList[str(guild.id)][key]["chanid"]
            time = self.blackList[str(guild.id)][key]["timeleft"]   
        except KeyError:
            print("returned")
            return```
how can i get the 69494... number?
rugged delta
#

haven't really used it before

waxen granite
#

it prints returned

slate swan
steady flume
sick birch
#

no

slate swan
steady flume
#

lol

#

@sick birch do u remember me ?

reef shell
steady flume
#

sorry for ping

steady flume
sick birch
steady flume
reef shell
#

what do you want to do tho

steady flume
#

pagination

reef shell
#

I mean disabled attribute is used for disabling a button, what else are you looking for instead of that

steady flume
#
class Pages(discord.ui.View):
    def __init__(self, author: int, embeds: list):
        super().__init__(timeout=None)
        self.embeds = embeds
        self.author = author
        self.embed_count = 0

    @discord.ui.button(label='left',
                       custom_id='1',
                       style=discord.ButtonStyle.blurple, disabled=True)
    async def back_page(self, button: discord.ui.Button, interaction: discord.Interaction):
        if self.author == interaction.user.id:
            self.embed_count -= 1

            embed = self.embeds[self.embed_count]

            if self.embed_count == 0:
                self.children[0].disabled = True

                self.children[2].disabled = False

                embed.set_footer(text=f"Page {self.embed_count + 1} of {len(self.embeds)}")

                await interaction.response.edit_message(embed=embed, view=self)

    @discord.ui.button(label='right',
                       custom_id='2',
                       style=discord.ButtonStyle.blurple, disabled=False)
    async def last_page(self, button: discord.ui.Button, interaction: discord.Interaction):
        if self.author == interaction.user.id:
            self.embed_count += 1

            embed = self.embeds[self.embed_count]

            self.children[0].disabled = False

            if self.embed_count == (len(self.embeds) - 1):
                self.children[2].disabled = True

                embed.set_footer(text=f"Page {self.embed_count + 1} of {len(self.embeds)}")

                await interaction.response.edit_message(embed=embed, view=self)
#

if u need

waxen granite
# kindred epoch show the full dict
    "824359600584523876": {
        "331829647568535563": {
            "timeleft": 10.0,
            "msgid": 905560108916944947,
            "chanid": 826871393617969233
        }
    }
}```, ignore the last pic. how to get this `331829647568535563` its a user id which i am tryin to get and convert back to user.mention
kindred epoch
#

uh

#

that dict doesn't look right

#

@waxen granite try printing this:

check = self.blackList[str(guild.id)][key]["331829647568535563"]
waxen granite
kindred epoch
#

ight, remove the try\except

waxen granite
kindred epoch
#

yea theres something wrong in that dict

waxen granite
#

wdym wrong?

kindred epoch
#

you need to give it an index to get that

#

those numbers are itself the index

waxen granite
#

can i give it as member name?

kindred epoch
#

what are those ids?

warm bane
#

@sick birch following up on our convo yesterday .... when you get a minute, I'd be interested in picking your brain on extensions. I did some light reading on cogs vs extensions and it said that extensions are used in cogs, but i didn't find anything useful on how extensions would be set up that is different than cogs. I did find that extensions are useful because you can load and unload them (maybe the terms were pack and unpack, i'll have to look again). Anyways, it was cool because it allows you to keep your bot up while changing a few commands/cogs at a time.

I'd like to ask you some more questions to make sure I'm on the right track, to learn about better bot designs (I really don't like one linear file when coding larger projects - clutter annoys me), and what other resources you would recommend looking into. (I skim read the pinned messages already and know what is there in case if I need it).

#

If others have thoughts, then just tag me so I can find your comments easier. Thanks.

kindred epoch
#

looking at the docs of it is also good to get more info about them

sick birch
warm bane
waxen granite
kindred epoch
warm bane
#

is cogs the best way to structure a bot?

sick birch
#

sure

waxen granite
warm bane
#

how do cogs and extensions differ?

kindred epoch
#

!e
test = {"userid": 675414248620294154}
print(test['userid'])

unkempt canyonBOT
#

@kindred epoch :white_check_mark: Your eval job has completed with return code 0.

675414248620294154
kindred epoch
#

do you see what i mean

waxen granite
#

ye but@kindred epoch

#

i am saving them as userid because there will be multiple users

warm bane
#

@kindred epoch i skimmed over your link.... thanks, im definitely going to be digging into this in a little. it looks really useful

kindred epoch
waxen granite
#

ye

#

under the same guild id

kindred epoch
#

then make a new dict under the same guild id

#

and that is exactly why you use a database

waxen granite
#

well it is under the same guild id

#

824359600584523876 is a guild id

kindred epoch
#

ye then whats the problem

waxen granite
#

331829647568535563 and 282859044593598464 are userids

#

i want to fetch them

#

from dict

kindred epoch
#

at this point, im just gonna say use a database, databases are made for this

warm bane
#

@sick birch you prefer DM or want to keep talking in discord-bots channel? or start a help channel?

waxen granite
sick birch
warm bane
#

ok 1 sec

sick birch
#

i'm playing something rn, keep it open, i'll join in later

kindred epoch
waxen granite
#

cant i get them as key ?

#

like i got the guild

kindred epoch
#

yea

#

why didnt you just do that

#

if you could get the guild id then why didnt you do the same thing with user id

waxen granite
#

for key in self.blackList[guild].keys(): userid = key i did

#

but it didnt work

kindred epoch
#

what does it print

waxen granite
waxen granite
#

its not able to do the try part

kindred epoch
#

remove the try and except and try again

#

also print self.blackList[guild].keys()

waxen granite
#

for key in self.blackList[guild].keys(): KeyError: <Guild id=824359600584523876 name='MecHaNiC Bot Support' shard_id=None chunked=True member_count=23>

kindred epoch
#

send whole error

waxen granite
# kindred epoch send whole error
Traceback (most recent call last):
  File "C:\Users\Endomorph\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
    await self.coro(*args, **kwargs)
  File "D:\Discord Bot\GitHub\ecrpgbot1v2.0\cogs\moderation.py", line 126, in unmutetime
    for key in self.blackList[guild].keys():
KeyError: <Guild id=824359600584523876 name='MecHaNiC Bot Support' shard_id=None chunked=True member_count=23>```
kindred epoch
waxen granite
#

824359600584523876

kindred epoch
waxen granite
#

what

#

self.blackList[guild].keys() should fetch the user id no?

kindred epoch
#

no

velvet crest
#

How can i access the bot object inside a custom function ?

waxen granite
kindred epoch
#

no idea honestly

slate swan
#

How do I make embed fields? Whenever I use them, I receive this:

-'Embed' object has no attribute 'set_field'

What happened to them? Did they get removed?

kindred epoch
#

its add_field

dapper cobalt
#

!d discord.ext.commands.Bot.get_prefix

unkempt canyonBOT
#

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

Retrieves the prefix the bot is listening to with the message as a context.
magic ore
#

Ah the full thing is needed

slate swan
dapper cobalt
#

!d pymongo.MongoClient

unkempt canyonBOT
#

pymongo.MongoClient```
Alias for [`pymongo.mongo_client.MongoClient`](https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient "pymongo.mongo_client.MongoClient").
magic ore
#

Yeah, I'm used to rdanny's rtfm command

#

Bot.get_prefix is a coroutine function that takes a message

#

That was an example for me

slate swan
#

Is it title or something else

magic ore
#

It takes two required kwargs, name and value

magic ore
#

!d discord.Embed.add_field

unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

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

!d discord.Embed.add_field

slate swan
#

ah ok

#

When a user sends an inexistant command, how do I catch the error without it popping up in terminal?

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "tax" is not found```
dapper cobalt
#

I'm slow. Damnit.

slate swan
#

thanks

magic ore
#

The on_command_error event

slate swan
#

ah alright thank you

dapper cobalt
magic ore
#

Shouldn't consume all errors though

#

This should help:
Not getting an error, but definitely should be?
Do you also have an on_command_error set up?
Please make sure to look at, and implement,** the 3 or so lines starting with 'else'** in the example below. Without this code or similar, your error handler is eating all unhandled errors. As you can imagine, this is bad when you get an unexpected error.
https://gist.github.com/EvieePy/7822af90858ef65012ea500bcecf1612

#

(So you know what to avoid doing)

slate swan
#

👍

void wedge
#
File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 1062, in change_presence
    await self.ws.change_presence(activity=activity, status=status, afk=afk)
AttributeError: 'NoneType' object has no attribute 'change_presence'
#

anyone know what this mean

magic ore
#

You're trying to change the presence before the bot has connected to the gateway

#

See the activity and status kwargs of the client constructor

#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
inland venture
#
    if user_message.upper() == 'Ratio':
        await message.add_reaction('👍')
        return
#

not working, plz help

cloud dawn
#

How can this ever be true if user_message.upper() == 'Ratio':?

kindred epoch
#

Lmfao

inland venture
kindred epoch
#

🤣 👌

cloud dawn
inland venture
#

oh what?

#

it has to be all capitalized?

kindred epoch
#

Ye

cloud dawn
#

!e ```py
print('These are words yes'.upper())

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

THESE ARE WORDS YES
inland venture
#

what will work then?

cloud dawn
#

You can do this though

inland venture
#

.lower or .upper wont work

cloud dawn
#
if user_message.lower().capitalize() == 'Ratio':
inland venture
#

ohh ty

cloud dawn
#

But why?

inland venture
#

AttributeError: 'str' object has no attribute 'capitalized'

cloud dawn
#

remove the d

inland venture
#
    if user_message.lower() == f'*epicgamer':
        embed = discord.Embed(title="epic gamer rate",
                              color=0xFF5733)
        embed.add_field(name=f"You are a {random.randrange(100)}/100 epic gamer", value="", inline=True)
        await message.channel.send(embed=embed)
        return
#

it's not working

#
In embed.fields.0.value: This field is required```
slate swan
#

value can't be empty

#

Uhm, is there a way I can get an emojis id?

#

for an animated emoji cuz i don't have nitro

neon oyster
slate swan
#

I find it so dumb that I got ratelimited for restarting my bot twice in a couple seconds

normal cipher
#

Anyone understand reaction role embed?

halcyon folio
#

if so just get a real host ez

slate swan
#

how do i put commas there??

gaunt herald
normal cipher
#

Any suggestions? Creates embed but wont assign the role

async def react(ctx, *, message,):
      embed=discord.Embed(title="Reaction Roles", description="React with the corresponding emoji to get the role", color=0xff0000)
      embed.set_author(name="SDN1")
      embed.add_field(name=':thumbsup: ', value="Verified", inline=True)
      embed.set_footer(text="SDN2")
      msg = await ctx.send(embed=embed)
      await msg.add_reaction(':thumbsup:  ')


      def check(reaction, user):

            return user == ctx.user and reaction.message == msg and str(reaction.emoji) in [':thumbsup:  ']

      while True:

               reaction, user = await Bot.wait_for("reaction_add", check=check)

               if str(reaction.emoji) == ':thumbsup:  ':
                    mrole = discord.utils.get(ctx.guild.roles, name='Verified')
                    await user.add_roles(Verified)
                    print ('gave a role to someone')```
gaunt herald
kindred epoch
unkempt canyonBOT
#

@kindred epoch :white_check_mark: Your eval job has completed with return code 0.

1,000
slate swan
normal cipher
slate swan
#

nvm i got it thx u

patent lark
slate swan
magic ore
#

yes

slate swan
#

I thought they were

slate swan
pliant gulch
#

Wonder why async checks aren't allowed

slate swan
slate swan
#

can someone help me with a check for my wait_for("message")

pliant gulch
#

I do know that wait_for creates a future and then the dispatch system will handle it but since its inside of a regular method you cannot await the check

#

Although I think you can use create_task

#

Might cause some problems though

magic ore
pliant gulch
#

Is there a specific reason for that

slate swan
#
def check(ctx):
   return ctx.message.author == ctx.author
``` and then put that as my check=?
magic ore
#

seems like it's because they aren't necessary

slate swan
#

not ctx

#

hold on

magic ore
#

(ie you can call the async functions to get whatever information before you call wait_for or after, outside of the check)

slate swan
#
 interaction = await client.wait_for("button_click", check = lambda i: i.component.id in ["text", "save"])
         if interaction.component.id == "text":
          await interaction.send("Please insert a message")
          m = await client.wait_for("message", check)
#

thats my thingy rn

#

i need help with the check at the bottom

#

everyone this is gonna be stupid but can anyone tell me a raid command?

#

No

slate swan
#

oh srry ddint read it

#

!rule 8 i think

unkempt canyonBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

slate swan
#

nope

#

k

#

!rule 5

unkempt canyonBOT
#

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

magic ore
pliant gulch
#

Although just a thought Idk if it will work

magic ore
#

i dont think that works

pliant gulch
#

I cba to try ¯_(ツ)_/¯

magic ore
pliant gulch
#

You would need to create an event loop or set one then do it

#

Or you can just use asyncio.run don't think you can use asyncio.run here

slate swan
thick rampart
#

am I using this wrong?

   @client.command()
   async def warning(ctx):
      await ctx.send(f'Hey {ctx.author.display_name}How should I dispose of the evidence?!')
#

before you ask any weird questions it's for a security bot part of the function of removing content that infringes rules

thick rampart
#

wait....I have a few others that are indented it didn't affect it. hmmm or maybe it did and it picked this one up first lol

#

I got this after un indenting

#

and no im using pycharm right now.....

#
  File "C:\Users\abrod\PycharmProjects\Discord_Bot_Phantom\discord_bot_phantom.py", line 23
    await ctx.send(f'Hey {ctx.author.display_name}How should I dispose of the evidence?!')
    ^
IndentationError: expected an indented block after function definition on line 22
supple thorn
#

What did you unindent

thick rampart
#

I am not use to writing discords bots so I apologize if I am making a ton of newb mistakes here lol

#

I undented the await line

supple thorn
#

Is your client.command indented

thick rampart
#

The original bot maker is out of town this week and I am trying to go by his instructions but....lmao

supple thorn
#

Thats why i told you its indented

thick rampart
#

lemme check

#

no it's not indented

shy schooner
#

can someone explain to me what intents are, why are they involved in user's privacy, health

boreal ravine
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

sick birch
slate swan
#

can someone help me pkease

thick rampart
boreal ravine
boreal ravine
#

isn't that how ctx works

#

¯_(ツ)_/¯

#

I can tell from your code

#

what

boreal ravine
#

well yes

#

since User is a discord user and Member is a guild member

jade tartan
#

What’s the wait_for method?

pale zenith
#

it waits for an event to be dispatched

slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
slate swan
#

Everything's explained pretty well

pale zenith
#

yep, and it has examples too, if you open the page

boreal ravine
#

is there an attr to display a guilds icon if the guild doesnt have an icon

slate swan
pale zenith
#

no there is not

maiden fable
#

Idk that just sees if there is no icon, nothing else

boreal ravine
slate swan
#

Guilds without icons have nothing in the response JSON, so nope

maiden fable
jade tartan
pale zenith
#

what do you want to do?

jade tartan
#

^

#

^

boreal ravine
#

yes

jade tartan
boreal ravine
#

yeah

pale zenith
# jade tartan ^

The first example does apply for you, maybe modify the check to check for author too.
await bot.wait_for('message', check=some_check)

#

just wait_for a bunch of messages lol

jade tartan
pale zenith
#

alright

jade tartan
pale zenith
#

My DMs are not open, no. Ask here or in .gg/dpy

#

even my about-me says so bc i get so many DMs from randos from the dpy server 🥴

slate swan
#
@bot.event
async def on_member_join(member):
    async with aiohttp.ClientSession() as session:
        async with session.get(
                f'https://some-random-api.ml/welcome/img/6/stars2?key=key&username={member.name}&discriminator={member.discriminator}&avatar={member.avatar_url}&type=join&guildName={member.guild.name}&textcolor=white&memberCount=23') as af:
            if 300 > af.status >= 200:
                fp = io.BytesIO(await af.read())
                file = discord.File(fp, "welcome.png")
                em = discord.Embed(color=0xf5ccf7)
                em.set_image(url="attachment://welcome.png")
                await member.send(embed=em, file=file)
            await session.close()
#

when entering the server, the bot does not send anything

#

@boreal ravine

#

Do you have the members intents enabled?

#

yes

#

And why do you check if the status code is smaller than 300 but bigger or equals than 200

#

Makes no sense at all

#

Just check if the status is 200

#

And just to make sure, you've enabled the intents in the developer portal and in your code right?

warm bane
#

Getting this error (Command raised an exception: AttributeError: module 'discord' has no attribute 'SelectOption') when trying to get drop downs to show. Using cogs.

Main.py:

from keep_alive import keep_alive

import os
from discord.ext import commands
from settings import *

bot = commands.Bot(command_prefix=commands.when_mentioned_or('!!'))

for filename in os.listdir("./cogs"):
    if filename.endswith(".py") and filename != "__init__.py":
        bot.load_extension(f'cogs.{filename[:-3]}')

@bot.event
async def on_ready():
  print(f'Logged in as {bot.user}.')

keep_alive()
bot.run(os.getenv('TOKEN'), reconnect=True)

=============================
Menu.py:

import discord
from discord.ext import commands

class Menu(commands.Cog):  # Category type is the class
  def __init__(self, bot): # using self bc using class
    self.bot = bot

  @commands.command(brief="Provides a menu of all Bot commands")
  async def menu(self, ctx):
    
    await ctx.send(
      content = 'Select an option:', 
      placeholder='Please select an option.',
      Options = [
                  discord.SelectOption(label='Option 1', description='This is option 1', value='1'),
                  discord.SelectOption(label='Option 2', value='2'),
                  discord.SelectOption(label='Option 3', value='3'),
                  discord.SelectOption(label='Cancel', value='Cancel'),
                ],
      custom_id='MainMenu'
    )
    interaction = await self.bot.wait_for('select_option', check=lambda inter: inter.custom_id == 'MainMenu' and inter.user == ctx.author)
    res=interaction.values[0]

    if res == 'Cancel':
      await interaction.send('You have canceled your select option')
    else:
      await interaction.send('You have selected %s option' % (res.label))


def setup(bot):
  bot.add_cog(Menu(bot))
#

Does the discord.SelectOption need to be coded differently in a cog?

#

it compiles fine, but doesn't execute the drop downs

slate swan
#
$ git clone https://github.com/Rapptz/discord.py
$ cd discord.py
$ python3 -m pip install -U .[voice]
warm bane
#

ok, ill check on my version

waxen granite
#

how cna i get member using its id?

halcyon folio
halcyon folio
waxen granite
unkempt canyonBOT
slate swan
#

Don't need to ask here and in a help channel, just ask in one place..

halcyon folio
#

did you install it

slate swan
#

Already being helped, you can ignore

halcyon folio
#

o

slate swan
#

Yeah, people do be impatient

waxen granite
#

prints userid

#

prints user - None

slate swan
#

Use guild.get_member() or await guild.fetch_member()

waxen granite
#

user = guild.get_member(userid) am i not doing it already

#

?

slate swan
#

As I said, exactly what I wrote

#

The member is not in the bot's cache so get_member returns None. If you use

guild.get_member() or await guild.fetch_member()

It will first try to use get_member and if it returned None then it will try fetch_member which will work fine

waxen granite
#

oh u mean both ok

#

the await alone worked

boreal ravine
#

ofc it worked

#

it fetched the member from the api

slate swan
#

It should not always be used though, therefore my solution

#

You should always try to get from cache first, and only then use the API call

ornate lichen
#
from googletrans==4.0.0-rc1 import Translator
#

i only want to import a certain version

#

how do i do that

ornate lichen
#

??

#

how do i correct it

boreal ravine
#

module is the module name and version is the version you want it to be

ornate lichen
#

no put it auto installs the old version

#

but

boreal ravine
#

what

ornate lichen
#

when ever i re run the code

#

or just randomly

boreal ravine
#

what IDE are you using

ornate lichen
#

ya replit

boreal ravine
#

then thats the problem

ornate lichen
#

then is there anything better i can use

boreal ravine
waxen granite
#

that return should have worked no?

ornate lichen
#

to host a 24/7 discord bot

boreal ravine
#

a VPS

#

this

ornate lichen
#

ya i alr am

#

uptime bot

boreal ravine
#

this

ornate lichen
#

so what ide whould i use

boreal ravine
#

a proper IDE

ornate lichen
#

ok

boreal ravine
ornate lichen
#

is heroku

ornate lichen
boreal ravine
#

uptime robot isnt a vps

ornate lichen
#

then

boreal ravine
#

a VPS

ornate lichen
#

its a website pinging service

boreal ravine
# ornate lichen is heroku

Heroku

- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.

- Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.

- Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.

- Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal CPython extension functionality. (This is the reason why voice doesn't work natively on heroku.)

- Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
boreal ravine
ornate lichen
#

ok

waxen granite
#

help

ornate lichen
#

thats a big one

#

the limited amount of time

slate swan
#

Every free hosting has disadvantages. If you want quality you need to pay, as simple as that.

ornate lichen
#

is vs code codd for it?

#

microsoft vs code

maiden fable
#

Welp, please don't ask for Free Hosting Services here again haha

waxen granite
#

can we use an emoji in thumbnail in an embed?

maiden fable
#

Last night there was literally a civil war debate on Raspberry Pi vs VPS

slate swan
maiden fable
#

U can't directly do :happy: or something

cosmic frost
#
async def on_message(message, channel):
    channel = client.get_all_channels
    if message.content.startswith('hello'):
     while True:
      await channel.send("hello")```
#

how do I make it so that if I say the command word

#

a message gets sent in every channel

tawdry perch
#

That's spamming?

cosmic frost
#

no

waxen granite
#

any help with this?

cosmic frost
#

if you say goodmorning

tawdry perch
cosmic frost
#

irl say goodmorning back in all channels

#

how i do that

tawdry perch
#

Loop the channels

cosmic frost
maiden fable
#

I guess, we should just help him Nipa. Won't be surprised when he is rate limited 😐

tawdry perch
#

Aight

#

So, use for loop to loop all the guild channels

maiden fable
#

But yea, he's right. U gotta loop

#

!d discord.Guild.text_channels

unkempt canyonBOT
#

property text_channels: List[discord.channel.TextChannel]```
A list of text channels that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
cosmic frost
#

example please

tawdry perch
#
for channel in ctx.guild.TextChannel:
``` not 100% sure if it's correct but you get the point
slate swan
#

ctx.guild.channels

waxen granite
#

anyone?

cosmic frost
#

oh

tawdry perch
jade tartan
maiden fable
slate swan
#

Yes, just check it's type with isinstance

tawdry perch
#

I think I should be only text channel

maiden fable
tawdry perch
cosmic frost
#

kk

cosmic frost
# cosmic frost i know how to spam🙄
async def on_message(message):
    if message.content.startswith('start spam'):
     while True:
        await message.guild.create_text_channel("spam channel")

    async def on_guild_channel_create(channel):
     while True:
        await channel.send(random.choice("bum do"))``` this is spamming
#

wouldnt have asked if i already knew

#

not tryna spam

maiden fable
#

Won't work lol

cosmic frost
#

how

maiden fable
#

Numerous mistakes

#

Won't help since u tryna spam 😐

cosmic frost
#

i did make one

#

look

#

havin fn with friends

maiden fable
#

😐

cosmic frost
#

but again not tryna spam

#

if i was i wouldnt have asked

tawdry perch
#

the problem is that we can't verify that

cosmic frost
#

its RIGHT THERE bruh

maiden fable
#

Thus certainly won't work lmao

#

Only on_message will work

cosmic frost
#

oops theres some accidents there

maiden fable
#

Nothing else

maiden fable
cosmic frost
#

didnt add @quaint axle.event

maiden fable
#

😐

#

Imagine ping

cosmic frost
#

oops

maiden fable
#

Lmao read his about me

cosmic frost
#

LOL

#

ok but can yall trust me now

#

sheesh

maiden fable
#

I mean, helping with spam bots is against ToS and server rules

cosmic frost
#

THIS ISNT FOR A SPAM BOT

maiden fable
#

Ok ok calm down my bad

cosmic frost
#

its just general knowledge i wamnted to know

#

lol

maiden fable
#

So what u need help with?

cosmic frost
#

oops wrong one

#

nvm

#

yeah

#

just realized why yall thought it was spamming now loll😅 i put while true:

maiden fable
cosmic frost
#

im dumb

tawdry perch
#

so did you need help with anything?

cosmic frost
#

well yall said i should use ctx.guild.text_channels right?

maiden fable
#

Ya

cosmic frost
#

im still confused on how exactly id implement that in(im new to this)

maiden fable
#

Well do u know how to use a for loop?

cosmic frost
#

tried earlier today but got confused

maiden fable
#

!d discord.TextChannel is what ctx.guild.text_channels returns (a list of those)

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text 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 the channel’s name.
maiden fable
#

!d discord.TextChannel.send is what u can use

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**.
maiden fable
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.

cosmic frost
#

o

slate swan
#

You realize your bot will probably get banned by Discord for spamming and abusing their API

maiden fable
#

You should leave aside your project and first learn basic Python

maiden fable
cosmic frost
slate swan
cosmic frost
#

not one with a few friends watching

slate swan
#

Overall API spamming or abusing

#

Private or not doesn't matter

waxen granite
#

will anyone help me :3

heavy folio
#

to get a command's retry after is it just py @command.error async def command_error(self, ctx, error): if isinstance(error, commands.CommandOnCooldown): await ctx.reply(f"please try again in {commands.CommandOnCooldown.retry_after} seconds")?

slate swan
#

error.retry_after

cosmic frost
heavy folio
#

oh

maiden fable
#

Nope

maiden fable
boreal ravine
slate swan
cosmic frost
#

ok lol

slate swan
#

So you can remove the other two

#

And use message.guild to get the guild object

cosmic frost
#

python is easier than c# they said

boreal ravine
#

it is

inner pumice
#

when i make my bot wait for a message like this: py msg = await client.wait_for("message")

#

how do i make it wait for one from the specific user

boreal ravine
#

add a check

slate swan
#

Make a check

boreal ravine
#

wait_for can take 3 args iirc

inner pumice
#

like ```py
if msg.author == ctx.author:
#carry on
else:
return

#

or within the parenthesis?

boreal ravine
#

no

#

yes but you gotta make the check first before assigning it the the function

inner pumice
#

mk

cosmic frost
manic wing
#

oh my

cosmic frost
#

-_-

cosmic frost
#

as in write it out

boreal ravine
#

we dont spoonfeed

cosmic frost
slate swan
#
@bot.event
async def on_message(message):
    # do your stuff
#

¯\_(ツ)_/¯

cosmic frost
#

troll lmao

#

alright🙄

boreal ravine
#

how is he trolling?

cosmic frost
#

nah nah its just a word that grew in my vocab

#

I and friends use it to describe someone who isnt in your favor

boreal ravine
#

well he isn't trolling and he did what he told you to do

valid galleon
#

is it possible to write some cogs in JS and some in py? im trying to use a d.py fork to make a dropdown help command and just cant seem to figure it out, and theres a lot of JS tuts for dropdowns so i cold use those

#

without multiple instances, that is

boreal ravine
valid galleon
#

i believe dyno bot does something like that so i thought i could do it nvm then

boreal ravine
#

where'd you hear that

valid galleon
#

i cans end you the repo if you want

lament mesa
#

It uses python probably for the backend

valid galleon
#

havent checked out its code tough

#

though*

boreal ravine
#

dyno isnt even open source

#

how would you check its code

slate swan
#

It was once leaked

slate swan
# slate swan Just check if the status is 200
    await ctx.send(f"{ctx.message.author.mention}, пронюхал бебру успешно!")

@bot.event
async def on_member_join(member):
    async with aiohttp.ClientSession() as session:
        async with session.get(
                f'https://some-random-api.ml/welcome/img/6/stars2?key=key&username={member.name}&discriminator={member.discriminator}&avatar={member.avatar_url}&type=join&guildName={member.guild.name}&textcolor=white&memberCount=23') as af:
            if 200 > af.status >= 200:
                fp = io.BytesIO(await af.read())
                file = discord.File(fp, "welcome.png")
                em = discord.Embed(color=0xf5ccf7)
                em.set_image(url="attachment://welcome.png")
                await member.send(embed=em, file=file)
            await session.close()
slate swan
#

no...

#

Just check if the status is 200

slate swan
slate swan
dense swallow
#

Just discord.Intents.all()

No need for the extra ()

dense swallow
slate swan
#

GitHub

dense swallow
#

Hmm 🤔?

slate swan
#

Most, if not all, repositories got taken down, but there are probably people that still have it/repositories existing

dense swallow
#

Oh

#

Was it in typescript?

slate swan
#

Don't remember, it's been over a year

dense swallow
#

Ahh I didn't even join discord...

slate swan
slate swan
#

!=*

slate swan
# cosmic frost i did make one

<@&831776746206265384> , you dont need to ask anyone for permission , its against discord rules wither you asked or not

slate swan
cosmic frost
#

what are you talking about

cosmic frost
slate swan
arctic python
#

@cosmic frost As per rule 5, we cannot help you with a project that may be used for malicious purposes. That includes a spambot. It doesn't matter what your intentions for the project are.

cosmic frost
#

wha, nooo no malicious purposes, i was being accused of them so I told them I already knew how to spma

arctic python
#

!rule 5

unkempt canyonBOT
#

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

cosmic frost
#

spam

#

yeah yeah

#

i was just showing them that if it was malicious I would already know

arctic python
cosmic frost
#

no I wasntt

#

bruhh

fading harness
#

hi how can i get the discord tag of the author of message? (example MaskDuck#9693)

slate swan
#

str(message.author)

slate swan
slate swan
#

Because author returns the object

arctic python
#

@cosmic frost Refrain from inquiring further about this project here or discussing mass message delivery in general.

#

If you persist, there will be escalating consequences.

cosmic frost
#

yeah I already figured out my issue sorry

slate swan
#

like

await X.send(f'hey you are {ctx.author}')
fading harness
#

what do i need

slate swan
#

ctx.author.discriminator

cloud dawn
boreal ravine
#

yes

slate swan
slate swan
cloud dawn
#

Member object most likely.

slate swan
#

No, abc.User

#

A message doesn't always come from a guild

#

Private messages users are not considered as discord.Member

cloud dawn
#

Hmm true.

slate swan
#

Since it returns a abc.User object it can be Member, User or ClientUser

cloud dawn
#

Yeah i thought it was a union.

bleak sigil
#

any discord bot hosting platform recommendations?

#

my budget is like 10 usd a month

slate swan
final shard
#

How to add comment to a attachment

#

The Text on top of attachment

#

This is how my code looks

await ctx.send(file = discord.File("video.avi"))
slate swan
#

If you mean some text above the video, then content="blah"

final shard
#

Nice job paying for WinRar

fossil goblet
#

Hello,

#

How do I check users state message?

boreal ravine
#

state?

fossil goblet
#

yep

boreal ravine
#

wdym by that

fossil goblet
#

The custom state

#

I mean that

boreal ravine
#

state?

#

u mean status?

fossil goblet
#

yes

boreal ravine
#

ah

fossil goblet
boreal ravine
#

!d discord.Member.activity then

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").
fossil goblet
#

hhhmmmmmmmm

boreal ravine
#

I think that returns the custom "status" too

fossil goblet
#

Thank youuuu

#

||Neeed to learn SQL||

#

I wrote a code :

@eternal girder
async def state(ctx):
await ctx.send(ctx.author.activity)
await ctx.send(f"<@ctx.author.id>")

Is my code right???

#

I don't know how but @eternal girder is highlighted.

#

It's pretty

tawdry perch
#

Why you keep pinging them pithink

slate swan
tawdry perch
#

I know

slate swan
#

Yeah

#

!d intents @normal cipher

unkempt canyonBOT
maiden fable
unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

New in version 1.5...
maiden fable
#

Oh nvm

#

Never knew that also existed

slate swan
#

Yeah

sturdy tapir
#
@client.command(pass_context=True)
async def clean(ctx):
    llimit = ctx.message.content[10:].strip()
    await ctx.DMChannel.purge(limit = 500)
    await ctx.message.delete()

it works on channels how do I make it work in dms

sturdy tapir
#

Can't I make it delete all the messages in dms

#

I'm sure I can

slate swan
sturdy tapir
slate swan
sturdy tapir
#

it's a selfbot

#

lmao

#

idk if it's allowed or not

slate swan
unkempt canyonBOT
#

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

sturdy tapir
#

are selfbots bad?

slate swan
sturdy tapir
slate swan
sturdy tapir
#

do you know why?

slate swan
sturdy tapir
#

you don't?

slate swan
#

Not good at explaining so just read the disc tos

fossil goblet
fossil goblet
kindred viper
#

Hi there, I'm trying to add a command to my bot which will give me a list of all members in the server. (Don't ask, I'm trying to learn how bot making works 😃) This is the code I tried:

@bot.command()
async def member_list(ctx):
    members = ctx.guild.members
    for member in members:
        try:
            await ctx.channel.send(str(member.name))
                
        except:
            return

The bot does manage to send a message, but it sends one, which is itself...

slate swan
#

oh no, that would get you rate limited

fossil goblet
kindred viper
#

Uh, what do you mean?

slate swan
#

How can he for sending to much messages?

waxen granite
fossil goblet
waxen granite
#

You could split the msg but thats advanced

kindred viper
#

ok

fossil goblet
slate swan
#

and you won't get banned unless they find you

boreal ravine
fossil goblet
#

But agaisnt ToS is bad. The rule 5 too

boreal ravine
slate swan
fossil goblet
boreal ravine
#

!intents @kindred viper

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

fossil goblet
slate swan
slate swan
boreal ravine
#

why ping him again

slate swan
#

My bad ig

unborn dagger
#

Hi everyone i am making a public discord bot, do i need to copyright or trademark it?

slate swan
kindred viper
#

Ok, so I kinda get the rate limit thing, in a way. So I'm also curious, if it's possible to dm all users in the server? I do have code that I got from a tutorial video, but it gives an error, when It messages "all users". But it tries to send a message to the bot itself first, causing it to stop immediately, as it can't send a message to itself.

slate swan
slate swan
#

sort of , but thats not the main reason

slate swan
slate swan
#

Pretty basic problem

boreal ravine
#

module error

lusty tide
#

hey can anyone help me? I was wondering if there is a way to detect if user is using a phone?

#

or what device is he using

sage otter
boreal ravine
#

!d discord.Member.mobile_status

unkempt canyonBOT
white trail
#

hey im tryna do a discord bot for my server can anyone help me pls

white trail
#

ok ty

lusty tide
#

np

#

:D

white trail
#

sooo

lusty tide
#

so u send me the server where the bot is

#

or u dunno anything how to do a bot

white trail
#

i dont even have the bot

lusty tide
#

ohok

#

I'll teach u

white trail
slate swan
lusty tide
#

why

slate swan
#

Starting discord.py with no python experience isnt a good idea

lusty tide
#

wait

#

u dunno python?

slate swan
#

What does that have to do with my statement

slate swan
#

even if you dont know what u r doin

slate swan
slate swan
lusty tide
slate swan
lusty tide
#

yea he doesn't

#

I'll teach him python first

slate swan
#

Goodluck with that ig

lusty tide
#

thx

slate swan
devout iris
#

How can bot join the music channel also mute and deafen?

lusty tide
devout iris
#

Btw, Sorry for english

slate swan
eternal bone
#

hii

lusty tide
#

hey

devout iris
#

Code?

eternal bone
#

i need help

slate swan
sage otter
lusty tide
lusty tide
devout iris
slate swan
eternal bone
#

i want to fix my code

sage otter
eternal bone
#

can anyone help me??

devout iris
sage otter
#

!d discord.VoiceChannel.connect

unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.

This requires [`Intents.voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
slate swan
devout iris
sage otter
#

And I just gave it

devout iris
slate swan
#

Saying"help" wont get you any help

slate swan
eternal bone
#

Especially in Python

eternal bone
slate swan
lusty tide
slate swan
#

Have you tried putting discords import to the bottom of the imports idk if it will help tho

eternal bone
slate swan
#

Dang idk

lusty tide
devout iris
#

Can i make a music bot with dpy?

slate swan
sage otter
#

I wouldn’t advise helping out with syntax errors. It’s off topic from this channel and just shows the user doesn’t know python.

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)
slate swan
sage otter
#

Import order has no significance to syntax errors

slate swan
sage otter
sage otter
#

!d discord.Member.is_on_mobile

unkempt canyonBOT
#

is_on_mobile()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): A helper function that determines if a member is active on a mobile device.
lusty tide
#

yea

#

thank u

slate swan
#

👀 you would need to call it tho

dusk pumice
#

How to get users status like online or offline????

tough wagon
#

!d discord.Member.status

unkempt canyonBOT
#

property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
dusk pumice
#

or members custom activity

tough wagon
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").
dusk pumice
#

tnx

#

and intents are on

#

So you don't have to say that

tough wagon
#

select bot

#

in the center

dusk pumice
slate swan
#

that's status

tough wagon
#

wdym?

slate swan
dusk pumice
#
await ctx.sned(ctx.author.activity)
tough wagon
#

sned

dusk pumice
slate swan
#

Lol

dusk pumice
dusk pumice
tough wagon
dusk pumice
#

There is way.

slate swan
#

Go to bot i think it is where its at

#

In scopes

dusk pumice
#

Click bot on scopes

#

and than you will see it

slate swan
#

You add the bot perms and copy link to a new tab and add it

dusk pumice
#

How to turn it on

#

I forgot the codes

#

🙂

slate swan
#

idk much but try intents = discord.intents.default()

#

intents.members=True

dusk pumice
#

That's all?

slate swan
#

And in the statement where U define bot make intents = to intents

slate swan
dusk pumice
#

😦

slate swan
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

New in version 1.5...
slate swan
#

for activities?

#

enable presence intent

#

and member too

slate swan
slate swan
#

lol

dusk pumice
slate swan
#

yes

#

oh I know why MY bot stopped working

#

or maybe that's an issue, idk

#

is message content not a default intent anymore?

slate swan
#

fawk

dusk pumice
slate swan
#

They recently added it…

slate swan
slate swan
dapper cobalt
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

See I was right @dusk pumice lol

dusk pumice
slate swan
dusk pumice
#

Not working

dapper cobalt
slate swan
#

.

dapper cobalt
#

The i is capital, and not small.

slate swan
#

I’m on mobile tho

slate swan
#

credits to dpy server

dapper cobalt
dusk pumice
slate swan
#

Vex#3110 made the tag

#

what a bad person

slate swan
dusk pumice
dusk pumice
slate swan
#

so what's the code where you get the user's status

dusk pumice
dusk dust
#

how can i do a member count?

dusk pumice
#

what

slate swan
unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
slate swan
#

where discord.Guild should be replaced with an instance of itself

#

Wait nvm it wouldn’t work

dusk pumice
dapper cobalt
#

Wait, what's\r?

slate swan
#

returns offline and None

#

?

dusk pumice
#

yea

#

That's what my bot is doing

slate swan
#

well is your member offline by any chance?

dusk pumice
#

It's getting MY status and activity

slate swan
#

you just changed your status to online

#

it was offline

dusk pumice
slate swan
#

you just changed it

dusk pumice
#

?

#

HuhOkay. I didn't knew that

slate swan
#

I saw it

dapper cobalt
#

Sometimes you gotta blame your brain, not your code.

boreal ravine
#

😂

slate swan
#

that's not nice either

boreal ravine
dapper cobalt
#

I will make a website for it.

dusk pumice
#

for what?

dapper cobalt
#

discord-intents.com

boreal ravine
#

lol

slate swan
#

but you gotta refresh it

dusk pumice
#

lol

visual island
#

make a company when

slate swan
#

now you have to enable message content intent aswell

boreal ravine
slate swan
#

not just the two

dusk pumice
#

yep.

dapper cobalt
#

Will include everything about Discord privileged intents, and also updated; since many people are clueless what even intents are.

dusk pumice
visual island
dapper cobalt
#

Someone once asked me "where is run button on bot page??"

dusk pumice
tough wagon
#
    public $var = 'no';
}```
done @dapper cobalt
visual island
dusk pumice
visual island
dusk pumice
#

check your friend list

remember the pink potatos XD

visual island
#

oh

#

i forgot

slate swan
visual island
#

:blobpain:

slate swan
visual island
dusk pumice
visual island
dusk pumice
visual island
boreal ravine
#

ah kylee

#

changed name

dusk pumice
# visual island see my about me
Suffering, suffering, suffering, I've always sworn I would never become a woman that full of those

Discord doesn't let me buy nitro :(