#discord-bots

1 messages · Page 850 of 1

slate swan
#

^

south brook
#

How is the id 'wrong'

cold sonnet
#

underscore?

#

get_channel

slate swan
#

oh yeah snake_casing

south brook
#

?

slate swan
#

didnt see that

south brook
#

wdym?

slate swan
#

you need a _ and not a space

#

its basic py

south brook
#

i have that

slate swan
#

no you dont

south brook
#

you dont see it in the ss

cold sonnet
#

I'm starting to think he's not trolling

slate swan
south brook
#

look, this one is bigger

slate swan
#

the id is wrong

#

since it returns None

south brook
#

Now it returns this

#

so it has an channel

#

and it has the right name

#

@slate swan

#

ow sorry

cold sonnet
#

we got no code

south brook
#

you have

cold sonnet
#

please send it again then

south brook
#

it isnt a nuker

#

i swear

slate swan
south brook
#

?

#

ye true

#

i added the right id

cold sonnet
#

imagine ghostpinging

slate swan
#

i got pinged

weary birch
#

hey i got question how can i make smth like this? did research but its no help

cold sonnet
#

which part do you not know of that?

weary birch
#

everyone of that

#

mostly the text

#

how i add it, other i know iguess

cold sonnet
#

just make a title and description with that text

south brook
cold sonnet
#

add fields

#

!d discord.Embed.add_field

unkempt canyonBOT
#

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

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

the name is a mention there, and values are just texts

weary birch
#

8+

#

ok*

cold sonnet
#

set the thumbnail with

#

!d discord.Embed.set_thumbnail

unkempt canyonBOT
#

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

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

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

takes a url

weary birch
#

thanks

quaint epoch
#

read the traceback

#

and this doesn't seem like the whole error

#

what's the following exception?

#

okay

#

it says that there is no key called 1 in seq

manic wing
#

nitrogen | legit

quaint epoch
#

so, you tried to pick a key from this json { "hey": 1, "bye": 1 }?

#

send a more detailed json structure, what part specifically you want to take

#

@slate swan , do you want to pick a random key, or random value from this? { "hey": 1, "bye": 1 }

#

or are the keys member_ids?

flat solstice
#

A few hikari questions bc I've had a look at the docs but I found the layout a bit confusing

  • does hikari have something similar to discord.abc? if so what is it and if not what would be hikari's equivalent
  • hikari has a guildtextchannel, is this a sub thing of hikari.channel(i.e. hikari.channel.guildtextchannel) is is it just a subset of hikari (i.e. hikari.guildtextchannel)
  • hikari doesn't have something like discord.ext.commands so is it just hikari.commands? Looking for hikari's equivalentof Bot, AutoShardedBot and Context
  • is discord.errors just hikari.errors in hikari
  • is discord.role just hikari.role in hikari
  • whats the thing to import for buttonstyle, creation of a action row, creation of a button, creation of a select option and the waiting for components in hikari
quaint epoch
#

so, from json { "hey": 1, "bye": 1 } you want to take either hey or bye?

cold sonnet
#

"hey" and "bye" are keys here

#

the ones are values

#

so in order to be able to random.choice, you might wanna make a list out of the keys

quaint epoch
#

so then why are you using a dict there? use smth like json { "944912530298527765": ("hey", "bye") }

cold sonnet
#

so use .keys() on this object, which returns a list of these

quaint epoch
#

make a tuple?

#

or pull data from it?

slate swan
#

pro

#

@cold sonnet cof cof

cold sonnet
#

!ot

unkempt canyonBOT
slate swan
cold sonnet
#

try it

quaint epoch
#

random_key = random.choice(guilds_dict[str(ctx.guild.id)].keys()) should work idk

slate swan
cold sonnet
quaint epoch
cold sonnet
#

ig

#

I did not mean to send no iq

#

question mark

quaint epoch
#

but srsly switch to a list or tuple

#

don't use dict keys lol

potent sundial
#

Hello I need help with my bot.

#

I do not know where to place the token.

slate swan
#

can anyone help me with my issue pls?

slate swan
# potent sundial I do not know where to place the token.

import discord

from discord.ext import commands

import random

import asyncio

TOKEN = 'ur token'

client = commands.Bot(command_prefix = '$')
client.remove_command('help') #removes original help command from python file so u can make a costume help command
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))

#ur code commands goes here

@client.event run(TOKE)

potent sundial
#

Ok

slate swan
#

put ur code and at the end put thi

#

@client.event run(TOKEN)

potent sundial
#

Ok

#

@slate swan Do I need to put “”

slate swan
#

yes

potent sundial
#

For token.

#

Ok.

slate swan
#

for the TOKEN = ' '

#

but at the end no just (TOKEN)

potent sundial
#

Ok.

#

It’s wrong.

slate swan
#

no lmao

#

whats wrong

potent sundial
#

Syntax error.

slate swan
#

wrong^

potent sundial
#

Bot.run(“token”)

slate swan
#

the run is at the end

vestal mist
#
@client.listen("on_message")
@commands.has_permissions(kick_members=True, ban_members=True, manage_roles=True)
async def ban_listener (ctx, member = discord.Member, reason=None):

  if msg.startswith('Ban'):

    # if member.guild_permissions.administrator():
    #   await ctx.channel.send('Err: User is administrator')
    
      print(member)
      print(ctx)

    # else:
      if reason is None:
        await member.send(f'Hello {member.name} , you have been banned from {await discord.guild.get_channel()}. There was no specified reason for this ban.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} for no specified reason.')
        await member.ban()

      else:
        await member.send(f'Hello {member.name} , you have been banned from {await discord.guild.get_channel()}. The reason specified for this was {reason}.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} the reason specified was {reason}.')
        await member.ban()

here da code

slate swan
#

after all the code is done

potent sundial
slate swan
#

maybe thats what is cuasing my issue

potent sundial
#

Error still.

#

I am using replit.

slate swan
#

but the bot is still working with what i said

full lily
vestal mist
slate swan
#

why not

potent sundial
#

I fixed code.

slate swan
#

could u give a bit of a help in sum

full lily
vestal mist
#

new errors lol

potent sundial
#

Ok bot is online.

#

Imma add commands.

#

But I need the basic respond command.

#

Ok.

#

No.

#

@slate swan Check dm

slate swan
vestal mist
slate swan
lyric tusk
#

Error : ImportError: cannot import name 'Enum' from 'discord' (unknown location)

lyric tusk
#

i can't run a extension

final iron
#

A cog or an actual extension?

lyric tusk
#

a cog

south jetty
#

How can I make roblox discord commands

lyric tusk
neat tartan
slate swan
neat tartan
#

I dont even think enum is a discord import 🤔

slate swan
neat tartan
#

Ah, i thought it was part of the numpy or base lib of python

unkempt canyonBOT
#

discord/enums.py lines 165 to 171

class Enum(metaclass=EnumMeta):
    @classmethod
    def try_value(cls, value):
        try:
            return cls._enum_value_map_[value]
        except (KeyError, TypeError):
            return value```
slate swan
#

tho there's no reason someone would import it

vestal mist
#

I should explain to everybody else

full lily
#

send the code please and the traceback

vestal mist
#
@client.listen("on_message")
@commands.has_permissions(kick_members=True, ban_members=True, manage_roles=True)
async def ban_listener (ctx, member = discord.Member, reason=None):

  if msg.startswith('Ban'):

    # if member.guild_permissions.administrator():
    #   await ctx.channel.send('Err: User is administrator')
    
      print(member)
      print(ctx)
      print(ctx.guild.name())

    # else:
      if reason is None:
        await member.send(f'Hello, you have been banned from {ctx.guild.name}. There was no specified reason for this ban.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} for no specified reason.')
        await member.ban()

      else:
        await member.send(f'Hello {member.name} , you have been banned from {ctx.guild.name()}. The reason specified for this was {reason}.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} the reason specified was {reason}.')
        await member.ban()
#

with line 104

#

which is the print, though it is the same with every line

buoyant quail
#

name()

full lily
#

I'm confused

buoyant quail
#

why you call it with ()

full lily
#

why are you doing @client.listen("on_message")

buoyant quail
#

ye, it's also a question

full lily
#

rather than a command

vestal mist
#

good point

#

also client isnt client

#

client is bot in this case

buoyant quail
#

about error you need to delete brackets after ctx.guild.name

slate swan
#

there's no way a Context would pop up in an event

potent sundial
#

Idk how I know that.

vestal mist
#

so how am I supposed to listen with a command? (sorry if Im stupid Im new to quite a lot of this)

potent sundial
#

;-;

full lily
#

as long as you use the right decorator, discord.py will take care of that for you

potent sundial
#

I want to make a ban command but I am afraid it will mess up the whole code lol.

haughty quartz
#

best library for slash commands?

vestal mist
#

so "on_message"?

buoyant quail
#

....

vestal mist
#

I guess not

buoyant quail
slate swan
alpine furnace
slate swan
#

there's no "best" library

haughty quartz
alpine furnace
#

Yes

#

Drop in replacement for dpy

haughty quartz
#

can u give me the docs as its kinda confusing with there being v1 and v2

potent sundial
#

I have a bot that is written in Node.js it has some errors but the bot is abandon.

slate swan
#

it's not a replacement of discord.py , is just a fork like 10+ others

potent sundial
#

Ok.

haughty quartz
haughty quartz
#

i currently use disnake

slate swan
#

discord py was developed by Danny as the sole core maintainer

potent sundial
slate swan
haughty quartz
slate swan
#

It always did

haughty quartz
#

huh im confused

slate swan
haughty quartz
#

damn

#

thats awesome

slate swan
#

it's not like only pycord and dislash can have slash commands

buoyant quail
#

xd

slate swan
#

And fyi, Disnake is developed by the developer of dislash.py

haughty quartz
#

thanks !

slate swan
#

So if you every used dislash you can just shift it easily to disnake

#

The syntax is same

haughty quartz
#

and i dont need to change to another library

supple crescent
#

here is my current channel creator. I want it to also ping the person that created the chat inside that new chat, is that possible?


@bot.command(name="contact")
async def contact(ctx):
    guild = ctx.guild
    admin_role =  guild.get_role(945325312533729311)
    
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        admin_role: discord.PermissionOverwrite(view_channel=True),
        guild.me: discord.PermissionOverwrite(view_channel=True)
    }

    await guild.create_text_channel("private-channel", overwrites=overwrites)
haughty quartz
#

thats a huge advantage lmao

buoyant quail
#

channel = await guild.create_text_channel("private-channel", overwrites=overwrites)

supple crescent
buoyant quail
#

ctx.author is author of the command

supple crescent
#

ohhh

vestal mist
#

Im still really confused

buoyant quail
#

first create than send

supple crescent
#

@buoyant quail like this?

@bot.command(name="contact")
async def contact(ctx):
    guild = ctx.guild
    admin_role =  guild.get_role(945325312533729311)
    
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        admin_role: discord.PermissionOverwrite(view_channel=True),
        guild.me: discord.PermissionOverwrite(view_channel=True)
    }
await channel.send(ctx.author.mention)
channel = await guild.create_text_channel("private-channel", overwrites=overwrites)
buoyant quail
#

channel = await guild.create_text_channel("private-channel", overwrites=overwrites)
await channel.send(ctx.author.mention)

supple crescent
#

gotcha

supple crescent
# buoyant quail channel = await guild.create_text_channel("private-channel", overwrites=overwrit...

so like this?

bot.command(name="contact")
async def contact(ctx):
    guild = ctx.guild
    admin_role =  guild.get_role(945325312533729311)
    
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        admin_role: discord.PermissionOverwrite(view_channel=True),
        guild.me: discord.PermissionOverwrite(view_channel=True)
    }

channel = await guild.create_text_channel("private-channel", overwrites=overwrites)  
await channel.send(ctx.author.mention)
#

wait no isidle the loop

buoyant quail
#

ye. but remember about indentation

vestal mist
#

please help, I dont know what you mean by the correct decorator and the docs dont really explain it to me very well, help?

@client.command()
@commands.has_permissions(kick_members=True, ban_members=True, manage_roles=True)
async def ban_listener (ctx, member = discord.Member, reason=None):

  if msg.startswith('Ban'):

    # if member.guild_permissions.administrator():
    #   await ctx.channel.send('Err: User is administrator')
    
      print(member)
      print(ctx)
      print(ctx.guild.name())

    # else:
      if reason is None:
        await member.send(f'Hello, you have been banned from {ctx.guild.name}. There was no specified reason for this ban.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} for no specified reason.')
        await member.ban()

      else:
        await member.send(f'Hello {member.name} , you have been banned from {ctx.guild.name()}. The reason specified for this was {reason}.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} the reason specified was {reason}.')
        await member.ban()
buoyant quail
#

you don't need check message. command will be used like the name of function

#

async def ban_listener mean that you call it like !ban_listener

vestal mist
#

ohhhhhhhhhhhhh

#

tysm

potent sundial
#

@vestal mist Can I have a kick code.

vestal mist
#

with the command prefix being ?, it should be ?ban, right? I am still not getting anything

unkempt canyonBOT
#

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

Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.kick "discord.Guild.kick").
vestal mist
#

( I changed it to ban)

lyric tusk
vestal mist
#
@client.command()
@commands.has_permissions(kick_members=True, ban_members=True, manage_roles=True)
async def ban (ctx, member = discord.Member, reason=None):
    
      print(member)
      print(ctx)
      print(ctx.guild.name)

      if reason is None:
        await member.send(f'Hello, you have been banned from {await ctx.guild.name}. There was no specified reason for this ban.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} for no specified reason.')
        await member.ban()

      else:
        await member.send(f'Hello {member.name} , you have been banned from {ctx.guild.name()}. The reason specified for this was {reason}.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} the reason specified was {reason}.')
        await member.ban()
slate swan
#
@bot.event
async def on_message(message):
    with open("banwords.json") as f:
        banwords = json.load(f)
        
    with open("banwords.json", "w") as f:
        json.dump(banwords , f)
        
    if {i.lower().translate(str.maketrans('','', string.punctuation)) for i in message.content.split(' ')}\
    .intersection(set(json.load(open('banwords.json')))) != set():
        await message.channel.send(f'{message.author.mention} по губам отшлепать??')
        await message.delete()
        await bot.process_commands(message) 

banwords.json

banwords = ["тупой", "дуб"]

erorr

await coro(*args, **kwargs)
2022-02-22T20:51:10.865809+00:00 app[worker.1]:   File "/app/main.py", line 51, in on_message
2022-02-22T20:51:10.865809+00:00 app[worker.1]:     banwords = json.load(f)
2022-02-22T20:51:10.865824+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/json/init.py", line 293, in load
2022-02-22T20:51:10.865824+00:00 app[worker.1]:     return loads(fp.read(),
2022-02-22T20:51:10.865838+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/json/init.py", line 346, in loads
2022-02-22T20:51:10.865839+00:00 app[worker.1]:     return _default_decoder.decode(s)
2022-02-22T20:51:10.865853+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 337, in decode
2022-02-22T20:51:10.865854+00:00 app[worker.1]:     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
2022-02-22T20:51:10.865867+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 355, in raw_decode
2022-02-22T20:51:10.865868+00:00 app[worker.1]:     raise JSONDecodeError("Expecting value", s, err.value) from None
2022-02-22T20:51:10.865894+00:00 app[worker.1]: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
#

Help me

unkempt canyonBOT
#

When using JSON, you might run into the following error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This error could have appeared because you just created the JSON file and there is nothing in it at the moment.

Whilst having empty data is no problem, the file itself may never be completely empty.

You most likely wanted to structure your JSON as a dictionary. To do this, edit your empty JSON file so that it instead contains {}.

Different data types are also supported. If you wish to read more on these, please refer to this article.

slow fog
slate swan
#

why do i get this error help Command raised an exception: AttributeError: 'generator' object has no attribute 'to_dict'

vestal mist
#

I dont think its being called as the print functions dont display anything

slate swan
vestal mist
#

@buoyant quail any ideas?

unkempt yacht
#

Is it possible to do it so that if you run a command in one server, it unbans in another

potent sundial
final iron
potent sundial
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., reason=None)

buoyant quail
slow fog
final iron
vestal mist
slate swan
#

what is happening

final iron
#

Nothing

unkempt yacht
buoyant quail
vestal mist
#

what

#

how

buoyant quail
#

<class 'discord.member.Member'>
<discord.ext.commands.context.Context object at 0x0000015D7FA81FD0>
Bot tester serv

#

and then errors

slate swan
#

well youre trying to print an obj

vestal mist
#

by doing ?ban ?

slate swan
buoyant quail
#

yes. !ban by me, but does not matter

unkempt canyonBOT
#

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

<class 'str'>
slate swan
#

same thing lol

final iron
vestal mist
buoyant quail
#

just work)

supple crescent
#
bot.command(name="order")
async def order(ctx):
    guild = ctx.guild
    admin_role =  guild.get_role(945325312533729311)
    
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        admin_role: discord.PermissionOverwrite(view_channel=True),
        guild.me: discord.PermissionOverwrite(view_channel=True)
    }

    channel = await guild.create_text_channel("private-channel", overwrites=overwrites)  
    await channel.send(ctx.author.mention)

CommandNotFound: Command "order" is not found. I AM STUPID

buoyant quail
final iron
#

You sure you didnt mean to type hint?

buoyant quail
supple crescent
slate swan
#

allot of flaws in that code

unkempt yacht
potent sundial
#

Does anyone know how to make a command where the bot changes your name like the !afk command.

slate swan
supple crescent
unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
slate swan
#

!d discord.Guild.unban

unkempt canyonBOT
#

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

Unbans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
buoyant quail
vestal mist
slate swan
#

its a decorator

supple crescent
#

bruh lamens turn pls

#

terms

slate swan
#

wut

final iron
vestal mist
#

no

final iron
potent sundial
slate swan
final iron
#

If you don't know what a decorator is you're not ready for discord.py

final iron
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.

supple crescent
final iron
slate swan
#

lol

potent sundial
buoyant quail
#

chat is moving fast :p

potent sundial
#

Not experienced in PY.

final iron
supple crescent
final iron
#

Decorators are used in python code all the time

slate swan
#

which sucks

supple crescent
final iron
#

Which is very bad

slate swan
#

so basic yet no one knows about it

potent sundial
vestal mist
#

do I need intents?

buoyant quail
final iron
slate swan
vestal mist
#

ok I have enabled intents and stuff, it is still not working

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

why do i get this error? Command raised an exception: AttributeError: 'generator' object has no attribute 'to_dict'

vestal mist
#
@client.command()
@commands.has_permissions(kick_members=True, ban_members=True, manage_roles=True)
async def ban (ctx, member = discord.Member, reason=None):
    
      print(member)
      print(ctx)
      print(ctx.guild.name)

      if reason is None:
        await member.send(f'Hello, you have been banned from {await ctx.guild.name}. There was no specified reason for this ban.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} for no specified reason.')
        await member.ban()

      else:
        await member.send(f'Hello {member.name} , you have been banned from {ctx.guild.name()}. The reason specified for this was {reason}.')
        await ctx.channel.send(f'user {member.name} has been banned by {ctx.author.name} the reason specified was {reason}.')
        await member.ban()
slate swan
south jetty
slate swan
#

cos that wat i found on docs

buoyant quail
vestal mist
#

I have no clue what Im doing ok

slate swan
vestal mist
#

my script is longer than 2000 characters

slate swan
#

ok?

#

use the pasting service

vestal mist
#

what is the pasting service

south jetty
#

can someone tell me an api to code roblox commands on discord

slate swan
slate swan
slate swan
south jetty
buoyant quail
#

Robloxpy for example

dull terrace
#

how do you feel about this caching mechanism 🤔

buoyant quail
#

lol don't u think someone knows

vestal mist
#

nobody answered :(

#

there is another script but it is really unimportant

maiden fable
#

Hmm

slate swan
dull terrace
#

just for organisation or?

slate swan
#

no

cold sonnet
#

what the heck is bob

slate swan
#

a class that has all the attrs

dull terrace
#

i use bob for user id

buoyant quail
#

xd

slate swan
#
from typing import Any

__all__ = ("Cache",)


class Cache:
    def __init__(self):
        self.cache: dict[Any, dict[Any, Any]] = {}

    
    def __dict__(self) -> dict[Any, Any]:
        return self.cache

    def __len__(self) -> int:
        return len(self.cache)

    def _save(self, key: Any, value: dict[Any, Any]) -> None:
        self.cache[key] = value

    def _get(self, key: int) -> None | dict[Any, Any]:
        try:
            return self.cache[key]
        except KeyError:
            return None

    @property
    def all_cache_items(self) -> None | dict[Any, Any]:
        return self.cache

    def _get_index(self, key: int, index: str) -> None | str:
        try:
            return self.cache[key][index0][index1]
        except KeyError:
            return None
unkempt yacht
#

what would the await ctx... be for the unban if you are unbanning

dull terrace
#

hmm okay thanks

unkempt yacht
#

where would i put the server ID

#

if im unbanning from another server

slate swan
pliant gulch
#

Also wouldn't it make sense to make the Key & Value generic types

pliant gulch
#

For type-safety

pliant gulch
# slate swan how

Because it always returns a dict, your default is an empty dict etc

#

It never returns None

slate swan
#

yeah ik i gotta fix that i think i did but i copypasted something old

unkempt yacht
#

so what would it be?

#

for the bot to unban the user

slate swan
vestal mist
pliant gulch
kindred drum
#

yo I got the most strange problem:
I have a command to remove all of a users roles (+strip)
When I use the command, it doesn't remove all the roles, only some and provides no error.
code: ```py
@commands.command(name="strip")
async def strip(self, ctx, member: discord.User):

    guild = bot.get_guild(915357451484790916)
    for i in range(0,len(Json_Items)): #It doesn't exist
            for x in Json_Items[i]:
                if int(x) == member.id:
                    member = await bot.fetch_user(x)
                    member_real = guild.get_member(member.id)
                     
                    print(Json_Items[i][x]['roles'])       
                    for c in Json_Items[i][x]['roles']:
                    
                        
                        

                        
                        role_remove = get(guild.roles, name=c)
                        print("removed role: "+c)
                  
                        await member_real.remove_roles(role_remove)
    await ctx.send("User roles striped")```

gif of whats happening:https://gyazo.com/cf5a57ca721daf9e248486e6d64c564d

slate swan
kindred drum
#

it only removes those roles, no more

#

the list of the users roles is printed above

pliant gulch
slate swan
unkempt yacht
pliant gulch
#

So then you could do ```py
cache = Cachestr, int
reveal_type(cache.root) # dict[str, int]

vestal mist
#

yeah, I dont get why it doesnt even mention anything, help?

slate swan
#
NOne
#

new type i see

pliant gulch
#

Yea but do you understand what I'm saying here

#

Making it generic is better than using Any

#

And ensures type safety

slate swan
slate swan
pliant gulch
#

Think of the word "generic"

pliant gulch
slate swan
kindred drum
#

I tried adding a 2 second timer on each role removal

pliant gulch
kindred drum
#

and it still doesn't remove all the roles

slate swan
kindred drum
#

i just odnt understand it

supple crescent
#

there is no error, its just not doing anything. what am i missing?

@client.event 
async def on_member_join(member):
     channel=client.get_channel(945789074663436318)
     emb=discord.Embed(title="NEW MEMBER",description=f"Thanks {member.mention} for joining!")
     await channel.send(embed=emb)
#

this is my fist try with embeds so idk if its right

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.

pliant gulch
slate swan
kindred drum
#

I used await asyncio.sleep(2)

slate swan
#

by arbitrary

unkempt yacht
pliant gulch
# slate swan by arbitrary

You should read up on it, if you're making your wrapper typehinted you should be typehinting correctly

slate swan
#

ill check it out as well

pliant gulch
unkempt yacht
#

What would the line of code be for the bot to unban a user with the given server ID?

#

I just need that one bit.

slate swan
#

!d discord.Guild.unban

unkempt canyonBOT
#

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

Unbans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
kindred drum
#

also it bypasses other things rate limit,s like it just goes until it can when adding roles (and goes after the rate limit), I don't get why its different for removing roles

unkempt yacht
#

await unban(user, *, reason=None)?

kindred drum
unkempt yacht
#

so where's the bit which unbans from the other server

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.
unkempt yacht
#

How, this is my code so far:

@commands.command(name="mainunban", aliases="mub")
@commands.has_guild_permissions(administrator=True)
async def mainunban(self, ctx, user: discord.User, reason:str=None):
        """Unbans the user from the main server."""
        main = 929308819526414387
        await unban (ctx, member: discord.User, reason=None)
        ube = discord.Embed(title=f'{member.name} was unbanned!, description='')
        ube.set_footer(name="Moderator ID:", value=f'{ctx.author})
        ube.set_thumbnail(url=ctx.guild.icon_url)
        ube.timestamp = datetime.datetime.utcnow()
        
        await ctx.send(embed=ube)```
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
buoyant quail
unkempt yacht
#

ok

kindred drum
#

what ya mean

unkempt yacht
#

ok

cold sonnet
#

huh

#

self.bot.get_guild

#

it is it

unkempt canyonBOT
#

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

Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") from an ID.

Note

Using this, you will **not** receive [`Guild.channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.channels "discord.Guild.channels"), [`Guild.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.members "discord.Guild.members"), [`Member.activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activity "discord.Member.activity") and [`Member.voice`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.voice "discord.Member.voice") per [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member").

Note

This method is an API call. For general usage, consider [`get_guild()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.get_guild "discord.Client.get_guild") instead.
cold sonnet
#

no

#

no reason api call

slate swan
#

!buttons

#

anyone know how to use buttons

cold sonnet
#

depends on lib

unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

cold sonnet
#

/fork

#

ui.View

slate swan
#

which one is the easiest to use

unkempt yacht
cold sonnet
#

then nop

slate swan
#

uh

#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slate swan
#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
cold sonnet
#

hmmmm

slate swan
slate swan
#

the library

#

its a class

pliant gulch
#

You gotta install discord.py through github in order to get them

slate swan
#

oh ok

slim ibex
#

🗿

slate swan
#

yeah you need 2.0 aka main branch

#

yeah ill prefer using a fork than main

pliant gulch
#

Your forks use the originals implementation kek

#

Or at the very least, the base

slate swan
#

yeah but other features

buoyant quail
#

so they are named forks

#

they don't change everything

slate swan
#

nope

#

reason why its a fork its just another version

pliant gulch
#

Rin had buttons but I removed them for the refactor!

slate swan
#

when it comes out in 50 years🏃

slim ibex
#

There are some minor changes like avatar_url to avatar.url

pliant gulch
#

I have only action row and text modals right now

slate swan
#

yes

pliant gulch
#

Yes

slate swan
#

andys aim with rin is performance and overall being better

pliant gulch
#

I don't use C or Cython right now, no

slim ibex
#

it would be better regardless

pliant gulch
#

But when I add voice I'll be writing bindings in either rust or C++

slim ibex
#

Rust🗿

pliant gulch
#

That's if I ever get to voice 😔

slate swan
#

andy

pliant gulch
#

I gotta finish models first

slate swan
#

you lesson to devs to make the wrapper better? so like you take the word from the community

slim ibex
#

yes I am part of it

slate swan
#

so its kinda ran by the community or based off its ideas

slate swan
pliant gulch
#

Weird how rin turned out

slate swan
#

how so?

buoyant quail
#

who is rin :

pliant gulch
#

You know the whole reason why I wrote rin was out of spite since another wrapper dev tried to scout me for their wrapper

#

Then I looked at their source code which looked god awful

#

So I decided to flex on them with rin

pliant gulch
#

For which?

pliant gulch
#

Yea

slate swan
#

lol

slim ibex
pliant gulch
#

🗿

slate swan
#

andy has something wrong with him to flex on everyone

#

🙄

#

check if fortnite has an api

hoary cargo
#

🗿 is there a way to sort member permissions to return a list with moderation perms instead of all of their perms even the generic ones

velvet tinsel
#

it's a huge community

slate swan
velvet tinsel
#

I found a dogecoin API

velvet tinsel
slate swan
velvet tinsel
#

weird and wacky
pycardano

velvet tinsel
slate swan
velvet tinsel
#

!pypi backrooms

unkempt canyonBOT
velvet tinsel
#

😳 ayo

slate swan
#

🗿

#
{
banwords = ["тупой", "дуб"]
}

erorr

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 1 (char 2)
#

is it?

#

where

#

ah ic

#

thats nice

#

why

#

watch the bot get written in js💀

#

😭

final iron
slate swan
#

its a python server

final iron
#

It would be very discouraging to learn python if the python bot was coded in javascript

slate swan
#

it was a joke bro

pliant gulch
#

Would've liked to see hikari be used or something

slate swan
final iron
#

How advanced is hikari right now?

pliant gulch
#

The main advantage of python based wrappers is the decorator syntax, rust is ok for discord bot's but the macros are just not it

#

In my opinion at least the main advantage is the decorator syntax

#

Other langauges you need to register via call, etc

#

Don't even get me started on cpp

pliant gulch
#

I cba

supple crescent
#

i genuinely cant tell what's wring with this, there is no error. it just doesn't work.(yes intents are there )

@client.event 
async def on_member_join(member):
     channel=client.get_channel(945789074663436318)
     emb=discord.Embed(title="NEW MEMBER",description=f"Thanks {member.mention} for joining!")
     await channel.send(embed=emb)```
royal jasper
#

how can i handle multiple selections with discord_components? like, if the person select something on menu and want to select other thing, don't show "this interaction failed"

rain olive
#

its better than all those dpy-wannabe-forks

final iron
#

The whole point was for forks to be made

rain olive
#

have you even tried hikari as a library

final iron
#

Like what are we going to do? Use discord.py, miss out on every single new feature until the library just eventually breaks?

kindred drum
#
@commands.command(name="strip")
    async def strip(self, ctx, member: discord.User):
        roleslist = []
        
        guild = bot.get_guild(915357451484790916)
        for i in range(0,len(Json_Items)): #It doesn't exist
                for x in Json_Items[i]:
                    if int(x) == member.id:
                        member = await bot.fetch_user(x)
                        member_real = guild.get_member(member.id)
                         
                        print(Json_Items[i][x]['roles'])       
                        for c in Json_Items[i][x]['roles']:
                            
                        
                            
                            

                            
                            role_remove = get(guild.roles, name=c")
                            roleslist.append(role_remove)
                            
                            
                            
        
        await member_real.remove_roles(role_remove1, role_remove2)
        await ctx.send("User roles striped")
                    ``` yo anyone now how I would get the list "roleslist" in  this format ``await member_real.remove_roles(role1, role2 etc)`` with the list?
alpine furnace
kindred drum
#

i dont know any way to do it

alpine furnace
rain olive
supple crescent
alpine furnace
#

Can you give an example? Seems like everything in their samples folder, you can do with dpy

#

Relatively easily too

#

discord.ext.commands is not pushed on dpy users at all, in my opinion

alpine furnace
supple crescent
alpine furnace
#

Soo the modules are just disjoint from the project, and if one becomes the best in its field, then there’s no point in having this extensibility anyway…other projects would just end up merging it into the main repo, even

karmic tartan
#

Grs are you like always talking here

alpine furnace
#

But like, that’s not to say you can’t do this with discord.py either

alpine furnace
karmic tartan
#

Alright lmao, just I was on here at like 2 am last night and you were talking and now it’s 5 pm and you’re still on

kindred drum
#

ah found it, stack overflow always coming in clutch, you gotta use ```py
member = await bot.fetch_user(x)
member_real = guild.get_member(member.id)

await member_real.edit(roles=[])```

supple crescent
alpine furnace
kindred drum
#

strange bug tho

supple crescent
kindred drum
supple crescent
#

if anythib

supple crescent
haughty quartz
#

is there a way to make a users name in chat appear blue like a ping without actually mentioning that person?

alpine furnace
karmic tartan
kindred drum
alpine furnace
#

Lol, deja vu

supple crescent
alpine furnace
#

That place is toxic af. Avoid at all costs, also that djs server

final iron
alpine furnace
supple crescent
#

yes

final iron
#

Only if you're a beginner

#

They have it listed that a basic understanding of python is required

hoary cargo
#

i'll try to filter them manually using a dict MR_uncanny_1

alpine furnace
#

Yeah, actually, if you were to meet face to face with the people you argue with here, you’d probably get along as best friends 😄

#

Something about discord, man

supple crescent
#

bruh i dont get this, no error, bot starts, just silence. 😭

rain olive
#

typehints in dpy are used as converters

#

🗿👍

supple crescent
alpine furnace
#

I’m stumped, but have you actually tried joining the server with an alt, or something while the bot is running

alpine furnace
#

Print something at the start of the method?

supple crescent
#

sure

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

supple crescent
#

kofc

#

and @alpine furnace if ur intrested

#

its around line 98

alpine furnace
#

You’re making two clients

#

One bot and one random empty base client

supple crescent
#

oh

alpine furnace
#

All the commands are registered under bot, and you run bot, but not client

supple crescent
#

where?

alpine furnace
#

Line 14

#

You can just do @bot.event

supple crescent
#

what shouldi put there

alpine furnace
#

Nothing, remove it

#

You already have a bot object right under it

supple crescent
#

and change line 98 to @ bot.event

alpine furnace
#

Yeah

supple crescent
#

k'

alpine furnace
#

And that on_ready too

supple crescent
#

uhhhh

#

@alpine furnace now every @client.event doesnt work

#

wtf

#

pls help

alpine furnace
#

Replace them with bot.event

#

Bot is a client

supple crescent
#

laorght

#

@alpine furnace async def on_ready():
TypeError: Client.event() missing 1 required positional argument: 'coro'

#

thats the on ready

alpine furnace
#

Did you put () after bot.event

supple crescent
#

yes......

#

totally....

torn sail
#

Remove the ()

rotund creek
#

Hey

potent spear
#

ayo

hoary cargo
#

wow no arguing today

lost lichen
#

i cant get this to work and i really dont know why...

authorfoot = ctx.author + 'response time: ' + 'placeholder'
embed.set_footer(text=authorfoot)
await ctx.send(embed=embed)```

but this does work

```py

authorfoot = ctx.author
embed.set_footer(text=authorfoot)
await ctx.send(embed=embed)

TypeError: unsupported operand type(s) for +: 'Member' and 'str'

#

im super confused

slim ibex
#

you can’t add a member object to a string

sick birch
#

str(ctx.author)

slim ibex
#

make it a str with str method

slim ibex
lost lichen
#

AH

#

thanks!

dull terrace
#

anyone wanna give an quick opinion on something in #databases? lemon_pensive

final iron
#

No

#

🗿

hoary cargo
#

🗿

whole sluice
#

how do you put api's on a discord bot? or to be more specfic how does dank memer insert a meme whenever u type a command?

slate swan
whole sluice
slate swan
whole sluice
slate swan
whole sluice
slate swan
#

since the lib uses objs

whole sluice
#

yeah i have a lot to learn lmao

slate swan
#

and then you could migrate to a fork or just learn with a fork

whole sluice
#

cool ill bookmark that ty

slate swan
#

yw

vivid marsh
#

Quick Question (I know this is a python server) but would it be better to make a eco bot with js or py?

whole sluice
#

i think i lied. i dont really know all of basic python yet. im still learning functions

#

im on default arguments

slate swan
vivid marsh
slate swan
normal bolt
#

help pls, How can I tag a member @member and make the bot get the id of the member I tagged?

whole sluice
vivid marsh
slate swan
whole sluice
slate swan
slate swan
whole sluice
#

im trying to memorize it but its a lot

slate swan
vivid marsh
whole sluice
whole sluice
#

its like 12 hours of videos. cause i bought this course from mosh hamedani for like 20 bucks. since i really liked his 1 hour course

whole sluice
hoary cargo
#

MR_uncanny_1 i did whois dyno rip-off, i think it's decent, what u guys think

final iron
#

🗿

pliant gulch
#

The join time should be using discord timestamps

#

Same with account registration

#

Would look a lot better and more interactive

final iron
#

Also accounts for timezones

#

I wish discord allowed the end user to choose how the timestamps were formatted

#

Like maybe a drop down menu

hoary cargo
final iron
#

It's simple

final iron
#

<t:1231231239>
<t:1231231239>

slate swan
#

🗿

final iron
#

Theres something in dpy that can help you create it

hoary cargo
# final iron Directly stolen from dyno

🗿 then it's an absolute success, though there's one problem that makes no much sense MR_uncanny_12 the roles are reversed like displayed from bot to top in hierarchy instead of the opposite

final iron
#

You could reverse the list

#

So it goes the other way

#

🗿

#

!e

your_role_list = ["a", "b", "c", "d"]
your_role_list.reverse()
print(your_role_list)
slate swan
final iron
#

bro

unkempt canyonBOT
#

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

['d', 'c', 'b', 'a']
final iron
#

You saw nothing

slate swan
#

finally

final iron
pliant gulch
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
hoary cargo
#

nvm

hoary cargo
final iron
#

Oh yeah

hoary cargo
final iron
#

.reverse() doesn't return the reversed list, it just reverses the list and returns None

#

Cause lists are mutable or smth

#

🗿

hoary cargo
pliant gulch
#

Then it returns a discord formatted timestamp for you

hoary cargo
#

oh

final iron
#

That should work

#

🗿

slim ibex
#

moai spreads

slate swan
unkempt canyonBOT
#

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

None
slate swan
#

🗿

final iron
#

🗿

slim ibex
#

🗿

slate swan
#

not sure how that returns none

final iron
#

bor

slim ibex
#

thats what im saying

final iron
#

iirc when you use a method on a string it returns a new string because strings are immutable

slim ibex
#

!e
print([1, 2, 3, 4].reverse())

unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

None
slate swan
#

it doesnt return anything it just changes the state of the list

final iron
#

🗿

slate swan
#

🗿

final iron
#

Watch andy say I'm wrong and make me sad

#

😭

slim ibex
#

^

glacial zealot
pliant gulch
#

I was about to say you were wrong at first cause you said lists were immutable

slate swan
slate swan
pliant gulch
#

But then you fixed it

final iron
#

I'm running on 5 hours of sleep

glacial zealot
#

I mean reversed

final iron
#

🗿

slate swan
#

🗿

slim ibex
#

!e print(["a", "b", "c", "d"].reverse())

unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

None
glacial zealot
#

!d reversed

unkempt canyonBOT
#

reversed(seq)```
Return a reverse [iterator](https://docs.python.org/3/glossary.html#term-iterator). *seq* must be an object which has a `__reversed__()` method or supports the sequence protocol (the `__len__()` method and the `__getitem__()` method with integer arguments starting at `0`).
slim ibex
#

o lma

glacial zealot
#

List methods generally edit the state of the list, instead of creating a new one

final iron
#

That's what I said

#

🗿

slim ibex
#

!e

print(list(reversed([1, 2, 3, 4, 5])))
unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

[5, 4, 3, 2, 1]
slate swan
#

I've mistook list.reverse() to also return a reference to itself many times

pliant gulch
#

A few days ago I fell into a trap of using a default mutable for my class constructor

slate swan
final iron
#

You copied what I said

slate swan
#

no

pliant gulch
#

to be fair I've never had that happen to me until recently so

hoary cargo
slim ibex
#

can a lambda take in *args, **kwargs?

#

I'd assume so but like

#

wait imma stop before ashley ots me

#

||ik ur lurking ashley||

pliant gulch
hoary cargo
final iron
#

🗿

supple crescent
#

i was trying to make it so when you do !clear, as long as you have the right role, it will delete the channel, but im getting the error: user is a required argument that is missing.

@bot.command(name="clear")
@commands.has_role(945325312533729311)
async def someCommand(ctx, user: discord.TextChannel):
    user.roles
    if role in user.roles:
      await ctx.send("Confirmed! Deleting channel in 10 seconds, no turning back!"),time.sleep(10),await ctx.channel.delete()
    else:
         await ctx.send("Sorry, you cant do that D:")
final iron
#

Mention a channel

supple crescent
#

this is from an old stack overflow so it might be outdated

#

ohh so like !clear #channel1

#

lemme try

final iron
#
user: discord.TextChannel
#

🗿

slate swan
supple crescent
#

oh

#

.

final iron
#
if roles in user.roles
#

I see a lot of issues in this code

supple crescent
#

🗿

slate swan
#

useless else lol

final iron
slate swan
#
if role in user.roles:
      return await ctx.send("Confirmed! Deleting channel in 10 seconds, no turning back!"),time.sleep(10),await ctx.channel.delete()
await ctx.send("Sorry, you cant do that D:")
#

it wouldnt continue

#

and time.sleep🏃

supple crescent
final iron
#

Blocking

slate swan
supple crescent
slate swan
#

use asyncio.sleep which only sleeps on the coro

supple crescent
#

i guess ive never had 2 codes that could be going at the same point

slate swan
#
await asyncio.sleep(10)
supple crescent
#

hmm il look into that

supple crescent
slate swan
slate swan
supple crescent
hoary cargo
supple crescent
#

wait yeah

#

you can make it recognize the channel the cmd came from right?

slate swan
supple crescent
#

alr that wont matter muich but thats good to know

final iron
unkempt canyonBOT
supple crescent
#

yeah

#

thats what i thought

#

i mean, im in test.

@bot.command(name='clear', help='delete a channel with the specified name')
async def clear(ctx, channel_name):
   guild = bot.guilds[0]
   existing_channel = discord.utils.get(guild.channels, name=channel_name)
   
   # if the channel exists
   if existing_channel is not None:
      await existing_channel.delete()
   # if the channel does not exist, inform the user
   else:
      await ctx.send(f'No channel named, "{channel_name}", was found')```
supple crescent
#

?

nimble plume
#

Yes

supple crescent
#

alr

#

async def clear(ctx, channel_name):

#

in there?

nimble plume
#

i mean, im in test.

@bot.command(name='clear', help='delete a channel with the specified name')
async def clear(ctx, channel_name):
   existing_channel = discord.utils.get(ctx.guild.channels, name=channel_name)
   # if the channel exists
   if existing_channel is not None:
      await existing_channel.delete()
   # if the channel does not exist, inform the user
   else:
      await ctx.send(f'No channel named, "{channel_name}", was found')
supple crescent
#

oh ok

nimble plume
#

Ur code be like

#

Try now

supple crescent
#

nope

#

channel still not found

final iron
#

You've been sold so many times

supple crescent
#

dude dont minimod

slate swan
#

It's not mini-modding by any means, spoonfeeding is just not the way to help someone out

#

what is the best library for discord buttons

slim ibex
#

disnake has all that stuff

hoary cargo
slate swan
vivid marsh
hoary cargo
final iron
supple crescent
#

sorry pep8

#
@bot.command(name="open")
async def open(ctx):
    guild = ctx.guild
    admin_role =  guild.get_role(945847161596297277)

    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        admin_role: discord.PermissionOverwrite(view_channel=True),
        guild.me: discord.PermissionOverwrite(view_channel=True)
    }
    channel = await guild.create_text_channel(f"private-channel{ctx.author}", overwrites=overwrites) 
    await channel.send(ctx.author.mention, "Hi! for help on how to order, do !help")   
    await bot.delete_message(ctx.message) 
    ``` any way this could be done? i keep getting the error takes from 1 to 2 positional arguments but 3 were given
slim ibex
#

which line raises error

supple crescent
#

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

Traceback (most recent call last):
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Messageable.send() takes from 1 to 2 positional arguments but 3 were given

#

its in the libraies somewhere

slim ibex
#

i assume its from await channel.send(...)

supple crescent
#

i think its from the delete

slim ibex
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

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

bc i just added that, i need someway for it to make the channel, then delte the comd

slim ibex
#

it only takes one pos arg

#

send the part of the traceback before the part you just sent

supple crescent
#

Traceback (most recent call last):
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Messageable.send() takes from 1 to 2 positional arguments but 3 were given
Ignoring exception in command open:
Traceback (most recent call last):
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\trent\Desktop\DiscordBot\discordbot.py", line 100, in open
await channel.send(ctx.author.mention, "Hi! for help on how to order, do !help")
TypeError: Messageable.send() takes from 1 to 2 positional arguments but 3 were given

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

Traceback (most recent call last):
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\trent\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Messageable.send() takes from 1 to 2 positional arguments but 3 were given

#

await channel.send(ctx.author.mention, "Hi! for help on how to order, do !help"), look at that

slim ibex
#

yeah it is the send

supple crescent
#

hmm

#

that unusal

slim ibex
#

mention_author is a kwd arg

supple crescent
#

that only started when i added the delete

slim ibex
#

put the string before ctx.author.mention

supple crescent
#

a;lroight

#

nope

slim ibex
#

same error?

supple crescent
#

same thing

#

await channel.send("Hi! for help on how to order, do !help", ctx.author.mention)

slim ibex
#

do await channel.send("...", mention_author=True)

supple crescent
#

news.

#

it now creates 2 private channels

#

and doesnt delete it

slim ibex
#

so it worked though

supple crescent
#

yeah

#

doesnt ping now though

slim ibex
supple crescent
#

dude help

#

everything is doubling

slim ibex
#

like every command?

cerulean olive
#

Unhandled exception in internal background task 'time_check'.
Traceback (most recent call last):
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\tasks_init_.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "taken.py", line 75, in time_check
await updateDate()
File "taken.py", line 93, in updateDate
date = datetime.now()
AttributeError: module 'datetime' has no attribute 'now'

slim ibex
#

datetime.datetime.now

cerulean olive
#

@slim ibex ur always here

hoary cargo
#

or utc.now

supple crescent
#

ill send full code

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slim ibex
supple crescent
#

lemme check

slim ibex
#

you can end python processes in task manager

supple crescent
#

ok yeah phew

cerulean olive
# slim ibex ``datetime.datetime.now``

Unhandled exception in internal background task 'time_check'.
Traceback (most recent call last):
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\tasks_init_.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "taken.py", line 75, in time_check
await updateDate()
File "taken.py", line 119, in updateDate
await channel.edit(name=f'﹕📋﹕daily﹕{month}-{date.day}')
AttributeError: 'NoneType' object has no attribute 'edit'

supple crescent
#

i though i was in trouble

slim ibex
#

is it a variable?

#

show the rest of the code

cerulean olive
#

y is a 14 year old smarter than me

slim ibex
#

💀

hoary cargo
#

Get moai'd

supple crescent
slim ibex
supple crescent
#

ahh

#

create would work

#

is that bad or nah

slim ibex
#

when your code runs, it checks variables/func in the order of local, enclosed, global, builtin

hoary cargo
slim ibex
#

and since builtin is last, you override the open() function

slim ibex
#

don't think vscode raises that stuff

#

pycharm def does

hoary cargo
#

Yeah

supple crescent
#

should i use pycharm or vsc?

#

or does it not matter

slim ibex
#

its preference

supple crescent
#

what are the advantges

slim ibex
#

im using pycharm atm, but i used vscode before

#

pycharm is a fully featured IDE

supple crescent
#

anyway, new error

hoary cargo
slate swan
#

Vscode is lighter and has more extensions and very easy to use
Pycharm is meant specifically for python but is quite bit complex

slim ibex
#

^

slate swan
#

Ares, What does vscode lack?

hoary cargo
#

MR_uncanny_1 I find pycharm very easy to use

hoary cargo
final iron
#

idk why people say pycharm is complex

#

It's quite simple

slate swan
hoary cargo
slate swan
#

Pycharm is too heavy for me 🏃

final iron
#

😔

final iron
slate swan
#

as if pycharm is the only workspace using venvs

final iron
#

Everyone should be using venvs

slate swan
#

venvs*

final iron
#

No matter your development environment

final iron
supple crescent
#

alright 1 thing, i want to use await message.delete(), but that doesnt seem to work with my code

@bot.command(name="open")
async def open(ctx):
    guild = ctx.guild
    admin_role =  guild.get_role(945847161596297277)

    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        admin_role: discord.PermissionOverwrite(view_channel=True),
        guild.me: discord.PermissionOverwrite(view_channel=True)
    }
    channel = await guild.create_text_channel(f"private-channel{ctx.author}", overwrites=overwrites) 
    await channel.send("Hi! for help on how to order, do !help", mention_author=True)   
    ```
supple crescent
supple crescent
#

c:\Users---\Desktop\DiscordBot\discordbot.py:101: RuntimeWarning: coroutine 'Message.delete' was never awaited
ctx.message.delete()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

final iron
#

called it

slate swan
#

And its not an error, it's a warning

supple crescent
slate swan
#

but you need to await it since it's a coro

hoary cargo
#

MR_uncanny_10 wh

slate swan
#

That's what the warning says.

hoary cargo
#

If you don't await it will not work MR_uncanny_16

supple crescent
hoary cargo
#

@final iron I'm gonna ruin your whole career
I had 300 pep8 warnings before rewriting my code in one of my cogs MR_uncanny_1

slate swan
#

you don't use the is statment with a class

final iron
#

🗿

slate swan
#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
supple crescent
#

fuck wrong gif

#

whatev

hoary cargo
slate swan
#

Because it gets triggered on every on_message...

#

you'd have to cache what user is using the modmail already so a new modmail doesnt start

slate swan
#

And check if the author is in the cache before proceeding

supple crescent
#

@final iron it worked ily man thanks

final iron
#

🗿

hoary cargo
#

MR_uncanny_1 +1