#discord-bots

1 messages · Page 727 of 1

boreal ravine
#

lol

#

o

honest vessel
#

it sill dosnt react

#

ok so is there anyway to grab messages from threads like on_message() has ?

#

like an event or

#

i want bot to be able to moderate the threads

slate swan
#

why the command bot.logout doesn't work?

tulip canyon
#

i can't from cogs.utils.checks import embed_perms, cmd_prefix_len

#

!d from cogs.utils.checks import embed_perms, cmd_prefix_len

unkempt canyonBOT
#

7.11. The import statement


import_stmt     ::=  "import" module ["as" identifier] ("," module ["as" identifier])*
                     | "from" relative_module "import" identifier ["as" identifier]
                     ("," identifier ["as" identifier])*
                     | "from" relative_module "import" "(" identifier ["as" identifier]
                     ("," identifier ["as" identifier])* [","] ")"
                     | "from" relative_module "import" "*"
module          ::=  (identifier ".")* identifier
relative_module ::=  "."* module | "."+
```...
heavy folio
#

look at his code, nothings wrong

#

but replit is showing that error

slate swan
honest vessel
#

yeah i just figured out i might need an update on discord.py

#

it sais i have 1.7.3

#

but there should be a version 2.0 right?

#
python3 -m pip install -U "discord.py[voice]"
Collecting discord.py[voice]
  Using cached discord.py-1.7.3-py3-none-any.whl (786 kB)
Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in ./bot-env/lib/python3.9/site-packages (from discord.py[voice]) (3.7.4.post0)
Requirement already satisfied: PyNaCl<1.5,>=1.3.0 in ./bot-env/lib/python3.9/site-packages (from discord.py[voice]) (1.4.0)
Requirement already satisfied: chardet<5.0,>=2.0 in ./bot-env/lib/python3.9/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (4.0.0)
Requirement already satisfied: yarl<2.0,>=1.0 in ./bot-env/lib/python3.9/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (1.7.2)
Requirement already satisfied: async-timeout<4.0,>=3.0 in ./bot-env/lib/python3.9/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.0.1)
Requirement already satisfied: typing-extensions>=3.6.5 in ./bot-env/lib/python3.9/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (4.0.1)
Requirement already satisfied: multidict<7.0,>=4.5 in ./bot-env/lib/python3.9/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (5.2.0)
Requirement already satisfied: attrs>=17.3.0 in ./bot-env/lib/python3.9/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (21.4.0)
Requirement already satisfied: cffi>=1.4.1 in ./bot-env/lib/python3.9/site-packages (from PyNaCl<1.5,>=1.3.0->discord.py[voice]) (1.15.0)
Requirement already satisfied: six in ./bot-env/lib/python3.9/site-packages (from PyNaCl<1.5,>=1.3.0->discord.py[voice]) (1.16.0)
Requirement already satisfied: pycparser in ./bot-env/lib/python3.9/site-packages (from cffi>=1.4.1->PyNaCl<1.5,>=1.3.0->discord.py[voice]) (2.21)
Requirement already satisfied: idna>=2.0 in ./bot-env/lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.3)
Installing collected packages: discord.py
Successfully installed discord.py-1.7.3
``` how the hell do i get it to install the 2.0?
shadow wraith
#

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

#

wait i misread it it's discord.py[voice]

shadow wraith
honest vessel
#

maybe voice has not 2.0?

hardy yoke
honest vessel
#

ok will try disnake then

#

or does anyone has any other fork recommended? whats most popular?

shadow wraith
#

but how will i make it so it effects the help command

slow fiber
#

!e `g1="English Merry Christmas"
g2="Dutch Prettige Kerstdagen"
g3="Swedish God jul"
g4="Finnish Hauskaa joulua"
g5="German Frohe Weihnachten"
g6="Italian Buon Natale"
g7="Catalan: Bon Nadal"
g8="Cornish: Nadelik Lowen"
g9="Galician: Bo Nadal"
g10="Irish: Nollaig Shona"
g11="Latin: Felix dies Nativitatis"
g12="Maltese: il-Milied it-Tajjeb"
g13="Occitan: Bon Nadal"
g14="Sami (Lule): Buorre javla"
g15="Scottish Gaelic: Nollaig Chridheil"
g16="Turkish: Mutlu Noeller"
g17="Burmese: Hnit thit ku mingalar pa"
g18="Cebuano: Malipayong pasko"
g19="Javanese: Sugeng Natal"
g20="Japanese: Meri Kurisumasu"
g21="Jingpho: Ngwi pyaw ai X'mas rai u ga"
g22="Karo Batak: Selamat wari Natal"
g23="Malay: Selamat hari Natal"
g24="Sundanese: Wilujeng Natal"

print("Welcome to Xanders Virtual Calendar! Enter a number 1-24")
num=int(input(""))

if 0 < num < 25 :
print("Here is your greeting:")
else :
print("Please enter a number 1-24")

if num == num:
x=num
y=g+X
print(y)`

unkempt canyonBOT
#

@slow fiber :x: Your eval job has completed with return code 1.

001 | Welcome to Xanders Virtual Calendar! Enter a number 1-24
002 | Traceback (most recent call last):
003 |   File "<string>", line 27, in <module>
004 | EOFError: EOF when reading a line
slate swan
#
@client.command()
async def usun(ctx,ilość = 5):
  await ctx.channel.purge(limit=
quantity)
  await ctx.send("deleted")
``` i have problem with "quantity"
spring flax
#

@slate swan you didn't even define quantity

slate swan
spring flax
#

What is ilosc?

slate swan
#

quantity in my Language

#

ok i already fixed it

shadow wraith
#

@slate swan how do u make the bot make a new channel because disnake.Guild.create_text_channel() no work 😭

slate swan
cold sonnet
#

!d disnake.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://docs.disnake.dev/en/latest/api.html#disnake.TextChannel "disnake.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_channels "disnake.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://docs.disnake.dev/en/latest/api.html#disnake.Member "disnake.Member") or a [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")) as the key and a [`PermissionOverwrite`](https://docs.disnake.dev/en/latest/api.html#disnake.PermissionOverwrite "disnake.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.TextChannel.edit "disnake.TextChannel.edit") will be required to update the position of the channel in the channel list...
hardy yoke
cold sonnet
#

you. are. cappin

shadow wraith
#
@commands.command(aliases=["cchannel", "createchannel"])
    @commands.guild_only()
    @commands.has_guild_permissions(manage_channels=True)
    async def create_channel(self, ctx, channel_name):
        guild = disnake.Guild
        channel = await guild.create_text_channel(channel_name)
#

don't mind the indents there, copy pasting code into discord fucks the indents

slate swan
#

Wot , the guild must be an instance of discord.Guild , not the class itself

cold sonnet
#

guild = disnake.Guild

shadow wraith
slate swan
#

eh

#

Noo

cold sonnet
#

that's still not it

shadow wraith
#

alr so what's next

slate swan
#

A guild object , not a class

Basically use something like ctx.guild ....

cold sonnet
#

use ctx.guild

shadow wraith
#

!d disnake.Guild

unkempt canyonBOT
#

class disnake.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.
shadow wraith
cold sonnet
#

cap

shadow wraith
#

not cap.

cold sonnet
#

bru

#

the docs don't work like that

shadow wraith
#

true true it looks for documentation not if it exists

cold sonnet
#

!d discord.ext.commands.Context.guild

unkempt canyonBOT
cold sonnet
#

returns a guild object

shadow wraith
#

oh

cold sonnet
#

which has the create_text_channel() method

slate swan
#

You made some mistake

shadow wraith
#

nah i ain't capping

#

i dont think it's documented either way

slate swan
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
slate swan
#

It is

#
async def on_membed_join(member):
  channel = discord.utils.get(member.guild.channels, id=925038725078057029)
  await channel.send(f"{member.mention} welcome")``` and error ```Traceback (most recent call last):
  File "main.py", line 170, in <module>
    @client.event()
TypeError: event() missing 1 required positional argument: 'coro'```
#

help

shadow wraith
#

i meant ctx.guild.create_text_channel(name=...)

slate swan
#

it's same

cold sonnet
#

not membed

#

and maybe save ur file and restart your bot idk

slate swan
#

LOL my bad

fading jetty
#

I am new to this server
Anyone bother helping me ?

slate swan
# cold sonnet not membed

error again Traceback (most recent call last):
File "main.py", line 170, in <module>
@client.event()
TypeError: event() missing 1 required positional argument: 'coro'

cold sonnet
#

what's in your error is not in your code

cold sonnet
#

yeah

#

you already removed the brackets

#

the error says they're still there

slate swan
#

@client.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.channels, id=925038725078057029)
await channel.send(f"{member.mention} welcome")

cold sonnet
#

right

slate swan
#
    @client.event()
TypeError: event() missing 1 required positional argument: 'coro'```
#

again

cold sonnet
slate swan
#

Save the file correctly

#

im using replit

#

And change every single @client.event() to @client.event

cold sonnet
#

restart your bot

#

stop running it

#

then start running it

slate swan
#

learn to read your errors shrug

honest vessel
#

so whats the ratelimit for a bot to send messages?

#

how frequent is max?

slate swan
#

discord kept it a secret

velvet tinsel
velvet tinsel
#

We’ll release the findings

#

Mwahahaha

#

Discord can’t stop us

honest vessel
viscid wren
#

how can i create slash command

slate swan
slate swan
honest vessel
#

@slate swan messages/seconds?

#

thanks

lunar quail
#

I use bot.wait_for(...) to listen for a single event under @bot.command() but how do I listen for multiple events ?

Say the bot proceeds to do something after an confirmation by either an "👌" reaction or user saying "yes", here the bot would need to listen for raw_reaction_add and message but how do I do that?

suppose I write something like this

await bot.wait_for("raw_reaction_add", lambda payload: payload.emoji.name == "👌")
await bot.wait_for("message", lambda msg: msg.content.lower() == "yes")

"""...Bot proceeds with stuff..."""

Here the problem is that the user could only proceed after saying "yes" and reacting with the emoji. I only want the bot to proceed with either of them. How do I do that?

Thanks for the help.

pale turtle
#
done, pending = await asyncio.wait([
                    bot.loop.create_task(bot.wait_for('message')),
                    bot.loop.create_task(bot.wait_for('reaction_add'))
                ], return_when=asyncio.FIRST_COMPLETED)

try:
    stuff = done.pop().result()
except ...:
    # If the first finished task died for any reason,
    # the exception will be replayed here.
for future in done:
    # If any exception happened in any other done tasks
    # we don't care about the exception, but don't want the noise of
    # non-retrieved exceptions
    future.exception()

for future in pending:
    future.cancel()  # we don't need these anymore 
``` This is an example from d.py server
slate swan
#

Yeah, using asyncio.wait

#

You can add an option to wait for the first event dispatched by the websockets.

#

!d asyncio.wait

unkempt canyonBOT
#

coroutine asyncio.wait(aws, *, timeout=None, return_when=ALL_COMPLETED)```
Run [awaitable objects](https://docs.python.org/3/library/asyncio-task.html#asyncio-awaitables) in the *aws* iterable concurrently and block until the condition specified by *return\_when*.

The *aws* iterable must not be empty.

Returns two sets of Tasks/Futures: `(done, pending)`.

Usage:

```py
done, pending = await asyncio.wait(aws)
```  *timeout* (a float or int), if specified, can be used to control the maximum number of seconds to wait before returning...
dense coral
#
import asyncio
import random
@bot.command()
async def gstart(ctx, time=None, *, prize=None):
  if time == None:
   return await ctx.reply("נא לרשום זמן!")
  if prize == None:
   return await ctx.reply("נא לרשום פרס!")
  embed=discord.Embed(title="New Giveaway!", color=0x00e1ff)
  embed.add_field(name="Prize:", value=f"{prize}", inline=False)
  embed.add_field(name="Hosting By:", value=ctx.author.mention, inline=False)
  time_numbers = {"s" : 1 seconds, "m" : 60, "h" : 3600, "d" : 86400}
  give_time = int(time[0]) * time_numbers[time[-1]]
  embed.add_field(name="Ened In:", value=f"{time}", inline=False)
  embed.add_field(name="Winner(s):", value=f"Soon", inline=False)
  give_msg = await ctx.send(embed=embed)
  await give_msg.add_reaction(":tada:")
  await asyncio.sleep(give_time)
  new_msg = await ctx.channelfetch_message(give_msg.id)
  users = await new_msg.reactions[0].users().flatten()
  users.pop(users.index(bot.user))
  winners = random.choice(users)
  await ctx.send(f":tada: Congratulations, {winners.mention} You won **{prize}**!")
  em=discord.Embed(title="Giveaway Ened!", color=0x00e1ff, timestamp=ctx.message.create_at)
  em.add_field(name="Prize:", value=f"{prize}", inline=False)
  em.add_field(name="Hosting By:", value=ctx.author.mention, inline=False)
  em.add_field(name="Winner(s):", value=winners.mention, inline=False)
  await give_msg.edit(embed=em)```
It adds reaction, but it does not announce a winner.
quick gust
#

shouldn't it be ctx.channel.fetch_message(give_msg.id)?

#

u forgot a .

dense coral
#

ok

#

eroor

final iron
dense coral
final iron
#

Did you restart your bot?

dense coral
final iron
#

Send the code then

dense coral
#
@bot.command()
async def gstart(ctx, time=None, *, prize=None):
  if time == None:
   return await ctx.reply("נא לרשום זמן!")
  if prize == None:
   return await ctx.reply("נא לרשום פרס!")
  embed=discord.Embed(title="New Giveaway!", color=0x00e1ff)
  embed.add_field(name="Prize:", value=f"{prize}", inline=False)
  embed.add_field(name="Hosting By:", value=ctx.author.mention, inline=False)
  time_numbers = {"s" : 1 seconds, "m" : 60, "h" : 3600, "d" : 86400}
  give_time = int(time[0]) * time_numbers[time[-1]]
  embed.add_field(name="Ened In:", value=f"{time}", inline=False)
  embed.add_field(name="Winner(s):", value=f"Soon", inline=False)
  give_msg = await ctx.send(embed=embed)
  await give_msg.add_reaction(":tada:")
  await asyncio.sleep(give_time)
  new_msg = await ctx.channel.fetch_message(give_msg.id)
  users = await new_msg.reactions[0].users().flatten()
  users.pop(users.index(bot.user))
  winners = random.choice(users)
  await ctx.send(f":tada: Congratulations, {winners.mention} You won **{prize}**!")
  em=discord.Embed(title="Giveaway Ened!", color=0x00e1ff, timestamp=ctx.message.create_at)
  em.add_field(name="Prize:", value=f"{prize}", inline=False)
  em.add_field(name="Hosting By:", value=ctx.author.mention, inline=False)
  em.add_field(name="Winner(s):", value=winners.mention, inline=False)
  await give_msg.edit(embed=em)```
#

it is from now

#

Thank you sir, I got along.

final iron
#

The line should be fine

dense coral
#

tank you!

#

member.guild.member_count

slate swan
#

This will give the member count of the current guild.

#

Not the total members in all guilds your bot is in.

#

If you want to get the total members in all guilds, as your question kind of says, you'd need to use that

#

!d discord.ext.commands.Bot.get_all_members

unkempt canyonBOT
#

for ... in get_all_members()```
Returns a generator with every [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") the client can see.

This is equivalent to:

```py
for guild in client.guilds:
    for member in guild.members:
        yield member
slate swan
#

And you should use len(set()) on it

#

Or bot.users if you need only the number of users

#

"users"

dense coral
#

How do I make the status of the bot show how many members there are on the server?

#

member.guild.member_count
no working in status

honest vessel
#

if u can get it to show a text replace text with wat they just said above ur question

#

@dense coral

kindred drum
#
@commands.Cog.listener()
    async def on_member_join(self, member):
        print("[INFO]:", member, "has joined" )``` why does this not output anything when someone joins?
#

still can't figure it out 😭

dense coral
kindred drum
#

still doesn't work @dense coral

dense coral
kindred drum
#

nvm works

#

thank you SO MUCH!

dense coral
#

I was glad to help! 🙂

kindred drum
#

although I don't get why this doesn't print

#

@dense coral py @commands.Cog.listener() async def on_ready(self): print("[INFO]: Bot is now online")

shadow wraith
kindred drum
#

I did but still same thing

#
async def on_ready(self):
        print("[INFO]: Bot is now online")```
cloud dawn
#

We got logging at home:

#

!d logging

unkempt canyonBOT
#

Source code: Lib/logging/__init__.py...

cloud bison
shadow wraith
#

does anyone know how to make a channel with the bot. ctx.guild.create_text_channel(name=...) doesn't work

slate swan
#

!d discord.Member.ban

unkempt canyonBOT
#

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

Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
honest vessel
#

ah rewriting bot from discord.py to disnake wasnt that much pain in the ass

slate swan
shadow wraith
#

it was an attributeError: 'Guild' object has no attribute 'create_text_channel'

slate swan
#

What library and version are you using?

shadow wraith
#

disnake and idk what version im using

honest vessel
#

prob latest

#

but u can check version with pip list, or import disnake print(disnake.__version__) i think

shadow wraith
#

im using 2.2.1

slate swan
#

Well, mind sharing the code because it's correct?

shadow wraith
#

wait lemme run the code one more time

honest vessel
#

should get errors?

shadow wraith
#

oh shit it actually worked i just forgot to test it 💀

#

last time i did disnake.Guild.create_text_channel(name=name)

honest vessel
#

trying slash command with disnake,

invite = await ctx.channel.create_invite(max_uses=0,unique=False)

would it be correct and work if i change ctx, to inner?

#

or inner.response?

shadow wraith
#

oh yeah and how do you get the list/tuple of the ctx.author's perms

honest vessel
#

why dont you have a decleration has_permissions()

slate swan
#

inner? You mean, inter/interaction?

honest vessel
#

@slate swan like there is no ctx, so i am wondering how i can create the invite in the slash command - or must i fetch by a channel id to greate channel object and etc etc?

shadow wraith
slate swan
shadow wraith
#

or does disnake store it somewehre else :P

honest vessel
#

ah yeah cool just had to use the inter

#

indentation is wrong

slate swan
honest vessel
#

@slate swangot it thanks I just had to ask could have tested

slate swan
#

You can also always type hint, so that you have IntelliSense suggesting things :)

honest vessel
#

@slate swanban(*,

#

you never say who to ban and what is *?

supple summit
#
@commands.command()
@commands.has_permissions(ban_members = True)
async def ban(self, ctx, member: discord.Member):
  await member.ban()
#

this is example btw

#

lemme fix

#

there

#

yes it will work

grizzled scaffold
#

Yes

supple summit
#

im using this lib myself

final iron
#

Disnake seems to be one of the most popular dpy forks

manic wing
#

^^^

final iron
#

Read the error

supple summit
#

you need bot to have admin permissions

#

or ban members permission like it said

#

you need for bot to have the perms

#

in server

fluid spindle
#

Probably, yeah...

supple summit
#

oh im stupid

#

you need to have the admin perms

fluid spindle
supple summit
#

yes its possible i think

#

not really

#

i never needed this feature

quick gust
#

This error means the bot doesn't have permissions

#

This means u don't have permissions

#

Yes

#

yes

#

u can just get the role in some way and store it in a role variable then ctx.author.add_roles(role)

#

u can get the role by ctx.guild.get_role(role_id) or by discord.utils

#

(discord.utils is slow)

#

if u have the ID, u can do what I said before, ctx.guild.get_role

#

because add_roles needs a role object iirc

#

kay

supple summit
#

you can try doing it without await

#

but idk if it will work

#

sad

#

if no error then it works

#

@slate swan can you do like

#
    @commands.command()
    async def giveadmin(self, ctx):
        role = ctx.guild.get_role(856954172262842378)
        await ctx.author.add_roles(role)
#

idk if it works btw

#

cause i don't really need role stuff in my bot

#

does it have manage_roles permission

dapper cobalt
#

Is the bot's role hierarchy higher than the user's role hierarchy?

#

Well, I'm going to ask you a question. Can a normal user, perhaps a server moderator, do any action to the server's owner?

#

The answer is no. Discord bots are no different.

thin kelp
#
@client.command()
@commands.has_permissions(manage_guild=True)
async def prefix(ctx,*,pf=""):
    if pf!="":
        #changes prefix here
    else:
        await ctx.send(f"My prefix is `{get_prefix(client,ctx)[0]}`")```
fluid spindle
#

@slate swan Did you make a role from the Discord settings yet?

dapper cobalt
dapper cobalt
fluid spindle
thin kelp
#

I am confused as to how to do it

dapper cobalt
thin kelp
dapper cobalt
thin kelp
#

I'll change that right now

#

but thats not the problem i am facing

slate swan
dapper cobalt
#

Unless, you have mentioning the bot a valid prefix.

manic wing
thin kelp
#

HOLY SHIT

#

You have a point

slate swan
thin kelp
#

i am so dumb

slate swan
thin kelp
#

rest is definitely something that i need

fluid spindle
#

I meant that I've given the server owner some role with a bot, but I've never done what you're doing here

velvet tinsel
#

yes

#

what’s the problem

#

🚶‍♂️

fluid spindle
#

Is the role you're trying to give above in the role hierarchy than the bot?

velvet tinsel
#

And what’s wrong 🚶‍♂️

#

Are you sure it has admin permissions? Are they admins as well?

#

? Display code

velvet tinsel
#

The lack of PEP8 scares me

fluid spindle
#

Is neither of the commands working?

keen talon
velvet tinsel
#

Which one is not working?

velvet tinsel
#

The ban or the giveadmin? Or both?

#

I’m reckoning they are in a class?

#

yert they are

#

@brave vessel I know you’re there, show yourself

brave vessel
#

lol, hi

#

I was gonna say that the indentation is the reason why it wasn't working

#

but iirc that's just a quirk of copy and pasting code

fluid spindle
#

Looking at the error they're getting... I'm thinking it's just a role hierarchy issue

#

But it's still not clear if the error is for ban or giveadmin

velvet tinsel
#

did you try to ban a higher role? Does the bot have the right permissions?

fluid spindle
#

The bot should be above the role you're trying to give

#

just curious, what was the problem?

#

ok

honest vessel
#

well

velvet tinsel
#

ok

honest vessel
#

show code

velvet tinsel
#

You don’t have permissions

#

Show code

#

Is that the current role ID?

#

what happens instead?

#

I think you need to await get role

#

hm, maybe it’s bot.get_role?

manic wing
#

nice

velvet tinsel
#

Or idk yert

manic wing
#

MAN SAID DISCORD.BOT

velvet tinsel
manic wing
#

also its not guild

#

OMMMMMMMGGG

#

!d discord.Guild.get_role

unkempt canyonBOT
velvet tinsel
#

Calm down

manic wing
velvet tinsel
#

My knee hurts like hell

manic wing
#

can i show you something

velvet tinsel
#

ok

manic wing
#

!d discord.ext.commands.Bot || not discord.bot ;-;

unkempt canyonBOT
#

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

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

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

@novel apex

velvet tinsel
#

I love you Caeden

manic wing
#

shit wrong mods 😳

manic wing
honest vessel
#

@manic wing del self

#

😄

manic wing
honest vessel
#

@slate swan are u sure u get an role object?

#

double check perms cus thats the error

#

for bot

#

the perms of bot in server

slate swan
#

What are the permissions of the bot, and what is the role hierarchy.

#

And what is the role hierarchy?

honest vessel
#

bot needs to have higher perms than itself to give

slate swan
#

The order in which the roles are displayed in your server settings.

honest vessel
#

a mod cant mod one

velvet tinsel
#

<@&831776746206265384>

honest vessel
#

or remove

slate swan
#

Again, what is the role hierarchy...

velvet tinsel
#

wdym

honest vessel
#

aaah nfts n bitcoins altcoins get few dms from dis server but stopped cus reporting all

velvet tinsel
#

me too

#

I like NFTs but people DM me a lot

slate swan
#

The bot role is lower than the admin role, you can't give yourself admin in any server.

blissful lagoon
#

!ban 927991919924105247 Looks like you joined just to advertise.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @wise vapor permanently.

slate swan
#

That doesn't mean anything

#

No it's not

honest vessel
#

u can give or pass owner thats onlything u can pass that is higher role

slate swan
#

If the role admin is above the bot role, then the bot can't give that role to anyone. Even with admin permissions.

honest vessel
#

u cant give same role as bot has

#

ye

#

thats only role u can give above bots own role

#

make bot owner n it can grant u admin

#

etc

velvet tinsel
#

Guys surprised

honest vessel
#

a admin cant admin others or remove it

#

but admin can give n remove moderation

#

exemple

slate swan
#

!ot

unkempt canyonBOT
slate swan
#

Check if the bot role is below the admin role or not.

timid falcon
#

!ot

slate swan
#

Then you ask someone who can access it.

timid falcon
honest vessel
#

@slate swan remove admin perm... n allow other roles basicly "admin" n bot will be able to give u it

timid falcon
#

Deleted

velvet tinsel
honest vessel
#

i like turtles

slate swan
#

Just ask to someone in the server to send a screenshot of the roles..

honest vessel
#

@slate swan wen u go to role perms uncheck admin. n allow everything else

slate swan
#

If you're trying to give yourself admin permissions on a random server your bot is in, you will most likely fail because server owners are not that dumb.

honest vessel
#

then bot will be able to give it

#

n check heirarchy

#

but cant give u higher perms than it has or same

#

needs lower

#

solution is make bot owner

slate swan
#

No.

honest vessel
#

no server

#

roles

slate swan
#

As they said, they can't check it.

#

It's against Discord's developer policy. Can get your bot and your account terminated.

honest vessel
#

oh he try hack em

#

bummer

#

thanks for waste our time @slate swan

#

@slate swan reporthim to modmail bbl

slate swan
#

No?

honest vessel
#

whatever

slate swan
#

The only thing moderators can do is ask them to stop asking help about this and stating that it's against the developers policy. I doubt they will get any type of punishment as it's a small troll people often want to do to their friends.

velvet tinsel
#

?

#

whatyert

#

Just remove it manually

#

just remove it manually jam_cavedude

#

If you have admin

#

why not

#

ok

stray thistle
#

Are you the server owner ?

#

i mean the server in which you are trying to remove your role

#
@commands.has_permissions(manage_guild=True)
async def removerole(ctx, member:discord.Member, role:discord.Role):
  await member.remove_roles(role)```
#

try this maybe

#

Ah alright

#

no problem

slate swan
#

Just started discord.py for few minutes, got a problem here

#

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

intents = discord.Intents().all()
client = discord.Client()
client = commands.Bot(command_prefix = '_', intents = intents)

@client.event
async def on_ready():
print("The bot is on and ready!")
await client.change_presence(status = discord.Status.idle, activity = discord.Game('Version Alpha 0.0.1'))

@client.command()
async def hello(ctx):
await ctx.send("HELLO SUPERIDOL!!")

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

#

Remove the 5th line

#

Either define Client or Bot

#

So remove the line with Client

#

if I remove the 5th line the on_ready function will still work right?

#

Then name your variable bot and not client

#

And replace all client usage to bot, then you should be good.

#

including the old 6th line?

#

Just remove the line where you used discord.Client

#

did

#

And replace all client usages to bot.

#
import discord
from discord.ext import commands

intents = discord.Intents().all()
bot = commands.Bot(command_prefix = '_', intents = intents)

@bot.event
async def on_ready():
  print("The bot is on and ready!")
  await bot.change_presence(status = discord.Status.idle, activity = discord.Game('Version Alpha 0.0.1'))

@bot.command()
async def hello(ctx):
  await ctx.send("HELLO SUPERIDOL!!")

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

yep

#

Then commands won't work because you've overwritten the on_message event

#

I will add on_message

#

So add

await bot.process_commands(message)

At the end of your on_message event

fluid spindle
#

Or you could use a listener

slate swan
#

You shouldn't change the status and activity in on_ready though, you should set it directly in the bot constructor.

#

Idk where is bot constructor that’s why I did it 😂

#

Instead of using the change_presence method, use the same parameters you used in that method and put them in your bot constructor, so commands.Bot(command_prefix="_", intents=intents, status=...).

#

Hello, I am trying to make my bot check if a message has been sent by someone in dms

#

after 60 seconds it cancels

#

how can i do this?

tacit token
#

hi guys, anybody help me? can i how to write a async def with space? example
async def mobile phone(ctx):

tacit token
#

and its work with mobile phone?

slate swan
#

uh

#

wait

#

you would have to do !mobile then set args as phone

#

async def mobile(ctx, type):
if type == "mobile":

tacit token
#

!mobile phone

slate swan
#

in there

slate swan
#

that would do !mobile mobile

#

i know how to do it w cogs but that isnt what ur doing

tacit token
#

example

!help commands

#

i try with buttons but never send embed message

slate swan
#

hello

#

anyone got any idea how to catch the asyncio.TimeoutError error?

fluid spindle
slate swan
slate swan
fluid spindle
#

Yeah, something like that... I haven't really used it

slate swan
#

pip install discord

fluid spindle
#

^

slate swan
#

do it in normal vsc

#

NORMAL CMD

#

not vsc 🧠 = 💀

#

mine always show as uninstalled in visual but dont in cmd

prime marten
#

Anyone know how to make a give_money command with sqlite3?

#

i just need the basics

slate swan
honest vessel
#

its basic

prime marten
#

ty

pliant hill
tacit token
honest vessel
#

@prime martenhttps://www.sqlitetutorial.net/sqlite-update/

slate swan
#

Cuz in the discord.py version 2.0 the avatar_url changed to avatar.url

tacit token
#

the code btw

slate swan
slate swan
tacit token
#

"The windows didnt find it"

slate swan
slate swan
#

Idk tbh

slate swan
slate swan
#

ctx.message.author could be just ctx.author

slate swan
slate swan
#

Still works doe

honest vessel
slate swan
#

why a var for the member.avatar_url just send it no need for the var?

dapper cobalt
# tacit token

You can make your code shorter and cleaner this way:

member = member or ctx.author
await ctx.send(member.avatar_url)
honest vessel
#

@slate swan didnt think of that it was an sql Q :p

slate swan
#

^

#

?

honest vessel
#

😄

slate swan
#

pardon?

honest vessel
#

why make var

slate swan
#

yeah

honest vessel
#

i myself used to overdo it

slate swan
honest vessel
#

cus before oop

dapper cobalt
honest vessel
#

oop is best that happend data

dapper cobalt
#

Check your dpy version using print(discord.__version__).

slate swan
#

Wait he's using nextcord library

slate swan
dapper cobalt
#

Ah, then it's member.avatar.url.

slate swan
dapper cobalt
slate swan
dapper cobalt
#

member.avatar.url

honest vessel
#

disnake feels like select "discord." replace "disnake."

tacit token
slate swan
tacit token
#

i go sleep gn ty

dapper cobalt
honest vessel
#

@slate swan haha

dapper cobalt
honest vessel
#

lol

dapper cobalt
#

Discord + Snake. Python is a snake.

slate swan
#

in a day i went from having no cogs and all my commands in a bot file to subclassing commands.Bot and having many cog filespithink

slate swan
honest vessel
#

theres a point in that one

dapper cobalt
#

Doing all that thinking while in a biology online class.

honest vessel
#

he ment a class

dapper cobalt
#
class Biology():
  ...
slate swan
honest vessel
dapper cobalt
slate swan
dapper cobalt
#

!ot I hate being this person.

unkempt canyonBOT
slate swan
#

lol

honest vessel
slate swan
#

cant make commands for a bot until i learn sql fully

slate swan
prime marten
#

in my economy bot im trying to put a cap on the total amount you can have in your bank (500 000) but am having some trouble with it
here is some of the code

        return await ctx.send("The maximum capacity for this bank account is :moneybag: 500 000")```

but it doesnt seem to work
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#

This has no error, but doesnt update, why

#
AttributeError: 'NoneType' object has no attribute 'id'```
#

what lib are you using?

#

forks of dpy do have the feature

#

make what?

#

the timeout feature of discord stops a user from interacting with the guild

#

dpy doesnt have timeouts

#

the timeout feature discord has added stops a user from interacting with the guild which dpy forks have

#

!d disnake.Member.timeout

unkempt canyonBOT
#

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

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

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

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

New in version 2.3.
slate swan
#

its a fork?

#

disnake is a api wrapper for the discord api?

#

its dpy but better

#

!pypi disnake

unkempt canyonBOT
slate swan
#

if you want to change to disnake all you have to do is change the word discord to disnake and your done

#

or you can import discord as disnake

#

or use find and replace in your ide

#

correct

#

yes

#

yw

#

well not really i havent checked for those types of apis

#

no problem

#

how do i make it welcome in multiple servers + channels

#

i think ive asked once before but never did it

#

pip install it

#

pip install disnake

#

replit being replit ig

#

i dont think it is

slim ibex
slate swan
slate swan
#

im not sure it is

slim ibex
#

it is if you have a database I’m pretty sure

#

I have never tried it before though

slate swan
slim ibex
#

yeah that’s what I’m saying

slate swan
#

yeah

slim ibex
#

I mean in my database

#

I have a guilds table where there is the guild id and a bunch of config info that includes the welcome channel ID

slate swan
slim ibex
#

Maybe with my bot I could say for it to send the set welcome message to the welcome channel associated with each guild

slate swan
#

because yes you can get the guild id but when will it know where to send the msg

slim ibex
#

but I wouldn’t want to know if a new user joins in a totally other server

slate swan
#

idk how to do databases tbh

slim ibex
#

Is it possible to use GraphQL with discord bots? That would be cool

slate swan
#

instead of just my server

slim ibex
#

so basically if a user joins in another server, you want every server that has the bot to know that?

#

it isn’t installed most likely

slate swan
slim ibex
#

If you are using VSCode, prolly just reload the window

slate swan
slim ibex
#

true lmfao

#

use VSCode or pycharm

slate swan
#

same

slim ibex
#

idk why people use in browser code editors

#

oh

slate swan
#

ig edit the code in vsc

slate swan
#

and run it in replit

#

so when someone joins the server it will welcome them

#

and if another one joins in the diff server it will welcome them in the server they join

#

not like where it sends it all into one server

#

yeah im not sure how it would know which guild the member joined in

#

using guild id

slim ibex
#

ahh I see

slate swan
#

how it does normally with just one

#

because a member joins right but how would the bot know which guild the member joined in?

slim ibex
#

I was confused on the question, my dusky

#

fault*

#

Well in this case, I would probably implement a database

#

From personal experience, putting multiple ids in to those get_guild and get_channel functions doesn’t work

slate swan
slim ibex
#

it’s simple

slate swan
slate swan
#

should be the same idk.

#

its obv possible mee6 does it etc other bots

slate swan
#

yeah

#

and you got the channel so it will only send a msg to that channel if its that guild

slim ibex
slate swan
slim ibex
#
@Cog.listener()
    async def on_member_join(self, member):
        result = db.record("SELECT welcomeChannel FROM guilds WHERE GuildID = ?", member.guild.id)
        if result is None:
            return
        else:
            result1 = db.record("SELECT welcomeMSG FROM guilds WHERE GuildID = ?", member.guild.id)
            
            members = len(member.guild.members)
            mention = member.mention
            user = member.name
            guild = member.guild

            wEmbed = Embed(description=str(result1[0]).format(members=members, mention=mention, user=user, guild=guild), timestamp=nextcord.utils.utcnow(), color=0x1c3fa8)
            wEmbed.set_author(icon_url=member.avatar.url, name=f"{member.name}#{member.discriminator}")
            wEmbed.set_thumbnail(url=member.avatar.url)
            wEmbed.set_footer(text=f"Guild: {member.guild}")

            try:
                channel = self.bot.get_channel(int(result[0]))
                await channel.send(embed=wEmbed)
            except TypeError:
                pass

#

This is my listener for the member join

slate swan
#

oh

slate swan
#

jee

slim ibex
#

you grab the guild id of the member guild and send it to the welcome channel of the guild

#

no, I import just Cog

#

from nextcord.ext.commands import Cog

slim ibex
#

that means I don’t have to put commands

slate swan
slate swan
slim ibex
#

It won’t work for you

slate swan
slim ibex
#

I have a db utility file that handles database stuff

#

which you don’t have

slate swan
slate swan
slim ibex
#

try str(user.status).title()

slate swan
#
import discord
from keep_alive import *
from config import TOKEN
from discord.ext import commands

intents = discord.Intents().all()
bot = commands.Bot(command_prefix = '_', intents = intents)

@bot.event
async def on_ready():
  print("The bot is on and ready!")
  await bot.change_presence(status = discord.Status.idle, activity = discord.Game('Version Alpha 0.0.1'))

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


@bot.command()
async def hello(ctx):
  await ctx.send("HELLO SUPERIDOL!!")
  
keep_alive()
bot.run(TOKEN)
cold sonnet
#

repl

unkempt canyonBOT
#

Hey @slate swan!

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

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

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

https://paste.pythondiscord.com

slate swan
cold sonnet
#

you got presence intents?

slate swan
#

and why on msg if your not sending anything

cold sonnet
#

@slate swan

slate swan
#

Wait

#

I have problem with keep alive

#

but how can I send it

#

from paste python discord

cold sonnet
#

can you show us some code?

slate swan
cold sonnet
slate swan
#
from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def main():
  return "Your bot is alive!"

def run():
    app.run(host="0.0.0.0", port=8080)

def keep_alive():
    server = Thread(target=run)
    server.start()
#

keep_alive.py

cold sonnet
#

and that is not discord bots anymore

slate swan
#

what is wrong with traceback

cold sonnet
#

oh it says too many requests @slate swan

cold sonnet
#

can you show code?

slate swan
#

someone said change it in bot constructor but idk where is it

cold sonnet
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

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

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

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

kk

cold sonnet
#

put activity and status here

slate swan
#

@slate swan are you the one that doesnt use json

cold sonnet
#

noone uses json

slate swan
#

what was the other thing other than json i forgot

#

cuz im using config.json to run the token

cold sonnet
#

databases

#

oh

slate swan
#

yeah

cold sonnet
#

environment variables

slate swan
#

oh i remember

#

.sql

#

oh

#

wait cant do that for running the token

slate swan
#

yea nvm lmao

cold sonnet
#

huh

#

string.title()?

#

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

whats the kwarg to change the bots status in the bot constructor

#

status?

cold sonnet
#

yes

slate swan
#

ah alr lol

cold sonnet
#

lmao

#

if he's got all the intents

#

how come status returns offline

slate swan
#

seems sus to me

cold sonnet
#

once a guy came here with the same issue

#

and it only returned offline because he was invisible

#

lmao

#

but BÖZ is smarter than that

#

BÖZ is online

slate swan
#

seems good but i recommend to make the code shorter

if member is None:
        member = ctx.author

from that to

member = member or ctx.author
slate swan
#

and you can set all those fields in the obj lol

#

that embed is killing me

cold sonnet
#

is the bot checkin you?

#

damn

pliant gulch
slate swan
cold sonnet
#

well send member.status only

pliant gulch
#

Because there is no field kwarg to the embed constructor

#

You must set it through add_field

slate swan
#
embed = discord.Embed().set_image()

i ment thispithink

cold sonnet
#

that looks better

slate swan
#

yah

cold sonnet
kindred drum
#

yo TypeError: __init__() missing 1 required positional argument: 'verification' anyone know why im getting this error? I think its cause of this ```py
class SomeCommands(commands.Cog):

def __init__(self, bot: commands.Bot, verification):
    self.bot = bot
    self.verification = verification 
code...

bot.add_cog(SomeCommands(bot))```

unkempt canyonBOT
#

discord/embeds.py lines 177 to 187

def __init__(
    self,
    *,
    colour: Union[int, Colour, _EmptyEmbed] = EmptyEmbed,
    color: Union[int, Colour, _EmptyEmbed] = EmptyEmbed,
    title: MaybeEmpty[Any] = EmptyEmbed,
    type: EmbedType = 'rich',
    url: MaybeEmpty[Any] = EmptyEmbed,
    description: MaybeEmpty[Any] = EmptyEmbed,
    timestamp: datetime.datetime = None,
):```
cold sonnet
#

show your intents BÖZ

kindred drum
#

they shouldn't matter

cold sonnet
kindred drum
#

i think its cause of verification not being like cogged or something

cold sonnet
#

huh

slate swan
cold sonnet
#

you are not BÖZ

cold sonnet
#

now I'm harassing you until your error is fixed

#

mindset

slate swan
#

your missing them

cold sonnet
#

well there's no presence intent

#

intents.presence

slate swan
cold sonnet
#

or

#

intents = discord.Intents.all()

slate swan
cold sonnet
#

you lied to me

slate swan
#

bot = commands.Bot(command_prefix= get_prefix, help_command=None, case_insensitive=True, intents=discord.Intents.all())

cold sonnet
#

and slap the checkbox in the dev portal aswell

slate swan
#

didnt help much but yw

cold sonnet
#

:thumbsup_tone1:

slate swan
cold sonnet
#

well that's not enough

#

:PeepoCry~0:

#

my emojis are not working

slate swan
#

thats like having shirts in a closet but not putting any on lol

cold sonnet
#

I can't use the sad crying one

#

only this peepocry

#

huh

slate swan
#

lol

cold sonnet
#

we're getting off topic

#

but there's noone asking for help

#

what else would we do

slate swan
cold sonnet
#

hey @slate swan, how's your discord bot doing?

slate swan
#

should be learning sql

cold sonnet
#

I should learn asyncio

slate swan
cold sonnet
#

"we use async def and await on async coroutine stuff cuz it's like that"

slate swan
cold sonnet
#

and idk what's yield

slate swan
cold sonnet
#

when I got to paginators and I needed an async generator

#

because why not

cold sonnet
#

I got stuck

slate swan
#

happens

cold sonnet
#

yep

slate swan
#

nice

cold sonnet
#

:thumbsup_tone5:

slate swan
#

you called it lol

cold sonnet
#

ducky_australia now I'm gonna go

#

cya

sage otter
cold sonnet
#

fr

sage otter
#

it’s almost the same as return but the function continues. While return just exits the function completely.

#

!yield

cold sonnet
#

uh

#

hm

sage otter
#

Is that what you meant?

cold sonnet
#

so you say

sage otter
#

I honestly don’t have too good of an understanding on it. Haven’t found a use for it once.

#

But that’s what I got from reading peoples stuff.

cold sonnet
#

uh meh

#

idk how to use it in code

cold sonnet
#

okay

#

mmhmm
now I just see why I didn't understand it

sullen glacier
#

anyone using replit here?

worldly bane
sullen glacier
# worldly bane Y

i keep getting "Replit: Package Operation Failed" when supposedly it's supposed to "work", is replit weird sometimes?

patent lark
jovial dock
#

bots are kewl

worldly bane
hard trail
#

I need a bit help with some code. So I'm creating a ticket bot basically and everything is working fine but I just need it to go into a specific category I have created. That's the part I need help with.

worldly bane
#

try this

#

not that sure tho

hard trail
#
@bot.command()
async def ticket(ctx):
  guild = ctx.guild
  overwrites = {
    guild.default_role: discord.PermissionOverwrite(read_messages=False),
    guild.me: discord.PermissionOverwrite(read_messages=True)
}
  await guild.create_text_channel(f'{ctx.author}', overwrites=overwrites)```
worldly bane
# hard trail Didn't work

an example

@client.command()
async def create(s, arg: str):
   guild = s.message.guild
   cat = discord.utils.get(s.guild.categories, name="FORUM")
   channel = await guild.create_text_channel(arg, category=cat)

hope this works for you

hard trail
worldly bane
hard trail
bronze axle
#

Hey

#

How to i send messages which is only visible to a single person? Using discord.py or any other discord libraries

worldly bane
#

if you have dpy 2.0

#

like buttons, dropdown

bronze axle
#

How do I get dpy 2.0

#

Any tutorials pls

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

@bronze axle

bronze axle
#

Thx

#

Any tutorials on the library though

worldly bane
#

just looked at github

cyan sleet
#

hai, uhm, i'm having an error here but idk how to fix this-

worldly bane
sick birch
#

Also it's most likely that if statement

#

not indented properly

slate swan
slate swan
#

will this work?

cyan sleet
#
@client.command()
@commands.has_permissions(ban_members = True)
@commands.cooldown(1, 1234567890, commands.BucketType.user)
async def test(ctx: commands.Context):
  if (not ctx. author.guild_permissions.ban_members):
    await ctx.reply('You need to have a `moddie` role ro have an access in this command.')
    return
  else:
    pc_hibis = (1000)
    random_amount = random.randint(99, 100)

  await economy.add_money(ctx.message.author.id, "wallet", pc_hibis)
  await economy.add_money(ctx.message.author.id, "bank", random_amount)

  embed = discord.Embed(title="Here's your weekly paycheck moddie!", colour=discord.Color.from_rgb(47, 49, 54))
  embed.add_field(name=f"Hey Moddie!", value=f"""**A lil message for you!**\nThank you for being a great moddie here in Junhan Bot!\nWe appreciate your efforts! """)
  embed.add_field(name=f"Weekly Paycheck!", value=f"""Items you got:\n`{pc_hibis}` `🌺` | `{random_amount}` `💎` """)
  await ctx.reply(embed = embed)
``` it works now but the message `You need to have a moddie role ro have an access in this command` doesn't
gloomy cape
#

i am making a bot but i want it to be online forever but it sometimes goes offline when i close my laptop i am using repl.it

slate swan
gloomy cape
#

o

slate swan
#

it saves power

gloomy cape
#

so wut should i use for my code

#

vs?

slate swan
#

and why are you trying to subclass client? lol

slate swan
#

iirc its

class smt(discord.Client)

just use the bot framework tbh

woven ingot
#

How do i fix this arent modules just imported automatically by adding a line of code to cript?

#

2022-01-05T02:41:00.914334+00:00 app[worker.1]: from discord_components import Button, Select, SelectOption, ComponentsBot
2022-01-05T02:41:00.914383+00:00 app[worker.1]: ModuleNotFoundError: No module named 'discord_components'

#

from discord_components import Button, Select, SelectOption, ComponentsBot

slate swan
#

they are

#

but you need to install them

slate swan
#

if you want to host the bot

#

and discord_components is a 2.7+ script i think

#

why even use third party libs when you have forks tbh

slate swan
#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

slate swan
#

should be 4 spaces per level or indentation

woven ingot
woven ingot
slate swan
woven ingot
slate swan
#

you can use other libs just gotta list them in the script and install them

woven ingot
lime trench
#
            for server in self.client.guilds:
                BotCache.servers[server.id] = document```

 everytime it inserts to the dict, it stays on the same guild_id
anyone know a fix?
https://cdn.discordapp.com/attachments/381965515721146390/928122996630106123/unknown.png
slate swan
tough lance
lime trench
#

pymongo

#

its not mongo issue, its not going threw every server id in it

lucid gazelle
#

how to have this in our cooldown?

shadow wraith
lost vine
#

I'm doing the roleplay category for my bot but when I did the if statement for the case when no one is mentioned but the bot didn't respond. Here's my code:

            color = discord.Color.random())
            embed.set_image(url = hug2)
            print(embed)
            await ctx.send(embed = embed)```
shadow wraith
#

how do i set perms for channels

#

in the bot

lost vine
#

For example:

async def lockdown(ctx):
    await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)```
shadow wraith
#

uhh how do i do it with other channels

slate swan
#

how can i get a users custom status?

slate swan
unkempt canyonBOT
#

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

Note

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

Note

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

how do i get a discord image attachment into a numpy array?

shadow wraith
#

does anyone know how to set channel perms and how to put the name of the channel to set perms to

shadow wraith
lucid gazelle
#

how to have this in cooldown?

mortal sinew
#

i think

slate swan
#
    @commands.command(name="Status")
    async def status(self,ctx, m: discord.Member):
        acts = m.activities
        act = [i for i in acts if isinstance(i, discord.CustomActivity)]
        print(acts)
        print(act)
        if act:
            act = act[0]
        else:
            return await ctx.send(f"No Custom Activity for {m.name}")
        text = act.name
        if text:
            await ctx.send(f'Custom Status of {m.name}: **{text}**')
        else:
            return await ctx.send("No text in custom status")```
shadow wraith
#

!d discord.Member.activities

unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.

shadow wraith
#

oh sh*t that exists.

slate swan
#

don't need to do what part

shadow wraith
slate swan
slate swan
#

And use it in set_permissions

#

Or channel.edit

pliant gulch
#

Otherwise you aren't given presence/status data

slate swan
#

aiosqlite if local , motor if noSQL , asyncpg if you want to make a db server ( my option)

#

AttributeError: 'NoneType' object has no attribute 'name'

#
    @commands.command(name="Status")
    async def status(self,ctx):
        await ctx.send(ctx.author.activity.name)```
slate swan
shadow wraith
#

oh yeah and make sure the membre has an activity

slate swan
#

discord.Intents.all() ?

shadow wraith
#

what other obj can a @commands.has_any_role() take

slate swan
#

yea , motor is mongodb but asynchronous
asyncpg is postregsql

shadow wraith
#

because i wanna put a nonetype object in there ;plead

slate swan
shadow wraith
#

that's it

pliant gulch
#

What else could you logically give it anyways other than those two??

shadow wraith
#

i thought what about an ignorant nonetype object

pliant gulch
#

At that point you'd omit the decorator

slate swan
#

Like , no roles?

#

technically not possible on discord, every member object has a role

shadow wraith
#

yea but you could change the object to something else with a cmd

pliant gulch
#

Don't think that's possible with how decorators work

#

🤔

shadow wraith
#

and there's no decorator for adding a command that only 1-etc... guilds can use

slate swan
shadow wraith
#

like exclusive commands for a guild

pliant gulch
#

Also roles are optional

#

Not every member has to have roles

shadow wraith
slate swan
#

yes, me

shadow wraith
#

i think the member activity doesn't mean their status?

pliant gulch
#

Where bot is your client

slate swan
shadow wraith
#

f**k

shadow wraith
#

yes ik they did i think

slate swan
#

And it means the activity which appears on the profile , which includes both Activity and Custom status

pliant gulch
#

You can remove that role lmao

slate swan
pliant gulch
#

Yes...

slate swan
#

How do I do that?
Member.remove_roles(guild.default_role)?

pliant gulch
#

If you await it yes

slate swan
#

Lemme checkkkk

lucid gazelle
worldly bane
slate swan
pliant gulch
slate swan
#

.jsk py ```py
await _ctx.author.remove_roles(_ctx.guild.default_role)

pliant gulch
slate swan
#

i just tried adding it and it crashes my bot now

#

intents = discord.Intents().all()
bot = commands.Bot(command_prefix=get_prefix(), description=desc,case_insensitive=True, intents=intents)
bot.remove_command('help')

slate swan
slate swan
#

nvm i fixed it

#

and remove the () after get_prefix

#

ok

pliant gulch
#

It's a classmethod, you can call it from an instance tho

#

Atleast I think you can? I'll check again lmao

lucid gazelle
#

like try again (minutes)

lucid gazelle
#

okayyy

#

@worldly bane

brave ravine
#
async def sendbikedata(ctx, date: str):
    open(Log)
    df = pd.read_excel(Log, index_col=None)
    if (date == None or date == ""):```I am trying to print something when there is no date entered, but i keep getting a  ``raise MissingRequiredArgument(param)`` error
pliant gulch
#

Are you trying to make date an optional argument?

brave ravine
#

yes

pliant gulch
#

You have to give date a default value, E.g None, ""

brave ravine
#

thank you

worldly bane
lucid gazelle
#

command for?