#discord-bots

1 messages ยท Page 549 of 1

valid galleon
#

if you press "." on github you get a lite version of vscode in ur browser

boreal ravine
#

and you want to send "False" using a webhook?

boreal ravine
#

Woagh

slate swan
#

yes

valid galleon
#

???? i have an on message event which runs at the same time when you put in the command so how can i fix that??

slate swan
#

or true

boreal ravine
# slate swan yes

well personally i'd create a webhook > send the message > delete the webhook

slate swan
#

That would be rate limiting

#

look like this @boreal ravine

dim cedar
#

i watched a video

#

where they are doing somtthing else

#

but the error is same and they fixed it

boreal ravine
boreal ravine
slate swan
#

@boreal ravine yeah

#

but other badges dont send

dim cedar
#

will watch that and thn help me

boreal ravine
slate swan
#

on bot =

#

@boreal ravine like the attributes dont work idk why

boreal ravine
#

wdym by the attr's dont work?

dim cedar
#

kyle

#

they did this

#

to fix the same error

slate swan
#

the flags names for example = hypesquad_balance

boreal ravine
slate swan
boreal ravine
slate swan
#

rtd ?

boreal ravine
#

the docs

slate swan
#

i read the docs

#

still doesnt wanna send

#

i think i have an idea

slate swan
slate swan
#

You gotta check on your own

slate swan
#

Doesn't exist :)

#

im just looking for others

#

it exists cuz i find nitro users with that sueur

#

Then show me the documentation where is shows it exists

#

As it doesn't exist

#

Those are the only flags

#

Discord doesn't have a bit shift for Nitro in the badges bitfield on their API

#

So you have to manually check by yourself

#

For example, if the profile picture is animated or if the user has a special discriminator or a banner, etc.

#

i dont manually check tho..

#

Or make a manual api call, which is pepega if you have what you need

slate swan
#

Only thing you can do is a manual API call

#

/users/{user.id} and read the value in the premium_type field

slate swan
#

That's not in the flags ;))))))

#

And it's even deprecated KEKL

proud glade
#

well? it still shows the information, and even tells you if its classic nitro or not, anddd it's better than doing a raw api call

slate swan
#

Whatever, maybe reading can help ๐Ÿคก

proud glade
#

another way would be premium_since, returns None if the user doesn't have nitro iirc ๐Ÿ‘

lusty swallow
proud glade
lusty swallow
#

not sure if it's because of discord's api itself but there seems to be no way to check for nitro

proud glade
#

well that's ๐Ÿ˜•๐Ÿ˜•

lusty swallow
gentle gyro
#

How do I set 'all' and 'max' as the maximum value in the bank for my currency bot?

valid galleon
#

so i fixed the error of it returning none when setting the afk, but now it sets the afk, removes it, and sets it again. it works how it should when you send a message, but the setting part is messed up. any way to fix this?
My code:

    @commands.command()
    async def afk(self, ctx, *, message = "No Reason Specified"):
        record = await afk_list(ctx.author.id)
        if record:
            embed = discord.Embed(title = 'AFK Running', description = f"{ctx.author.mention}, You Already have an afk running", colour = discord.Colour.red())
            await ctx.send(embed = embed)

        else:
            try:
                await add_afk(ctx.author.id, message)
                await ctx.author.edit(nick = f'[AFK] {ctx.author.display_name}')
                embed = discord.Embed(title = 'AFK', description = f'{ctx.author.mention} I Set Your AFK\n Reason: {message}', colour = discord.Colour.green())
                await ctx.send(embed = embed)
                return
            
            except:
                await add_afk(ctx.author.id, message)
                embed = discord.Embed(title = 'AFK', description = f'{ctx.author.mention} I Set Your AFK\n Reason: {message}', colour = discord.Colour.green())
                await ctx.send(embed = embed)
stark hearth
#
import discord
import googletrans
from discord.ext import commands
from googletrans import Translator

    @commands.command(name = 'translate', help = 'Translates a series of text to any language you want')
    async def translate(self, ctx, lang, *, args):
        translator = Translator()
        translation = translator.translate(args, dest=lang)
        
        em = discord.Embed(
            name = 'Translation',
            description = f'{args} ---> {translation.text}'
        )
        
        await ctx.send(embed = em)

i keep getting an command error on this command.

#

wait nm this api is old lmao

cyan bay
#

how do i make my bot say smthn to like a specific channel?

cyan bay
proud glade
#

send

#

or to be specific, channel.send

drifting arrow
#

You can't be doing my man bad like this

proud glade
#

well, mans asked how to send it not how to set it ๐Ÿคทโ€โ™‚๏ธ

#

still, i'd recommended reading the docs, many ways to get a channel

#

most basic one would be channel = bot.get_channel(id_goes_here)

cyan bay
slate swan
#

or use a parameter and type hint it to be a channel

#

Then you can do !say #channel a message here

cyan bay
#

ok

proud glade
#

yeah, many ways to do it

#

depends on what exactly you're looking for

slate swan
#

how do i invoke a command from within a on_message event

gloomy quest
#

Does anyone know how to use a discord widget on GitHub?

#

its the closest

boreal ravine
gloomy quest
#

I mean something like

#

When you click the whatever its called you join the server

boreal ravine
#

i dont understand

gloomy quest
#

and when u click it you join a server

boreal ravine
#

oh

boreal ravine
gloomy quest
#

yeh but i want my own server instead

boreal ravine
gloomy quest
#

k

boreal ravine
#

k

#

it's that easy

gloomy quest
#

yessss

#

thxx

boreal ravine
#

ok

iron zealot
#

hello there

#

discord bots very kool

quasi pawn
#

which product do I choose for a bot's host

dim cedar
#
@bot.command()
@commands.has_permissions(administrator=True)
async def mute(ctx, member: discord.Member, *, reason=None):
  guild = ctx.guild
  mutedrole = discord.utils.get(guild.roles, name = "Muted")
  if not mutedrole:
    mutedrole = await guild.create_role(name = "Muted")
  for channel in guild.channels:
    await channel.set_permissions(mutedrole, speak=False,send_messages=False,read_message_history=True,read_messeges=False)
    
  await member.add_roles(mutedrole, reason=reason) 
  await ctx.send(f"Muted {member.mention} for reason {reason}")  
  await member.send(f"You were Muted in the server {guild.name} for {reason}") ```
#

why this is not working

heavy folio
#
    class UserInfo_Button(discord.ui.View):
      @discord.ui.button(label="View Member's Roles", style=discord.ButtonStyle.blurple)
      async def receive(self, button: discord.ui.Button, interaction: discord.Interaction):
        member = discord.Interaction.user

        for x in list(discord.Interaction.guild.roles)[::-1]:
          memberRoles = f"\n{x.mention}"

        embed = discord.Embed()
        embed.add_field(name="Roles", value=memberRoles)

        await discord.Interaction.response.send_message(embed=embed, ephemeral=True)

    @commands.command()
    async def hi(self, ctx, member: discord.Member): 
      member = ctx.author or member
      embed = discord.Embed(
         description=member
      )
      await ctx.reply(embed=embed, view=self.UserInfo_Button()
```i have this, but below i have a command which has an arg `member`, so how do i make the interaction get the `member`'s roles? im certain its not `discord.Interaction.user` since thats for the user who clicked the button
boreal ravine
boreal ravine
#

!d discord.Member.roles

unkempt canyonBOT
#

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

These roles are sorted by their position in the role hierarchy.
heavy folio
boreal ravine
heavy folio
#

but thats for the user who clicked on the button, not the member arg

boreal ravine
#

the author?

heavy folio
boreal ravine
#

i dont see a member arg anywhere

heavy folio
#

i didnt send the command

#

sec

boreal ravine
#

hm

slate swan
#

It literally feels like I'm reading a convo between deleted users

#

Y'all's pfp ๐Ÿ˜ญ

lean thicket
#

Hello there ๐Ÿ‘‹

Is this any way to make a command both a regular one and slash command under the same function? I'm using discord_py_slash_command for the slashs

@commands.command(name="info")
@cog_ext.cog_slash(name="info", description="some description")
async def cool_func():
    await ctx.send("some info")

Of course, this won't work, but is there any workaround?

boreal ravine
#

just make one slash & one normal command ๐Ÿง 

slate swan
lean thicket
#

It's extra code though, but I guess it'll have to do

proud glade
heavy folio
#
      # checks if member has banner or not
      if bool(member.banner) is True:
        fetchedMember = await self.bot.fetch_user(member.id)
        # new_embed.set_thumbnail(url=fetchedMember.banner.url)
      else:
        pass
```did i do something wrong here? i ran the command and mentioned someone with a banner but then its not showing in the embed thumbnail, theres nothing in the thumbnail
heavy folio
proud glade
heavy folio
#

uh no?

#

its not a problem, they just changed it to .url bruh

proud glade
#

well good for you ๐Ÿ‘

heavy folio
#

??

proud glade
dapper cobalt
#

break can be used only in loops, I think what you want is return.

slate swan
#

Hi, so I've coded a discord bot using nodejs once a while back, I remember I did a command handler and a event handler where i have a index.js file, and two different folders called "commands" and "events", so inside the commands folder, each command the bot has is in their own file within that folder, and every event that's called is in their own file in the events folder, example:

index.js
commands โ†“
    ping.js
    info.js
    help.js
    kick.js
    etc...
events โ†“
    message.js
    ready.js

How can I do this with python?

dapper cobalt
#

Code?

dapper cobalt
#

Just return.

proud glade
slate swan
dapper cobalt
#

Yes.

slate swan
#

So cogs it is, ty guys

proud glade
#

return stops the command ๐Ÿ‘

proud glade
dapper cobalt
#

What is message though?

slate swan
#

Sorry for interrupting, I looked up how cogs works and it doesn't seem like I want to use this since from what I understood you can't separately do a command handler and a event handler

dapper cobalt
#

Try printing message.content.

slate swan
#

A few posts on stackoverflow, and googled how cogs works with python, I haven't found a site where they explain how to make separate handlers using cogs

dapper cobalt
#

I've explained it in this repository.

slate swan
#

Oh okay ty

ionic wadi
#

Im trying to make a report command, and I want users to be able to send proof pictures and let that pictures be send to the logs channel. But Is that possible at all?

#

Or Is It just message.content?

slate swan
#

!d discord.Message.attachments

unkempt canyonBOT
slate swan
#

Gives a list of attachments (pictures in your case)

ionic wadi
#
@commands.command(brief="Iemand reporten", description="Iemand reporten voor bijv leaken of raiden")
    async def report(self, ctx, user=None, proof=None, reason=None):
        botmessage = await ctx.send("Wat is de discord naam en tag?")
        message = await bot.wait_for("message")
        user = message.content
        await message.delete()
        await botmessage.edit(context="Kan je hieronder **1** foto sturen die het meest bewijst?")
        message = await bot.wait_for("message")
        proof=message.content
        await message.delete()
        await botmessage.edit(context="Wat is de reden dat hij gereport wordt?")
        message = await bot.wait_for("message")
        reason = message.content
        await message.delete()
        await botmessage.delete()
        await ctx.send(f"Je report over {user} is succesvol naar het management verstuurt, {ctx.author.mention}")```
#

The message doesnt edit

dire saddle
#

hey

slate swan
#

And you shouldn't just accept screenshots as proof, they can be faked

slate swan
#

How can I get a guilds information?

boreal ravine
unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a โ€œserverโ€ in the official Discord UI.

x == y Checks if two guilds are equal.

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

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

str(x) Returns the guildโ€™s name.
slate swan
#

do i do commands.guild?

boreal ravine
slate swan
#

okay

#

ty

boreal ravine
#

๐Ÿ‘

ocean leaf
#

how can i install discord.py 2.0 in replit? I need it because i think threads only works in 2.0 or later

slate swan
# boreal ravine ๐Ÿ‘

<discord.embeds.Embed object at 0x000001F95F709700> this is the output i get from:

    @commands.command()
    async def guildinfo(self, ctx):
        embed = discord.Embed(title="Guild Information")
        embed.add_field(name="Guild Owner", value=f"{discord.Guild.owner}")
        await ctx.send(embed)

How come?

boreal ravine
slate swan
#

oh ok

boreal ravine
# ocean leaf

pip install -U git+https://github.com/Rapptz/discord.py

slate swan
#

I still get <discord.embeds.Embed object at 0x000001E6C5249700>

boreal ravine
ocean leaf
boreal ravine
#

oh

slate swan
#
    @commands.command()
    async def guildinfo(self, ctx):
        embed = discord.Embed(title="Guild Information")
        embed.add_field(name="Guild Owner", value=f"{ctx.guild.owner}")
        await ctx.send(embed)

boreal ravine
#

hm

boreal ravine
slate swan
#

oh, what does this do tho?

ocean leaf
#

yes try

slate swan
#

what does the code do? like why do i do this? (so i can learn)

boreal ravine
#

since there was ctx as a param it'll return the guild owner from where the command was invoked

slate swan
#

no no, the (embed = embed) why do i do that

ocean leaf
#

embed name means the name of ur embed variable

slate swan
#

okay so the second embed is my variable i get that, but what is the first embed

#

Guys what type of mini games should I do using discord.py?

boreal ravine
#

!d discord.TextChannel.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

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

*a key word

boreal ravine
#

i think its to clarify what embed your using @slate swan not sure though

boreal ravine
#

since embed could be anything

slate swan
#

yeah i read that, thanks

#

but the ctx.guild.owner returns None

ocean leaf
#

or the server is glitched

placid skiff
#

!d discord.Guild.owner

unkempt canyonBOT
#

property owner: Optional[discord.member.Member]```
The member that owns the guild.
boreal ravine
placid skiff
#

It is a member object

#

Should not return None

boreal ravine
#

wait do you have intents

#

!intents @slate swan

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
#

intents?

boreal ravine
boreal ravine
slate swan
#

yes its on

placid skiff
placid skiff
slate swan
#

I enabled them already

boreal ravine
slate swan
#

Did that

#

still returns none

ocean leaf
#

It says create_thread is not defined. i am in 2.0

boreal ravine
placid skiff
slate swan
#

yes

ocean leaf
#

ctx.channel.cretae_thread?

boreal ravine
placid skiff
ocean leaf
#

ok

boreal ravine
#

!d discord.TextChannel.create_thread

unkempt canyonBOT
#

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

Creates a thread in this text channel.

To create a public thread, you must have [`create_public_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_public_threads "discord.Permissions.create_public_threads"). For a private thread, [`create_private_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_private_threads "discord.Permissions.create_private_threads") is needed instead.

New in version 2.0.
placid skiff
#

Try on another guild

slate swan
#

main.py```py
from discord.ext import commands
from discord import Intents

intents = Intents.default()
intents.members = True
client = commands.Bot(command_prefix="-")

commands/guild.py```py
@commands.command()
    async def guildinfo(self, ctx):
        embed = discord.Embed(title="Guild Information")
        embed.add_field(name="Guild Owner", value=f"{ctx.guild.owner}")
        await ctx.send(embed=embed)

boreal ravine
placid skiff
fading harness
#

@slate swan i want my bot to say sth in voice channel

slate swan
#

i followed the docs you guys sent in this channel

placid skiff
#
bot = commands.bot(prefix=. . ., intents = intents)
slate swan
#

oh right sorry

#

Yup works now

#

Thanks!

boreal ravine
#

๐Ÿ˜ข

ocean leaf
#

why is this error happening?

boreal ravine
placid skiff
boreal ravine
#

add a type kwarg when creating a thread

#

Like , type=discord.Thread.public

supple thorn
#
guild = self.bot.get_guild(data["guild"])
member = guild.get_member(data["userid"])
#

Ok so

#

When i print member its None

#

Which shouldnt be None cause its my id and im in the server

#

Its not finding me

placid skiff
#

!d discord.Guild.get_member

unkempt canyonBOT
supple thorn
#

It finds the guild perfectly fine

#

Just not me

placid skiff
#

Why you pass data[]?

#

Is a list?

supple thorn
#

Yes

#

Its from my database

#

Im using mongodb

#

When i print the data["userid"] my id shows up perfectly

#

Its a int

#

So i dont know whats wrong

placid skiff
supple thorn
#

I said its a int

placid skiff
#

Sorry didn't read lol

#

Just for check, try to convert your id into a Member object

placid skiff
#

Did you know Converters?

supple thorn
#

How do i get a member object when it returns none

supple thorn
placid skiff
placid skiff
# supple thorn no

Try doing this, import discord.Member and do member: Member = data["userid"]
Then print it

slate swan
#

typehinting only works in your command parameter, doing that doesn't automatically convert that int to discord.Member

#

just enable members intents

boreal ravine
#

parameters*

#

lol

supple thorn
#

I do have member intents on

slate swan
#

print dict(bot.intents)

#

and show it to me

dense swallow
#

discord.TextChannel always returns a channel and throws an error if it's not found?

past ermine
#

Hi, so I would need if person 1 is typing on server a in global channel that the bot starts typing on all the other servers too in the specific channels that is in a list. can someone help me?

dense swallow
#

Okay thanks

slate swan
placid skiff
supple thorn
#

Fuck

#

@slate swan thanks

slate swan
placid skiff
#

Well bruh, till it works, don't touch it ๐Ÿ˜‚ ๐Ÿ˜‚

slate swan
#

just saying since you're giving wrong info there

hot cobalt
#

Typehints do absolutely nothing unless something additional is present to make them work. In the case of discord.py, the decorators include this functionality, which is why the type hints on your parameters are enforced

#

But they're not going to be enforced if you just have some variable definition somewhere in your code

slate swan
#
@commands.command()
    @commands.is_owner()
    async def reload(self, ctx, *, name: str):
        if ctx.message.content[1] == "cmd":
            try:
                self.client.reload_extension(f"commands.{name}")
            except Exception as e:
                return await ctx.send(e)
            await ctx.send(f"**commands.{name}** reloaded!")
        elif ctx.message.content[1] == "event":
            try:
                self.client.reload_extension(f"..events.{name}")
            except Exception as e:
                return await ctx.send(e)
            await ctx.send(f"**events.{name}** reloaded!")
        else:
            try:
                self.client.reload_extension(f"..{name}")
            except Exception as e:
                return await ctx.send(e)
            await ctx.send(f"**{name}** reloaded")

How come this isn't working man i've been stuck on this for a while now, I dont understand the issue, it returns the exception everytime

hot cobalt
#

It's been a while since I've used discord.py, but iirc ctx.message.content is just the message content in a string form. Which means that ctx.message.content[1] is just grabbing the character at index 1, which can never be equal to a string of length greater than 1

#

You probably meant to check name

#

if name == "cmd": etc

slate swan
#

no no

#

so the thing is

boreal ravine
slate swan
#

i have these files:

commands โ†“
    guildinfo.py
    reload.py
events โ†“
    on_ready.py
main.py

so the thing is I want reload to be able to reload in events, commands and the files outside these folders such as main.py

#

so, when i run the command -reload cmd guildinfo it will reload the guildinfo.py in commands folder
if i do -reload event on_ready it will reload the on_ready.py in the events folder, but if i do -reload main its supposed to reload the main.py

hot cobalt
#

My point still stands, ctx.message.content[1] is just getting the character at index 1 of the message content, which will never be equal to cmd or event etc

slate swan
#

i tried doing list(ctx.message.content)[1] too

#

still wont work

hot cobalt
#

That would make a list of characters, not a list of words

unkempt canyonBOT
#

discord.on_typing(channel, user, when)```
Called when someone begins typing a message.

The `channel` parameter can be a [`abc.Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") instance. Which could either be [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel"), [`GroupChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.GroupChannel "discord.GroupChannel"), or [`DMChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.DMChannel "discord.DMChannel").

If the `channel` is a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") then the `user` parameter is a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"), otherwise it is a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

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

You could split it, but just make a second argument instead

#

Pass in the event as a param as well as the name

slate swan
#

i tried that too but then it threw me an error saying missing argument in reload() when i dont wanna reload in any folder

hot cobalt
past ermine
slate swan
hot cobalt
#
async def reload(self, ctx, *, name: str, event=None):
#

If it's not given it'll be set to None

maiden fable
slate swan
#

Okay thanks

past ermine
#

how do I trigger the typing?

maiden fable
#

Also channel returns the TextChannel, not the server

#

U gotta get the server with channel.guild

past ermine
#

And then?

#
@bot.event
async def on_typing(channel, user):
  if channel.guild in servers:
#

Like that? @maiden fable

slate swan
maiden fable
#

See the embed Python bot sent

slate swan
#
    @commands.command()
    @commands.is_owner()
    async def reload(self, ctx, *, name: str, filename=None):
        if filename == "cmd":
            try:
                self.client.reload_extension(f"commands.{name}")
            except Exception as e:
                return await ctx.send(e)
            await ctx.send(f"**commands.{name}** reloaded!")
        elif filename == "event":
            try:
                self.client.reload_extension(f"..events.{name}")
            except Exception as e:
                return await ctx.send(e)
            await ctx.send(f"**events.{name}** reloaded!")
        else:
            try:
                self.client.reload_extension(f"..{name}")
            except Exception as e:
                return await ctx.send(e)
            await ctx.send(f"**{name}** reloaded")
E.S โ€” Today at 1:35 PM
-reload guildinfo cmd
Misa BOT โ€” Today at 1:35 PM
Extension '..guildinfo cmd' could not be loaded.
past ermine
maiden fable
#

Ah, just do channel.trigger_typing

#

!d discord.TextChannel.trigger_typing

unkempt canyonBOT
#

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

Triggers a *typing* indicator to the destination.

*Typing* indicator will go away after 10 seconds, or after a message is sent.
hot cobalt
#

@slate swan Odd, it seems it just accepted guildinfo cmd as a single arg. It's entirely possible I'm just misremembering and discord.py is just going throw everything after *, into the one param. Like I said it's been a long time since I last used it.
I gotta go, but someone should be able to help you out with getting those arguments separated properly

past ermine
#

Tbh I don't get it.

#

I'll do it somewhen else.

#

But thanks anyway.

valid perch
#

*, arg puts everything not already consumed into arg

#

So you won't get away with adding arguments after it

long fog
#

hi

#

@bot.command(pass_context=True)
@commands.is_owner()
async def shutdown(ctx):
await ctx.author.send('Hazard shutting down...')
await ctx.bot.logout()

#

how to i add extra owner?

maiden fable
slate swan
#

I have written code to automatically create a channel when a user joins the server,
but when the user leaves the server, can I automatically delete the created channel?

maiden fable
#

Like a DB or a dict (cache)

slate swan
#

I see

crystal wind
#

I was wondering if I can do a coroutine for another try/except inside an async def. For instance, when it comes to buttons, you have to use try/except to time out an expiration to components at a certain moment. But for my case, once you press a button, it prompts an ephemeral embed with another component attached to it, I was wondering if I could use two try/except in a asynchronous way (so their own respective components expire independently) instead of a try/except inside a try/except which one depends another.

long fog
#

btw how do you make a bot create a thread

cursive spindle
#

hello

#

i have send a embed message. i can fetch the message and change only something like title or description?

#

will change my whole embed?

gloomy quest
#

Is it just for me or is the random api down?

gloomy quest
#

it will only change the certain thingy(Eg. desc/value)

boreal ravine
slate swan
#

anyone know how i can make my boy embed a message on join

gloomy quest
urban shell
#

hey guys, I am working on a music bot, I'm currently using yt-dl to source the audio, is there a way to use Spotify or some other source with a better audio quality for the same?

slate swan
#

I would like to set permissions for a channel after it is automatically created.
How can I get the Id of the newly created channel on the fly to write the code to set the permissions?

dapper trail
#

hey can anyone tell me how can i send a msg from my bot with second line

#

like

#

my prefix is g
type g help for more info

hollow basin
dapper trail
#
async def on_message(message):
    mention = f'<@!{bot.user.id}>'
    if mention in message.content:
        await message.channel.send("Ya can type g help for more info")```
#

i was making my bot do this command on ping but how do i add second line?

slate swan
hollow basin
dapper trail
hollow basin
#

I'm not a good explainer , I'm still learning

slate swan
#
if ctx.channel == True:
     return

Is this correct? I want to make sure you are talking to the bot privately not in a s ever or channel

slate swan
#

Yes

#

But not in a channel or server

#

Is my code the correct way or nah

hollow basin
#

Ohh i get it now

slate swan
#

Yes

#

one qustion how do u guys make a uhm like when somone pings the owner for example lemon his the owner and i want my bot to say Sorry please ping the Admins

slate swan
zinc trench
#
from discord.ext import commands

Bot = commands.Bot(command_prefix=".")

@Bot.event
async def on_ready():
    print("Bot is Ready")

@Bot.command()
async def hello(ctx):
    await ctx.reply("Hello")

@Bot.command()
async def add(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1+numb2)

@Bot.command()
async def multiply(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1*numb2)

@Bot.command()
async def divide(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1/numb2

Bot.run("tokenpastedhere")```
slate swan
#

Only the Bot.event works?

#

And u forgot to put a )?

slate swan
#

๐Ÿ˜„

junior falcon
#

Someone can help me with requests?

slate swan
junior falcon
#

requests the library i mean

slate swan
#

mh ask one of the @zinc trench or @slate swan

zinc trench
zinc trench
slate swan
#

mh

zinc trench
boreal ravine
boreal ravine
boreal ravine
#

!d discord.Message.content

unkempt canyonBOT
junior falcon
boreal ravine
junior falcon
#

but i dont know how to use requests for make HTTP GET

boreal ravine
#

hm

zinc trench
#

can someone help

#

how to store token in env file in vscode

junior falcon
boreal ravine
junior falcon
#

is a site where you need to vote how i create a variable like {votesTotal}

#

for get the n of votes?

zinc trench
boreal ravine
junior falcon
#

so how i make

boreal ravine
#

well use the way I said earlier and get the json data from the url if it even is json

zinc trench
boreal ravine
#

so yes, you can.

zinc trench
boreal ravine
#

sure I guess

zinc trench
#
from discord.ext import commands
import os
from dotenv import load_dotenv

load_dotenv()
token = os.getenv("token")

Bot = commands.Bot(command_prefix=".")

@Bot.event
async def on_ready():
    print("Bot is Ready")

@Bot.command()
async def hello(ctx):
    await ctx.reply("Hello")

@Bot.command()
async def add(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1+numb2)

@Bot.command()
async def multiply(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1*numb2)

@Bot.command()
async def divide(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1/numb2)

Bot.run(token)```
boreal ravine
#

whats wrong?

zinc trench
#

.

boreal ravine
zinc trench
boreal ravine
supple thorn
#
re = data['mutetime'] - 1
if data["mutetime"] != 0:
          await collection.update_many({"same": "pog"},{'$set':{'mutetime': re}}
slate swan
#

How do I only respond to a certain word IF they tell that word to the private chat with my bot?

supple thorn
#

Ok so this is in a tasks that loops for 1 second it subtracts 1 from a int

zinc trench
boreal ravine
supple thorn
#

It works with the same person only

boreal ravine
supple thorn
#

Only problem is when a different person gets in the database and has a different mute time

zinc trench
boreal ravine
supple thorn
#

It pretty much puts the mute time of the first person

fading harness
#

should i install github copilot

zinc trench
supple thorn
#

To the other dude and i dont really know how to individually subtract 1 from each of their mute time simultanously

boreal ravine
boreal ravine
unkempt canyonBOT
#

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

x == y Checks if two channels are equal.

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

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

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

Wow thx

boreal ravine
boreal ravine
zinc trench
#

btw @boreal ravine why are you so intelligent ๐Ÿ˜‚

boreal ravine
supple thorn
zinc trench
junior falcon
#

printing the json show me all the datas

boreal ravine
patent holly
#

why cant i use the += increment

junior falcon
boreal ravine
boreal ravine
bright palm
#

You can't do = and += lmao

boreal ravine
#

I didn't see that

patent holly
#

idk how i cant use it

#

Ive downloaded python 3

#

and I have no logs

boreal ravine
zinc trench
# boreal ravine full traceback?
from discord.ext import commands
import os
from dotenv import load_dotenv

load_dotenv()
token = os.getenv("token")

Bot = commands.Bot(command_prefix=".")

@Bot.event
async def on_ready():
    print("Bot is Ready")

@Bot.command()
async def hello(ctx):
    await ctx.reply("Hello")

@Bot.command()
async def add(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1+numb2)

@Bot.command()
async def multiply(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1*numb2)

@Bot.command()
async def divide(ctx, numb1:int, numb2:int):
    await ctx.reply(numb1/numb2)

Bot.run(token)```
see my code
boreal ravine
patent holly
junior falcon
#

i just removed my apikey and the nameserver

zinc trench
# boreal ravine i meant the full error not the code

Traceback (most recent call last): File "c:/Users/pnbha/OneDrive/Documents/Python/Discord/bot.py", line 31, in <module> Bot.run(token) File "C:\Users\pnbha\AppData\Roaming\Python\Python38\site-packages\discord\client.py", line 723, in run return future.result() File "C:\Users\pnbha\AppData\Roaming\Python\Python38\site-packages\discord\client.py", line 702, in runner await self.start(*args, **kwargs) File "C:\Users\pnbha\AppData\Roaming\Python\Python38\site-packages\discord\client.py", line 665, in start await self.login(*args, bot=bot) File "C:\Users\pnbha\AppData\Roaming\Python\Python38\site-packages\discord\client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) AttributeError: 'NoneType' object has no attribute 'strip'

bright palm
#

It's cause the environment variable doesn't exist

boreal ravine
bright palm
#

So it is getting the default which is None

boreal ravine
boreal ravine
junior falcon
#

voti

zinc trench
boreal ravine
# junior falcon voti

so if the json was like this

{"statusCode":404,"message":"Questo server non esiste","error":"Not Found"}
``` you'd do 
```py
print(voti["statusCode"])
print(voti["message"])
print(voti["error"])
``` & more
junior falcon
#

Omg thank u

#

it worked

zinc trench
bright palm
#

You are using vscode right?

#

Is your .env in the base folder

#

Of your current workspace

zinc trench
#

yes

#

right

bright palm
#

Can you show your folder tree

stiff nexus
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/cogs/general.py", line 291, in on_raw_reaction_add
    if embed.colour not in utily.color:
TypeError: argument of type 'int' is not iterable
        if embed.colour not in utily.color:
            return

zinc trench
bright palm
#

And this is the root folder?

zinc trench
bright palm
#

.-. have it open as the root folder or put the .env in the Python folder

zinc trench
#

lemme try

#

@bright palm

#

like this?

#

still showing error

ionic ledge
#

it was runnnig smoothly then suddleny this happened

zinc trench
#

lol

boreal ravine
ionic ledge
boreal ravine
#

oh

boreal ravine
#

the getenv() part

ionic ledge
boreal ravine
#

you dont have to show me anything

#

I see your code in the error

ionic ledge
boreal ravine
ionic ledge
boreal ravine
#

@ionic ledge try ["Token"] then

ionic ledge
zinc trench
ionic ledge
lament mesa
#

Replit moment

valid niche
#

Replit has been used to host a lot of spam bots and discord is quickly banning all their IPs

#

So you cannot use replit, not that you should in the first place

boreal ravine
#

Been using replit for about 4 months now and I have never seen that error ยฏ_(ใƒ„)_/ยฏ

valid niche
#

Then it will quickly be banned

slate swan
#

^

boreal ravine
#

A node?

slate swan
#

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.

valid niche
#

Itโ€™s called a node when youโ€™re talking about servers

boreal ravine
#
  • 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.

eh i can easily bypass the "file part" and my bot isnt that big anyways

valid niche
#

Be warned that there is a fair chance you will literally have your account banned from discord

boreal ravine
#

for what reason

valid niche
#

Your bot is on a machine that was used to send spam attacks

boreal ravine
#

eh. I'll keep that in mind.

ionic ledge
valid niche
restive verge
#

is there any function to handle errors caused by Cog.listeners()

valid niche
#

Well some would say their own pc or self hosting is free, if you donโ€™t count electricity bills

valid niche
unkempt canyonBOT
#

discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is printed to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.

The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.9)").

If you want exception to propagate out of the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") class you can define an `on_error` handler consisting of a single empty [raise statement](https://docs.python.org/3/reference/simple_stmts.html#raise "(in Python v3.9)"). Exceptions raised by `on_error` will not be handled in any way by [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
restive verge
#

i did try the on_error function it did not invoke

valid niche
#

how did you implement it?

restive verge
#
class Test(commands.Cog):
    def __init__(self,bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_message(self,message):
        a = 10/0
        print(a)



    @commands.Cog.listener()
    async def on_error(self,event,*args,**kwargs):
        print(event)
        print(args)
        print(kwargs)

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

is it wrong

#

i am new with discord bot programing and no idea how args and kwargs work

boreal ravine
#

learn args, kwargs first

valid niche
#

args and kwargs are literally that, args and kwargs

#

arguments and keyword arguments

#

*args and **kwargs means it will take any argument and any keyword argument, no matter how many

restive verge
#

so is the syntax correct for the above function

boreal ravine
#

I mean

#

it isnt a valid event

valid niche
#

hm i just tried it, for some reason on_error indeed isn't dispatching, and i have a feeling i might know why

#

since on_error is a built in event

slate swan
#

its , on_command_error

valid niche
#

on_COMMAND_error

#

so that only works with COMMANDS

restive verge
#

yes on_command_error works only for commands

valid niche
slate swan
#

oh ic

valid niche
#

since on_error seems to work differently

lusty swallow
#

!d discord.on_error but it's discord.on_command_error for commands

unkempt canyonBOT
#

discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is printed to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.

The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.9)").

If you want exception to propagate out of the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") class you can define an `on_error` handler consisting of a single empty [raise statement](https://docs.python.org/3/reference/simple_stmts.html#raise "(in Python v3.9)"). Exceptions raised by `on_error` will not be handled in any way by [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
valid niche
#

i tried it with this simple test code

from discord.ext import commands

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

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

    @commands.Cog.listener()
    async def on_message(self,message):
        a = 10/0
        print(a)



    @commands.Cog.listener()
    async def on_error(self, event, *args, **kwargs):
        print(event)

bot.add_cog(Test(bot))

bot.run("TOKEN")
#

and it did not work

slate swan
#

maybe this is revalent

valid niche
#

so it can only be dispatched to bot.event() and not to cog.listener()

slate swan
#

ye

restive verge
slate swan
restive verge
#

i am creating a function if any error happens the bot will dm me what error has occured

slate swan
#

im asking , what kind of errors do you expect?

#

if an error in an command , use on_command_error

inner geyser
#

hey there, actually I was facing some errors, I had put some member ids in a blacklist.txt file, and I wanted the bot to not respond when a member id is in blacklist.txt file. Which wasn't really executing correctly

    @commands.Cog.listener()
    async def on_command(self, ctx):
        print(ctx.command.name)
        f = open('cogs/blacklist/blusers.txt').read()
        blusers = f.split('\n')
        print(blusers)
        if str(ctx.author.id) in blusers:
            print("Error")
            return
valid niche
slate swan
#

this wont stop the member from using the command

valid niche
#

on_command runs when someone uses a command, but it's unable to stop the command's exeuction

inner geyser
restive verge
slate swan
#

use a check , or do what sebkuip said

inner geyser
valid niche
#

or a global check works too

slate swan
#

yes

valid niche
#

!d discord.ext.commands.Bot.check

unkempt canyonBOT
#

@check```
A decorator that adds a global check to the bot.

A global check is similar to a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.

Note

This function can either be a regular function or a coroutine.

Similar to a command [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check"), this takes a single parameter of type [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").

Example...
restive verge
#

checks is the best option

inner geyser
slate swan
restive verge
inner geyser
slate swan
restive verge
inner geyser
#

hey umm, I got this error

discord.ext.commands.errors.CheckFailure: The global check functions for command help failed.
inner geyser
restive verge
#

sometimes functions collide with each other

#

cogs

inner geyser
#

also

#

how can I fix it

valid niche
restive verge
#

for example one listener function in cog deletes a message and another listener function in other cog receives an error

inner geyser
#

and how?

valid niche
#

there's no fix if there's no issue

#

you set your check to fail in this situation, and it failed, stopping the command from running

valid niche
#

it's only raising an error so you can handle it if you want, to inform the user the check failed, or do whatever you want

restive verge
#

is there any way to fix that

inner geyser
slate swan
inner geyser
slate swan
slate swan
#

so i have to str(ctx.author.user)

#

but author doesn't have a user attribute

valid niche
#

why?

#

just str(ctx.author)

valid niche
#

author IS the user

boreal ravine
#

^

slate swan
#

ohhh

#

fuck man im fucking dumb

valid niche
#

or rather, it's the member in most cases

#

the only times it's a user is when the member left before ctx was created, or it's in DMs

river kindle
#

i created an afk command but when i set afk

async def afk (ctx, reason = None):
  current_nick = ctx.author.nick
  embed = discord.Embed (title = "AFK", description = f "{ctx.author.mention} is now ** AFK ** - ** Reason: {reason} **", color = 0x00ff00)`
  await ctx.send (embed = embed)
  await ctx.author.edit (nick = f "[AFK] {ctx.author.mention}")```

when the user is put afk, the id of the person is shown with afk, when I used `ctx.author.mention instead`
boreal ravine
#

@river kindle y pass context

river kindle
#

ah?

valid niche
#

also those spaces in the decorator are also...uncommon

#

it's not exactly normal to write it all with spaces

river kindle
#

sorry it's discord make spaces

#

not me

valid niche
#

oh and one last tip: according to good naming conventions, client.command is NOT possible to exist

#

it would be bot.command

#

having good naming is important

river kindle
valid niche
#

according do GOOD NAMING CONVENTIONS client.command shouldn't exist

slate swan
#

Meanwhile I'm already here, https://paste.ofcode.org/39naEBrt7R26i8rmiM3wg9n
How can I make my reload command shorter? I use multiple if statements and multiple embeds (im going to add embed to the exception errors too), so there has to be a way of shortening this right?

valid niche
#

!zen 2

unkempt canyonBOT
#
The Zen of Python (line 2):

Simple is better than complex.

devout quest
#
if message.content.startswith("$ryv"):
    ryv = randint(1,10)
    if ryv == (1):
  
    ryv = [
      "https://www.youtube.com/watch?v=3_wbWSlxG4A",
      "https://www.youtube.com/watch?v=oyCYrCG0_MA",
      "https://www.youtube.com/watch?v=ZU7Q2yvmwfc"
    ]
    await message.channel.send(ramdom.choice(ryv))```
valid niche
#

or not zen 2

devout quest
#

what do i wrong

valid niche
#

which zen was it

devout quest
#

lmao

boreal ravine
#

@devout quest bruh

valid niche
#

!zen 7

unkempt canyonBOT
#
The Zen of Python (line 7):

Special cases aren't special enough to break the rules.

boreal ravine
#

ur variable names

valid niche
#

!zen 6

unkempt canyonBOT
#
The Zen of Python (line 6):

Readability counts.

valid niche
#

there we go, that was it

devout quest
#
if message.content.startswith("$ryv"):
    ryv = randint(1,10)
    if ryv == (1):
  
    ryv = [
      "https://www.youtube.com/watch?v=3_wbWSlxG4A",
      "https://www.youtube.com/watch?v=oyCYrCG0_MA",
      "https://www.youtube.com/watch?v=ZU7Q2yvmwfc"
    ]
    await message.channel.send(ramdom.choice(ryv))```
boreal ravine
#

@devout quest bruh

#

change ur variable names

devout quest
#

what

slate swan
#

Meanwhile I'm already here, https://paste.ofcode.org/39naEBrt7R26i8rmiM3wg9n
How can I make my reload command shorter? I use multiple if statements and multiple embeds (im going to add embed to the exception errors too), so there has to be a way of shortening this right?

valid niche
#

if you could state your issue

devout quest
#

uh, why

boreal ravine
#

because

devout quest
boreal ravine
#

ryx is already set to a random int

devout quest
#

fix my code

boreal ravine
#

no

devout quest
#

that is ryv

valid niche
river kindle
valid niche
boreal ravine
valid niche
#

saying "it doesn't work" isn't enough information

slate swan
#

I don't want to repeat the embeds and the if statements, normally i would use for in loops but idk what to do in this case

boreal ravine
river kindle
#

no, the bot manages to do that, but how did I present that problem to you

slate swan
#

help?

#
async def on_message(message):
      
      
      def check(m):
          return m.channel == message.channel and m.author != client.user and "__Super Rare__" in m.content
          
      embeds = message.embeds
      if not message.embeds:
        await client.process_commands(message)
        return
      footer = (embeds[0].to_dict()['footer'])
   
      if "Type" in footer:
        
        m = await message.channel.send("")
        
        while True:
          response = await client.wait_for('message', check = check, timeout=300) 
          if "__Super Rare__" in response.content:
            break

        await message.channel.send("")```
How do i end this i have no more codes
boreal ravine
#

the code looks fine

slate swan
#

https://paste.ofcode.org/39naEBrt7R26i8rmiM3wg9n
How can I make my reload command shorter? I use multiple if statements and multiple embeds (im going to add embed to the exception errors too), so there has to be a way of shortening this right? I dont want to repeatedly use embeds and if statements

boreal ravine
#

@slate swan also stop reposting stuff

river kindle
slate swan
boreal ravine
boreal ravine
slate swan
#

im asking how I can shorten the if statements and embeds?

boreal ravine
#

you have an if statement

#

that checks for certain files

#

my way is that u check

#

for every file in the arg given

slate swan
#

no you havent understood the code

boreal ravine
#

so no need for "if statements"

slate swan
#
async def reload(self, ctx, name: str = None, filename: str = None):

I have 2 args, one folder and one for the file to reload

boreal ravine
devout quest
#

@cunning lion

cunning lion
boreal ravine
slate swan
#

nah I don't think you understand what I meant by repeatedly calling discord.Embed

#

Idk how to explain tbh

#

nvm ill fix it by my own ty tho

river kindle
boreal ravine
river kindle
boreal ravine
#

if he had a nickname it'll show up

boreal ravine
#

to display nicknames

river kindle
#

no, i have fixed

river kindle
#

thanks @boreal ravine

boreal ravine
#

bruh

#

ok

river kindle
#

trust me

#

it works

slate swan
heavy island
#

how do i get a list of all the members in a server

slate swan
unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
slate swan
#

quick question , does Role.members require member perms?

#

*intents

heavy island
# slate swan !d discord.Guild.members

im trying to print the list out:

print(ctx.message.guild.members)

but that returns this for some reason:
[<Member id=863786161600462918 name='Tebby' discriminator='5433' bot=True nick=None guild=<Guild id=server_id name='ServerName' shard_id=None chunked=False member_count=1792>>]

#

what am i doing wrong

slate swan
#
async def on_member_join(member): 
  embed = discord.Embed(colour=0x000000, title=f"Welcome to kiss!", description=f"There are now {len(list(member.guild.members))} members ![blackxo](https://cdn.discordapp.com/emojis/898398960748724304.webp?size=128 "blackxo")"),
  embed.set_thumbnail(url=f"https://cdn.discordapp.com/icons/721726753147453583/a_e9109e9fbf8e0ecf8613cc5bb8515228.gif")
  embed.set_footer(text=f"{member.guild}", icon_url=f"{member.avatar_url}")
  channel = client.get_channel(id=896885653713870848)

  await channel.send(f'{member.mention}', embed=embed)``` not working when i have a dm on member join
#

any1 know why?

slate swan
#

lemme make sure tho hold on

#

oh wait , why would the embed be sent to user when you are sending it to a channel according to your code....

slate swan
slate swan
#
@client.event
async def on_member_join(member):
    print ("{} joined!".format(member.name))
    print (f'{member.guild.name}')
 
    role = member.guild.roles

    if member.guild and not member.bot:
        async with member.typing():
            embed = discord.Embed(
                title="Welcome to Kiss!",
                colour=0x000000,
            )
            embed.set_thumbnail(
                url="https://cdn.discordapp.com/icons/896885629391106080/a_b6b1f08f67118dc828195dcdc35b0f3d.gif"),
            embed.add_field(name="Make sure to read the rules and get some roles! ![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart") ",
                            value="We are a small Edating, Aesthetic, NSFW server. ![sx3](https://cdn.discordapp.com/emojis/898398973805604894.webp?size=128 "sx3")")
            embed.set_footer(text="Dm zul#1337 for help")
            await member.send(embed=embed)```
#

so , the bot types in the member's dms?

slate swan
#

im not sure , but you cannot have 2 same events

#

ah, so do you know what i should change it to?

#

change it to a listener

#

replace .event to .listen() and try

slate swan
#

hm sure

#

alright gimme a sec

ocean leaf
#

create_thread is not defined

#

how to properly do this?

#

pls tell me

slate swan
slate swan
ocean leaf
slate swan
#

sure if you want to create a thread in the same channel

ocean leaf
#

yes i want

#

ok lemme try

#

i am in version 2.0

#

it shd work

slate swan
slate swan
slate swan
# ocean leaf

you are not , replit wont use discord.py2.0 for sure

slate swan
slate swan
# slate swan

not this one , here py f member.guild and not member.bot: async with member.typing(): embed = discord.Embed( title="Welcome to Kiss!", colour=0x000000, ) embed.set_thumbnail(

#

in the code you sent above

valid niche
#

it's not an actual error that you made a mistake

slate swan
#

so you want me to remove the , in this?

valid niche
#

so if you "fixed" that error, that means you removed the check

slate swan
#

since you have no more kwargs there

ocean leaf
inner geyser
# valid niche it's not an actual error that you made a mistake

uhh, I see, but the thing is, when it doesn;t work, then id doesn;t work for anyone, and when it does work, then it works for everyone

    @check
    async def on_command(self, ctx):
        print(ctx.command.name)
        f = open('cogs/blacklist/blusers.txt').read()
        blusers = f.split('\n')
        print(blusers)
        if str(ctx.author.id) in blusers:
            print("Error")
            return
boreal ravine
#

@ocean leaf wait

#

did u actually do TextChannel.create_thread() ๐Ÿ˜น

slate swan
#

I want to make it so if you use a command a role gets removed from yourself, dm me if u know how thanks :0

slate swan
#

oh

slate swan
boreal ravine
#

@slate swan u sure thats a valid hex code?

slate swan
#

yes 0x000000 returns black iirc

slate swan
boreal ravine
#

@ocean leaf try ctx.channel.create_thread()

slate swan
#

I want to make it so if you use a command a role gets removed from yourself, dm me if u know how thanks :0

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

does discord.Role.members require member intents? ๐Ÿ˜ถ

valid niche
boreal ravine
#

!e print("hi",)

unkempt canyonBOT
#

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

hi
slate swan
valid niche
#

return True means the command may run, return False, or anything else means the command may not run

boreal ravine
#

oh

#

never knew that

slate swan
unkempt canyonBOT
#

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

<class 'str'>
slate swan
#

owh

boreal ravine
#

uhuh..

#

still a string

#

!e print(type("h",))

#

huh

inner geyser
slate swan
#

my bad

#

nvm now

hasty iron
unkempt canyonBOT
#

@hasty iron :white_check_mark: Your eval job has completed with return code 0.

<class 'tuple'>
slate swan
gleaming torrent
#

how do I make environment variables work?

hasty iron
#

type is not a function but yes

inner geyser
restive verge
#

custom checks

slate swan
hasty iron
#

type is a class

inner geyser
# restive verge custom checks

umm, no, actually I don't want any of the blacklisted users to execute any command, I mean how can I go adding checks to every command

valid niche
# inner geyser I tried them already, same thing as before

you should return true when the check passes, and the user is allowed to use the command. You should return False if they are not allowed. This will cause a checkfailure error, which you can handle to inform the user that they are not allowed

#

that's how the intended setup is

restive verge
#

Today we remove our messy command decorators and make it into one custom check.

Read description for links!

----------------------------------------ยญยญ---------------------------------------ยญ-ยญ--

Need Help?
Require help with your code? Why not head on over to our dedicated support discord where you can recieve only the best support: https://me...

โ–ถ Play video
restive verge
#

take this video

inner geyser
restive verge
#

u can add role checks like has role blacklisted which will make your code simpler

restive verge
#

@inner geyser did it work

slate swan
slate swan
slate swan
#

(remove it)

#

alright

restive verge
#

๐Ÿ˜…

placid skiff
#

How i can parse Member.roles so it returns me only a list of role names?

slate swan
#

you need to iterate thru it

slate swan
wicked atlas
placid skiff
slate swan
#

wrong ping

maiden fable
#

!list-comp

unkempt canyonBOT
#

Do you ever find yourself writing something like this?

>>> squares = []
>>> for n in range(5):
...    squares.append(n ** 2)
[0, 1, 4, 9, 16]

Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:

>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]

List comprehensions also get an if statement:

>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]

For more info, see this pythonforbeginners.com post.

maiden fable
#

You should do this

placid skiff
#

I try

maiden fable
#

And u can do role.name for role in...

slate swan
#
    async def reload(self, ctx, folder: str = None, file: str = None):
        ftype = {"commands": "cmd", "events": "event"}
        for f in ftype:
            if folder in ftype or folder in ftype.values():
                try:
                    self.client.reload_extension(f"{f}.{file}")
                except Exception as e:
                    return await ctx.send(e)

                await ctx.send("successfully reloaded")
                break
            if folder not in ftype or folder not in
                await ctx.send("invalid arguments")
                break
``` When I type event instead of cmd, it wont work because it's only iterating through the first key, how can I fix this?
proven jewel
maiden fable
#

???

proven jewel
#

you will help me resize and make the avatar under the overlay

foggy gale
maiden fable
slate swan
#

I already know the values

maiden fable
maiden fable
slate swan
proven jewel
#

?

maiden fable
slate swan
maiden fable
# proven jewel and come on who's for the pillow

I guess many people? Also try opening a help channel since this channel is specifically for help with Discord API Libraries and you would have more chances of someone helping you in a help channel

proven jewel
slate swan
# maiden fable Tell me why it's not doing it then....?

it's because it never can reach the second iteration because i break the loop, and if i dont break the loop, it will print twice, and on the second iteration it will raise an error because the path for the reload_extension() will be wrong

maiden fable
slate swan
maiden fable
#

Also why don't u just do if folder in ftype.keys() or folder in ftype.values()?

#

Why u looping

slate swan
#

because i need the f

#

im declaring the path

#
        for f in ftype:
            if folder in ftype or folder in ftype.values():
                try:
                    self.client.reload_extension(f"{f}.{file}")
maiden fable
#

Can't u simply use regex or something like folder.replace("command.", "cmd.") or something?

slate swan
#

if its a cmd, f = "commands", if its a event, f = "events", but for it to be events, it needs to reach the second iteration which it doesnt

maiden fable
#

Don't ping mods or helpers randomly

proven jewel
#

sorry

maiden fable
#

Ghost Ping ๐Ÿ˜

placid skiff
maiden fable
wicked atlas
#

Just curious

placid skiff
#

i used discord.utils.find to search for the role in the list of roles

wicked atlas
#

Ah, so thats what you were doing

#

Trying to check if a user has a role?

slate swan
#

hey guys im trying to make a bot where if u type a command and u have a certiain role then it removes your own role

@commands.has_role('eligible')
async def name(ctx, role: discord.Role, user: discord.Member):
placid skiff
ocean leaf
placid skiff
#

I couldn't use checks don't worry xD
i'm not stupid

#

i have to check if a user has a role that is saved in my database

slate swan
#

hello?

placid skiff
#

so until the command is executed i don't know what role that is

wicked atlas
glacial kernel
#

how to make a music bot?

ocean leaf
slate swan
#

wow u guys help alot

ocean leaf
#

In 2.9 only

wicked atlas
restive verge
slate swan
#

exactly u know what i want to do

#

so u know how to help

wicked atlas
#

Well, lets see, you can use Member.remove_roles i believe to remove roles

#

!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.
placid skiff
slate swan
wicked atlas
#

It is a role object

#

Looks like your command takes a tole object as a parameter, so you should just be able to pass it in without doing anything to it

final iron
slate swan
#

i mean u can

#

but okie dokie

wicked atlas
#

Just donโ€™t use youtube downloaders or other things that are against tos

final iron
#

I meant you can't do it following tos

#

Theres no point now a days imo

wicked atlas
#

Yeah

slate swan
#

@slate swan ```@client.event
async def on_member_join(member):
print ("{} joined!".format(member.name))
print (f'{member.guild.name}')

role = member.guild.roles

if member.guild and not member.bot:
    async with member.typing():
        embed = discord.Embed(
            title="Welcome to Kiss!",
            colour=0x000000,
        )
        embed.set_thumbnail(
            url="https://cdn.discordapp.com/icons/896885629391106080/a_b6b1f08f67118dc828195dcdc35b0f3d.gif"),
        embed.add_field(name="Make sure to read the rules and get some roles! ![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart") ",
        value="We are a small Edating, Aesthetic, NSFW community. ![sx3](https://cdn.discordapp.com/emojis/898398973805604894.webp?size=128 "sx3")")
        embed.set_footer(text="Dm zul#1337 for help")
        await member.send(embed=embed)

        embed = discord.Embed(colour=0x000000, title=f"Welcome to kiss!", description=f"There are now {len(list(member.guild.members))} members ![blackxo](https://cdn.discordapp.com/emojis/898398960748724304.webp?size=128 "blackxo")")
        embed.set_thumbnail(url=f"https://cdn.discordapp.com/icons/721726753147453583/a_e9109e9fbf8e0ecf8613cc5bb8515228.gif")
        embed.set_footer(text=f"{member.guild}", icon_url=f"{member.avatar_url}")
        channel = client.get_channel(id=896885653713870848)

    await channel.send(f'{member.mention}', embed=embed)``` is this better
fallow mauve
#

how do i make it so that if someone DMs my bot, it DMs me their message and who sent it?

#

kinda like @novel apex

tight jasper
#

@fallow mauve that should do it?

glacial kernel
#

music bot?

tight jasper
#

i think

sick birch
#

i don't know if the UPDATE statement returns anything

glacial kernel
#

do you have something to help?

sick birch
#

what you could do is generate a UID for each warn, and do it that way maybe?

tight jasper
sick birch
#

why do you need the update?

#

why would you want to update a warn

#

one would think that you just insert a new row for each warn

#

How exactly?

#

SQLite is blazing fast

#

Your code is kind of confusing me because Iโ€™m not sure if UPDATE returns anything

slate swan
#

I need help Pls Dm me whoever is good at Python Bot Progamming/Coding.

#

How can i set the embed color later on?

lament mesa
slate swan
#

embed doesn't have that attribute tho?

lament mesa
lament mesa
#

!d discord.Embed.colour

unkempt canyonBOT
#

The colour code of the embed. Aliased to color as well. This can be set during initialisation.

lament mesa
#

its a property iirc

slate swan
#

ooh

lapis lintel
#

Is it correct to store data that the bot needs on a json? Or does it has to be a db?

#

Say for example, data of a minigame my bot has, data of which prefix the bot has on that server, things like that

slate swan
#

DB

#

No hesitation

#

Does anyone know why my bot keeps restarting randomly? I have logging setup.
It restarts without any errors.
And it happens randomly (after an hour of the startup, 3 hours after that, 10mins after that, etc.)
it re-runs on_ready, and it goes offline on discord for awhile
It shuts off then turns back on but keeps data (like the bot's uptime time)

#

(Shud I ask this in a help channel)

boreal ravine
#

@slate swan what host do you use?

slate swan
#

I tried multiple hosts

#

Google VPS, WitherHosting, Dynox, Repl.it, Heroku, and even my pc

boreal ravine
#

which one were u using

placid escarp
#

how can i make loop that checks if there are messages in channel(by id) and then delete all messages