#discord-bots

1 messages ยท Page 749 of 1

untold token
#

Weird

maiden fable
#

Try looking through guild.bans

#

Or try using guild.unban

quick gust
#

Are u sure they aren't an alt? I might be wrong but I think all discord guild bans are IP bans by default

untold token
#

Yes

#

Discord bans are IP based

flint cypress
quick gust
#

Did u understand what I said?

#

It might be that one of their other accounts (if any) is banned

hardy geyser
#

hello, i was just writing a bot and realized that discord.ext.commands.has_permissions cannot check for the manage server permission

#

this line:

@commands.has_permissions(manage_server=True)

returns the error Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> commands.has_permissions(manage_server=True) File "C:\Users\win\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 1779, in has_permissions raise TypeError('Invalid permission(s): %s' % (', '.join(invalid))) TypeError: Invalid permission(s): manage_server

slate swan
#

!d discord.Permissions.manage_guild

unkempt canyonBOT
slate swan
#

is what you want

hardy geyser
#

oh

#

thanks its working

#

im stupid sorry

slate swan
#

its alright

#

and yw

hardy geyser
#

half an hour wasted on stackoverflow

slate swan
#

lol

#

Small tip, whenever you need to use server, write guild.

slate swan
#

how can i show how many guilds my bots in with this?

len(bot.guilds)
slate swan
#

the wut

hexed vine
#

!embed

#

!embed

#

!embed

slate swan
#

?

quick gust
#

i didnt understand your question

slate swan
#

you can i display how many guilds my bot is in

quick gust
#
len(bot.guilds)```
slate swan
#

alr

#

how can i make all my embed colors a certain color do i subclass the Embed class?

spare sand
#

is there a bot i can add to my server which can make these boxes

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

pretty easy just send msg with the backticks

spare sand
slate swan
#

no its not lol

slow fog
#

ass

slate swan
#

what fork should i use

meager crown
#

fork of what

slate swan
meager crown
#

yeah

slate swan
#

and there are some forks to use

meager crown
#

yeah, i reccomend nextcord

#

recommend*

slate swan
#

o

#

anyone can help me discord bot i have the gitbhub

meager crown
#

i didnt understand a word you just said

slate swan
#

modmail bot

#

i dont know data thing

meager crown
#

data what

#

data thing

#

???

#

database?

#

@slate swan

slate swan
#

modmail github

#

i want to be my bot

#

like i change security

#

eh

heavy folio
#

is it your bot

slate swan
#

you want to be your bot? as if self bot?

meager crown
#

๐Ÿ’€

slate swan
#

๐Ÿ’€

heavy folio
#

self bot tos

slate swan
#

Well if you want to self host it , read the FAQs or smthin

#

its someone else and i have to fork it and change the bot token and run the bot with some replit

kind wasp
#

Selfbot?

slate swan
#

im not good at python

#

im good at lua only

kind wasp
#

I know

slate swan
#

then learn python

slate swan
heavy folio
#

weong channel

kind wasp
#

Run the file on replit

heavy folio
#

no what lol

kind wasp
#

Pra PC with py version

slate swan
#

where lua server

kind wasp
#

Pra*

#

Or*

meager crown
slate swan
#

^^^

#

or learn python. discord libraries on python are a bit complex

#

dat python

#

no python suck and its not a 3d platform

#

and lua has a 3d platform

zealous dagger
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 146, in help
    label = event.component[0].label
TypeError: 'Select' object is not subscriptable

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1353, in invoke
    await super().invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/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: 'Select' object is not subscriptable```
slate swan
#

๐Ÿ’€

#

like roblox which u can script lua and design model in blender

zealous dagger
#

HOw to

slate swan
#

we dont use python to make roblox game mate ๐Ÿ’€

zealous dagger
#

Solve

zealous dagger
#

this error

slate swan
#

i play roblox i dont play python mate ๐Ÿ’€

#

It's not an iterable

zealous dagger
zealous dagger
#

But I want to respond to the select menu

#

So how do I do that

#

@slate swan

slate swan
#

What library do you use

zealous dagger
#

discord_interactions

slate swan
#

Master branch?

meager crown
zealous dagger
#

discord_components

zealous dagger
slate swan
#

Idk about that library read the docs , ask in their help server
Or wait for someone else to respond

#

Wait what , are you using 2.0 , discord_interactions or discord_components

zealous dagger
#

Yes

#

you are right

#

@slate swan

slate swan
#

you cannot code in python by knowing lua ๐Ÿคฆโ€โ™‚๏ธ

#

you need to learn atleast the basics

zealous dagger
#

Anyone else

#

can help

slate swan
#

send the code

zealous dagger
#

Ok

#

Come in

slate swan
#

???

zealous dagger
heavy folio
#

@zealous dagger youhave discord_comp and 2.0 dpy?

#

uninstall third party libs it breaks dpy

slate swan
#
    @commands.Cog.listener('on_reaction_add')
    async def handled(self,reaction,user):
        if reaction.message.channel.id == 931503735052591124:
            await reaction.message.delete()

This would look at all reaction, wont this slow down the bot? Any better way to do this?

maiden fable
slate swan
copper gulch
#

is there a way to do commands in the discordBot dms?

slate swan
#

you can always do that...

#

unless you try to do something limited only to guilds

copper gulch
copper gulch
slate swan
#

oh , what command are you trying to make?

copper gulch
#

maybe a bug in my game somehow

icy mango
#

can anyone send me some code examples of tag command

slate swan
icy mango
#

yes

slate swan
maiden fable
#

!src tag

unkempt canyonBOT
#
Command: tags

Show all known tags, a single tag, or run a subcommand.

Source Code
slate swan
maiden fable
#

Breh ๐Ÿ˜

icy mango
#

thanks

slate swan
#

it uses pgsql iirc

icy mango
#

oof and i dont know how to use db

mystic arrow
#

hi

icy mango
#

๐Ÿ’€

slate swan
#

you can learn something easy like sqlite or mongodb

icy mango
slate swan
#

great

mystic arrow
#
import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged in as')
        print(self.user.name)
        print(self.user.id)
        print('------')

    async def on_member_join(self, member):
        guild = member.guild
        if guild.system_channel is not None:
            to_send = 'Welcome {0.mention} to {1.name}!'.format(member, guild)
            await guild.system_channel.send(to_send)


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

client = MyClient(intents=intents)
client.run('token')
zealous dagger
#

Else mine would not work

#

@heavy folio

#

and by the way

#

or someother module

slim ibex
#

!pypi nextcord

unkempt canyonBOT
zealous dagger
slim ibex
#

i used it for my bot, deployed it and pushed it to servers

#

its great

#

check out disanke too

#

!pypi disnake

unkempt canyonBOT
zealous dagger
#

and does it support

#

select

#

menu

slim ibex
#

and there is a new lib, in alpha/planning called Pincer. You can test with Pincer and learn it but don't make a production ready bot with it

#

!pypi pincer

unkempt canyonBOT
zealous dagger
#

I mean this

slim ibex
#

yes

#

with views

zealous dagger
#

Can you give me an example

#

of using select

#

and with option response

#

I would be very thankful to you

slim ibex
#
class Dropdown(nextcord.ui.Select):
  def __init__(self, options: list[nextcord.SelectOption]):
    super().__init__(placeholder="Choose" min_values=1,
max_values=1, options=options)

  async def callback(self, interaction: nextcord.Interaction):
    ...

class View(nextcord.ui.View):
  def __init__(self, options: list[nextcord.SelectOption], *, timeout: Optional[float] = 60.0):
    super().__init__(timeout=timeout)
    self.add_item(Dropdown(options))
maiden fable
#

???

slate swan
#

!pypi pycord

unkempt canyonBOT
slate swan
#

py-cord

#

oh ok thanks

#

!pypi py-cord

unkempt canyonBOT
slate swan
#

i was wondering why was it related to ffmpeg

zealous dagger
#

I installed it

#

But Caan't import

#

it

#

HOw to do that so

slate swan
#

installed what? first be consistent with what library you want to use

zealous dagger
#

!pypi py-cord

unkempt canyonBOT
slate swan
#

you cannot use pycord discord.py discord_components everything in a single bot

zealous dagger
#

No

#

I removed

#

Discord and replaced everything with pycord name in it

#

but not working

unkempt magnet
#

I'm trying to make a discord slash command. heres the code:

@slash.slash(name="Channel", description="Choose Querty chat channel", options=[create_option(name="channel", description="Channel", option_type=7, required=True) ])
async def Channel(ctx, channel: discord.TextChannel):
    guild = ctx.guild.id
    
    channel_dict[guild] = channel

    print(channel_dict)

    f = open("storage.json", "w")
    json.dump(channel_dict, f)

the command doesnt appear in the slash menu
I'm using all intents

intents = discord.Intents.all()
client = commands.Bot(command_prefix='!', intents=intents)
slash = SlashCommand(client, sync_commands=True)
client.run(Token)

Client.run is last line
could anyone help

zealous dagger
#

Why so

slate swan
#

send code

#

and error , if any

zealous dagger
#

ok

#

It is very long

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.

zealous dagger
unkempt magnet
zealous dagger
#

It will not work

#

Send your

#

code

#

From the slash till the client.run

slate swan
zealous dagger
unkempt magnet
#

no

#

I cant even execute it for it to give an error

slate swan
# unkempt magnet yes

it will take 1 hr to appear on discord , unless you provide a test_guild or enabled_guilds arg depending upon the library u use

boreal ravine
#

๐Ÿ‘€

zealous dagger
#

Here you go

unkempt magnet
zealous dagger
#

!pypi discord-py-slash-command

unkempt canyonBOT
zealous dagger
#

Is this module fine

#

@slate swan

slate swan
zealous dagger
#

for select menu and buttons

upbeat otter
slate swan
zealous dagger
upbeat otter
slate swan
zealous dagger
#

Ahhhhhhhhhhhhhhh.................!!!!!!!!!!!!!!

slate swan
zealous dagger
#

I know

#

But there are tons

#

Of them

slate swan
#

use disnake

#

atleast that what ill suggest

#

disnake or nextcord

unkempt magnet
zealous dagger
#

Fine then see you (when problem occurs)

unkempt magnet
slate swan
#

^^ examples

granite prawn
#
@client.event
async def on_message(message):
  links = re.findall("discord.gg/[0-z]*",message.content) #regex all invites
  for i in links:
    try: #will fail if invalid
      invite = await client.fetch_invite(i)
      if not invite.max_age: #continue if its permanant
        continue

      else: #if not permanant
        await message.delete()
        await message.author.send('Only permanant invites are allowed!')
        return

    except discord.NotFound: #invalid invite handling
      await message.author.send('Invalid invite link')
      await message.delete()
      return
    except: #rate limit handling
      pass

    await client.process_commands(message)

this is a script that will automaticaly delete invites that are not valid permanant links, the bot gets rate limited very often. is there any way i can use an alternative to fetch_invite so it wont be an api call or maybe any way that wouldn't rate limit this.

slate swan
#

probably not , i tried searching for an alternative but didnt get

#

someone told me u can use raw requests for that too

heavy folio
#

wait the lib handles ratelimits nvm

granite prawn
maiden fable
maiden fable
#

They just delete message iirc

stable berry
#

hello

#

need help

#
class ReactionRolesNotSetup(commands.Command_Error):
  pass

def is_setup():
  async def wrap_func(ctx):
    data=await ctx.bot.config.find(ctx.guild.id)
    if data is None:
      raise ReactionRolesNotSetup

    if data.get("message_id") is None:
      raise ReactionRolesNotSetup

    return True
  return commands.check(wrap_func)


class Reactions(commands.Cog, name = "ReactionRoles"):
  def __init__(self, bot):
    self.bot=bot

  @commands.group(
    aliases=['rr'], invoke_without_command=True
  )
  @commands.guild_only()
  async def reactionroles(self, ctx):
    await ctx.invoke(self.bot.get_command("help"), entity="reactionroles")

def setup(bot):
  bot.add_cog(Reactions(bot))   

#

is here any problem

slim ibex
granite prawn
maiden fable
#

Ah

prime marten
#

Hi, so i have an economy bot with a deposit command (sqlite3)
Any idea on how to put a limit that your bank balance cannot be more than say 500k?

upbeat otter
fleet sparrow
#

hello

#

is there a way to add multiple roles permissions for use a command? like this:

@client.command()
@commands.has_role(['RoleName1', 'RoleName2'])```
maiden fable
#

O my bad

#

Just use multiple has_role decos

fleet sparrow
#

xd works

#

but you will need all roles to execute the command

#

๐Ÿค”

granite prawn
#

!d discord.ext.commands.has_any_role

unkempt canyonBOT
#

@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.

Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.

This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
west shuttle
#
async def mute(ctx, member: discord.Member = None, time:int, reason = "No reason"):

In VSC there is a red line undertime:int

fleet sparrow
fleet sparrow
west shuttle
karmic lintel
#

i always have to ping my bot to use commands how to solve?

fleet sparrow
heavy folio
#

because you have member as none and time as a positional arg

fleet sparrow
heavy folio
#

no lol

heavy folio
#

!d discord.ext.commands.when_mentioned_or

unkempt canyonBOT
#

discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
karmic lintel
#

the too problems

heavy folio
#

it's an add on prefix

#

@karmic lintel have an on_ready?

karmic lintel
#

yes

karmic lintel
granite prawn
#

so you can also put time before member if it must be specified

karmic lintel
#

@heavy foliotell bro

granite prawn
karmic lintel
#

@granite prawnpls help me

granite prawn
karmic lintel
#

i always have to ping my bot to use commands how to solve?

#

like .say hi @botping here . is prefix

granite prawn
#
client = commands.Bot(command_prefix=when_mentioned_or(".")) 

this is correct, you can ping the bot or use .say

granite prawn
final iron
#

You should be using bot as discord.Client is a thing

granite prawn
karmic lintel
#

and bot returns hi @botping

heavy folio
#

yes dont name it client (bad practice)

#

@karmic lintel send your on_ready

#

and stop pinging me

karmic lintel
#
@client.event
async def on_ready():
    print('Bot is Ready')
final iron
heavy folio
#

wait

karmic lintel
#
@client.event
async def on_ready():
    print(f'{client.user.name} has connected to Discord!')

heavy folio
#

on_message mb

karmic lintel
#

i have two on_ready

heavy folio
karmic lintel
#

@heavy folio

heavy folio
#

wh

#

why? and stop pinging me

#

send your on_message, and why do you have 2 on readys

granite prawn
final iron
#

I still can't read docs

karmic lintel
#

help mee \๐Ÿ˜ญ \๐Ÿ˜ญ

final iron
#

The bot = commands.Bot() line

karmic lintel
heavy folio
#

bro

#

i literally said

final iron
karmic lintel
#

what?!!

karmic lintel
final iron
#

I have no point

#

I'm asking you a question

slate swan
#

im writing a program to generate all possible discord invites that arent vanity invites
im hitting a bit of a snag in trying to figure out how to get it to generate the other characters while its under 1000 (ex 0001,0100) the zeros in front of the one are "blank" becuase they dont exist
how do i make it so they do exist

import os
import random
try:
    import json
    import requests
except:
    os.system("python -m pip install requests json")
proxylist = open("proxies", "r").readlines()


def PagingDiscordServer(webhook_url, text_message): requests.post(webhook_url, proxies={"socks5": random.choice(
    proxylist)}, data=json.dumps({"content": text_message}), headers={'Content-Type': 'application/json', })


charlist = open("chars", "r").readlines()
webhook = "WEBHOOK"
length = 7
for i in range((len(charlist)**7)):
    invite = "discord.gg/"
#

pls help ;-;

sick birch
#

Sounds kind of suspicious

#

Brute forcing invites?

quaint epoch
#

how do i send messages only certain ppl can see?

slate swan
#

i just wanted to see all the possible ones and see what i find

sick birch
#

Hmm yeah no probably shouldnโ€™t

slate swan
#

like i tried discord. gg/bi earlier and it gave me somthing in arabic

#

i just wanted to see what servers i find

quaint epoch
#

that's

sick birch
#

Lot of common vanities are taken, meant to be public too so itโ€™s not a big deal but itโ€™s a problem when you get ahold of invites for servers that arenโ€™t meant to be public

knotty gazelle
quaint epoch
sick birch
#

Im not sure if it breaks TOS but it probably does

slate swan
#

im after the plubic ones that are really intresting

sick birch
#

It doesnโ€™t really matter what youโ€™re after the fact is youโ€™re still trying to brute force invites and join servers you werenโ€™t after

#

There are plenty of discord server listings online which you can look at

slate swan
#

yeah that is very much breaking TOS

#

ugh fine i wont bruteforce invite

#

invites*

#

killjoys

tidal hawk
#

Was there way to get client.owner or client.developer

#

basically the creator of object n turn it into obj

hoary cargo
keen talon
hoary cargo
#

buttons are not standalone, you can't send just a button without something attached to it

#

like a message/embed

quaint epoch
#

idk how to use buttons, time to start reading the docs again...

final iron
hoary cargo
tidal hawk
#

Create a member object with bot's creator

#

If I'm the creator then it should: client.creator => returns user/member object

quaint epoch
karmic lintel
#

anyone help me pls \๐Ÿ˜ญ

quaint epoch
#

whats*

karmic lintel
hoary cargo
# quaint epoch disnake

https://www.youtube.com/watch?v=kNUuYEWGOxA
i recommend u this vid, it covers the basics of buttons, and it works for disnake too

This is the Ultimate Python Guide on Buttons with Discord.py or Pycord. In this video, I talk about how to create buttons in discord.py or pycord and how to respond to button clicks along with everything about Views. After watching this you'll know everything about Buttons and Views in discord.py or pycord.

This video might also apply to other...

โ–ถ Play video
karmic lintel
#

full code?

hoary cargo
quaint epoch
karmic lintel
#

it occurs in every command

final iron
#

Send your bot constructor

karmic lintel
karmic lintel
quaint epoch
hoary cargo
#

stop.

quaint epoch
#

don't do client it's confusing

karmic lintel
#

eh?

hoary cargo
#

let them use whatever they want

#

you can define commands.Bot as whatever you want

quaint epoch
karmic lintel
hoary cargo
#

it's the same thing

#

use what you are comfortable with

final iron
slate swan
#

hey so i am trying to make a slash command group using py-cord library
codes:

parody = bot.create_group(
    "hmm", "parody"
)

error:
command.id = cmd.id
AttributeError: 'SlashCommandGroup' object has no attribute 'id'

quaint epoch
hoary cargo
quaint epoch
final iron
#

- creating a bot using the Bot object and naming it client

honest vessel
#

why name it client when its a bot and not using client

hoary cargo
#

your point?

karmic lintel
#

@quaint epoch?/?

honest vessel
#

its like call a car a motorcycle

final iron
slate swan
#

if you are making it as for a community example
music bots or game bots then no
if you are making bot for a specific server then its ok to use discord.py

#

sure it is bad practice in the sense that it makes things slightly more confusing when getting help with your code

quaint epoch
hoary cargo
#

๐Ÿฅฑ people be like good practice to name your bot whatever but they don't know the basics of python

slate swan
#

for example you might use a function from the commands extension that would usually not be seen with discord.Client

karmic lintel
#

without mentioning bot

slate swan
#

yet you're using commands.Bot, it's just that your object is named client

slate swan
unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @fervent violet until <t:1642170934:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

quaint epoch
karmic lintel
final iron
karmic lintel
#
async def select(ctx):
  await ctx.send(".s l")```
slate swan
#

do you have events?

slate swan
karmic lintel
karmic lintel
final iron
slate swan
#

it would only be a problem if it's overriding the default on_message event

#

that's not the case for him

slate swan
karmic lintel
quaint epoch
#

did you enable intents

#

it might be necessary

karmic lintel
slate swan
karmic lintel
quaint epoch
karmic lintel
#

it is an existing command

quaint epoch
#

do py intents = discord.Intents.all() client = commands.Bot(command_prefix='prefixhere', Intents=intents)

#

it might work afterward

slate swan
#

why would he need privileged intents?

#

what it seems like to me is, he sends a command to his bot, bot replies with a message that intends to trigger another bot

#

which makes no sense at all in retrocess

slate swan
fluid spindle
#

What type of storage library do you guys recommend for storing info?
I mean, like, JSON, pySQLite, etc...

slate swan
#

@karmic lintel send the full script all the codes in the file

slate swan
#

you can use a json-like structured database, like mongoDB

slate swan
slate swan
slate swan
#

wherever you are hosting your bot, you will be able to connect to an external database

solar anchor
#
@Bot.command()
async def addlink(ctx, link, name):

    buttonG = Button(label=str(name), url=str(link))
    view = View()
    view.add_item(buttonG)


@Bot.command()
async def links(ctx):
    await ctx.send('**Links:**' + name, view=view)```
slate swan
#

now the question of you being able to host it yourself, that's another story

solar anchor
#

how can i get the info from the first command in the second?

slate swan
#

so yes, irrelevant. he asked for a reccomendation

solar anchor
#

for name and view

slate swan
#

if its heroku then he has to use postgresqlite because
if stores in json the json file resets after every push and if sql file then same

fluid spindle
final iron
#

You shouldn't be using heroku to host anyway

slate swan
#

agreed, heroku is a platform for web applications

slate swan
slate swan
#

a JSON-like database can also be refered to a document-based db

#

lost count at certain point

slate swan
#

here's a good distinction of them both

#

a relational, column type database

#

and a document type database

quaint epoch
#

you can use timeout

final iron
#

Just use timeout

slate swan
#

merely sharing full snippets of commands is against the purpose of this channel

slate swan
quaint epoch
#

oh yeah

stable berry
karmic lintel
quaint epoch
slate swan
fluid spindle
karmic lintel
stable berry
slate swan
#

what the....

quaint epoch
#

most hosting providers provide smth like 150 mb dtbase for free, which is MORE THAN enough for a small disc bot

karmic lintel
#

\โค๏ธ

slate swan
#

did you just help this dude spam a discord server?

slate swan
slate swan
#

are you nuts? that's a malicious script

slate swan
# karmic lintel ok

bot=False is from the library named discum
(and also thats a library specially made for self-bot purposes only)

slate swan
quaint epoch
#

fuck

slate swan
#

@quaint epoch

fluid spindle
quaint epoch
#

ping mods

#

@slate swan ping mods

slate swan
#

wait wait

stable berry
#

2hat happened

slate swan
#

don't ping mods,

karmic lintel
#

eh

slate swan
#

holy

#

just open a modmail entry, relax

#

i've already done it, put a pin on this

quaint epoch
unkempt canyonBOT
#

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

slate swan
quaint epoch
slate swan
#

MongoDB has it's downsides, but it is very beginner friendly

quaint epoch
#

im dm'ing modmail now

karmic lintel
slate swan
slate swan
quaint epoch
#

did you get the username and id?

slate swan
#

of course

#

relax, he'll get his slap on the wrist and we will all forget this

#

move on

quaint epoch
long rock
#

Rage multi tool

fluid spindle
slate swan
#

๐Ÿคฃ

quaint epoch
#

if this incident gets famous remember me @slate swan

#

lol

final iron
#

So I need some help comprehending the docs

quaint epoch
final iron
#

Lets say we look at something like:

slate swan
final iron
#

!d discord.ext.commands.Bot.run

unkempt canyonBOT
#

run(*args, **kwargs)```
A blocking call that abstracts away the event loop initialisation from you.

If you want more control over the event loop then this function should not be used. Use [`start()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.start "discord.ext.commands.Bot.start") coroutine or [`connect()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.connect "discord.ext.commands.Bot.connect") + [`login()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login").

Roughly Equivalent to...
final iron
#

How do I know what the args and kwargs are?

slate swan
#

they're pointed out in the web page

quaint epoch
#

!e discord.ext.command.Bot

unkempt canyonBOT
#

@quaint epoch :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'discord' is not defined
quaint epoch
#

!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.
quaint epoch
#

nice

slate swan
karmic lintel
#

tysm

slate swan
#

๐Ÿคฃ

final iron
quaint epoch
slate swan
#

anyone know where I can ask questions related to aiohttp?

slate swan
cloud bison
#

my bot commands are working in dm how I cant stop them?

slate swan
karmic lintel
#

who i s deleting my commands? e

slate swan
#

it blocks the specific command from running in an instance of DMChannel

keen talon
slate swan
#

run() is a different case because it is an abstraction of another function

#

!d discord.ext.commands.Bot.start

unkempt canyonBOT
#

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

A shorthand coroutine for [`login()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login") + [`connect()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.connect "discord.ext.commands.Bot.connect").
slate swan
#

so the same arguments that start() takes, run() takes as well

final iron
solar anchor
#

how can i send a message if a user didnt fill in the requirtmenst for a command

#
@Bot.command()
async def link(ctx, link, name, text):```
#

lets say they didnt fill in a name

maiden fable
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

slate swan
#

you mean like, a missing parameter?

maiden fable
#

Rip

solar anchor
#

yeah

slate swan
#

!d discord.ext.commands.MissingRequiredArgument

unkempt canyonBOT
#

exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
maiden fable
#

Imagine spelling error

solar anchor
#

xDF

slate swan
#

what you need is to make a listener in the 'on_command_error' event

#

and then match if the specific exception is a MissingRequiredArgument type

solar anchor
#

uh

slate swan
#

then you can make your statement

maiden fable
#

!d isinstance @solar anchor

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

The object will be the error

#

And classinfo will be the error class

#

Rip they haven't fixed that yet

solar anchor
#
@Bot.command()
async def link(ctx, link, name, text):

    buttonG = Button(label=str(name), url=str(link))
    view = View()
    view.add_item(buttonG)
    await ctx.send('****' + text + '****', view=view)

    if link == None or name == None or text == None:
        await ctx.send("Fill in all requirments")```
#

i just tried this haha

maiden fable
#

Rip

slate swan
#
@Bot.listen('on_command_error')
async def error_handler(ctx, error):
#

here's the starting point for your new shiny command error handler

#

now you figure out how to use the isinstance() method that hunter pointed you to

solar anchor
#

okay thanks

#

do i add it high up in the code?

slate swan
#

eh that's redundant

solar anchor
#

alright

slate swan
#

as long as it's before Bot.run and after your commands.Bot constructor

#

you'll be good

solar anchor
#

alrighty thanks a lot guys

#

it works

#

yay

#

๐Ÿ˜„

keen talon
#

๐Ÿ‘

quaint epoch
#

@slate swan

#

did you get the spammers user id?

#

@slate swan

#

a mod is asking me for the id

#

:|

keen talon
quaint epoch
#

i was talking to wrench

#

the guy that wrote the spammer script

#

username/id would be great

#

mods asking

#

panicccc

#

i don't wanna be banned man

keen talon
#

Turn on developer mode in settings

quaint epoch
keen talon
#

And then right click on user

quaint epoch
#

i did it but he deleted all his messages

keen talon
#

๐Ÿ™‚

quaint epoch
keen talon
quaint epoch
#

are going to kill me

#

I'll never be able to join this server again

bright delta
#

hi i have a question, im making a ship command but i keep getting this error and i have no idea why. can anyone help me with it? heres my code

@bot.command()
async def ship(ctx, *, member):
  author_name=ctx.message.author.name
  responses = ['1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100']
  response = random.choice(responses)
  embed = discord.Embed(f'{author_name} + {member} = {response}% ![1heartring](https://cdn.discordapp.com/emojis/928268202536992768.webp?size=128 "1heartring")', color = 3092790)
  await ctx.send(embed=embed)```
#

i have an issue , im trying to make a ship cmd but it keeps giving me some sort of error. can any1 help? heres my code

quaint epoch
#

@slate swan

bright delta
#
@bot.command()
async def ship(ctx, *, member):
  author_name=ctx.message.author.name
  responses = ['1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100']
  response = random.choice(responses)
  embed = discord.Embed(f'{author_name} + {member} = {response}% ![1heartring](https://cdn.discordapp.com/emojis/928268202536992768.webp?size=128 "1heartring")', color = 3092790)
  await ctx.send(embed=embed)```
quaint epoch
#

did you get the spammers id

bright delta
#

this is the error thats giving me

keen talon
#

type ```
description = blah blah blah

Instead of just `blah blah blah`
bright delta
#

this is the error im getting TypeError: __init__() takes 1 positional argument but 2 were given

slate swan
#

that's some really unneficient code

#

doesn't look like it's a problem with your code though

dreamy sluice
#

I ran into an error with cogs, and I can't seem to understand (I am new to using cogs and classes in general, so yea)

Code:

class Presets(commands.Cog):
  async def check(self, member):
    id = str(member.id)
    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()
    if id not in read:
      read[id] = {"username": member, "iron": 0}
      r = open("stats.json", 'w')
      json.dump(read, r, indent=1)
      r.close()



class Economy(commands.Cog):
  def __init__(self, bot):
    self.bot = bot
  
  async def cog_check(self, ctx):
    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()
    if str(ctx.author.id) not in read:
      read[str(ctx.author.id)] = {"username": str(ctx.author), "iron": 0}
      r = open("stats.json", 'w')
      json.dump(read, r, indent=1)
      r.close()
    return True

  @commands.command(aliases=["balance"])
  async def bal(self, ctx, member:discord.Member=None):
    if member==None:
      member = ctx.author

    presets = self.bot.get_cog('Presets')
    await presets.check(member)

    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()

    if str(member.id) in read:
      balance = read[str(member.id)]["iron"]

      embed = discord.Embed(title=f"{member.name}'s Balance", description=f"{balance} Iron",color=ctx.author.color)
      
      await ctx.reply(embed=embed)
    else:
      await ctx.reply(f"{member.mention} isn't part of my economy yet :(")
slate swan
#

actually, I know what it might be

dreamy sluice
slate swan
#

color=0x3092790

bright delta
#

so 0x3092790?

slate swan
#

yep

#

try that

bright delta
#

im getting the same error

#

lemme try removing the color

slate swan
#

hunch was wrong then

bright delta
#

nvm same thing

slate swan
#

most likely something else

maiden fable
#

what happened

dreamy sluice
maiden fable
#

?

dreamy sluice
bright delta
#

wait wth

#

my discord was lagging so much

#

sorry i didnt mean to spam my error lmaooo

maiden fable
dreamy sluice
#

oof

maiden fable
bright delta
#

yeah like it showed my msgs were deleted instantly so i tried re-sending them

maiden fable
#

mhm

bright delta
#

im gonna try making it

#

non-embedded

#

oh my god

#

i messed up

slate swan
#

you really should just use the randint function

#

instead of picking from a list of numbers as strings KEKW

#

also

#

your list doesn't even work

#

because it's not properly formatted

bright delta
#

yeah i know i forgot to add '' to every single number

slate swan
#

yeah, you should just use randint instead my guy

#

number = str(random.randint(1,100))

bright delta
#

should i do import randint?

#

its already too late im halfway done

slate swan
#

no, you already have imported random

#

Just use random.randint(0, x).

#

randint is a function from the random stdlib

#

Only random is needed.

#

!e
import random
print(random.randint(0, 9999))

unkempt canyonBOT
#

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

6772
bright delta
#

oh i see

slate swan
#

Without code we sadly can't.

bright delta
#

well too late now. ive finished it already

dreamy sluice
#

@slate swan Do you know how I can make use of functions in cogs?

bright delta
#

ty tho will keep in mind

dreamy sluice
slate swan
#

wouldn't hurt to just change it anyway,

#

Simply make a file and import it in the cog.

bright delta
#

you can use my kick script if u want

@bot.command(case_insensitive=True)
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member=None, *, reason=None):
    await member.kick(reason=reason)
    embed = discord.Embed(description=f'{member.mention} was kicked', color = 3092790)
    await ctx.send(embed=embed)```
slate swan
#

your code will be way more efficient

dreamy sluice
dreamy sluice
slate swan
#

Yes?

dreamy sluice
slate swan
#

Just make a function in a file and import that file into your cog.

slate swan
#

Oh you mean, a function in a cog and use it outside.

dreamy sluice
slate swan
#

Just make it outside and use inside, better practice.

dreamy sluice
#

Hmm, lemme show what I want to do

bright delta
#

works now with embeds too

dreamy sluice
slate swan
#

pass_context is outdated, remove it.

#

Do you have a on_message event?

#

an*

slate swan
#

What is client defined as?

dreamy sluice
slate swan
dreamy sluice
slate swan
#

Maybe send the error you got ๐Ÿ˜…

dreamy sluice
#

I did, lemme reply to it

slate swan
#

yeah, upload the traceback on the paste service

slate swan
#

What is presets?

#

a class

dreamy sluice
bright delta
#

try this

@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def mute(ctx, member:discord.Member):
    role = discord.utils.get(ctx.guild.roles,id=929296185074778145)
    await member.add_roles(role)
    await ctx.send(f'{member} was muted')```
#

i guess

slate swan
#

pass_context has been deprecated

#

you can remove it without trouble

#

not that it changes anything

#

but, you know, it doesn't need to be there

#

Oh well as I said, make a separate file for these functions.

slate swan
bright delta
#

without pass_context

#

no i just tried to change the last thing

slate swan
#

Well you should get an error handler, otherwise the bot won't say anything when it doesn't have permissions.

#

You appended a Member object to a string.

#
"muted"+member
#

string+Member

#

You could've done str(member)

#

Or put it in an f-string, which does exactly the same.

bright delta
#

i usually just do python await ctx.send(f'{member} msg')

slate swan
#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

bright delta
#

wait

#

i fd up

#

ok done

karmic lintel
#

in say command cant we ignore after 3 words?

karmic lintel
slate swan
#

!pypi time-str

unkempt canyonBOT
slate swan
#

^^ u can use this too

karmic lintel
final iron
slate swan
unkempt canyonBOT
karmic lintel
# final iron What do you mean?

like i made a dc bot and i also made say command in it so whatever we say it repeats but i want that it should not repeat after 3 words

#

@slate swan

slate swan
karmic lintel
slate swan
#

dont mind me just bringing replit to its knees

slate swan
final iron
karmic lintel
final iron
slate swan
#

second

slate swan
karmic lintel
#

@slate swan pls improve this statement

@client.command(case_insensitive=True)
async def say(ctx,*,text):
    await ctx.send(text)
slate swan
#

split the text variable , i cant codefeed

slate swan
#

also

karmic lintel
final iron
#

He gave you an example, you have to implement it

slate swan
#

anyway, no offtopic here, use the ot channels

#

you can store around 40GB on replit

karmic lintel
dreamy sluice
karmic lintel
#

@final ironhelp me only once pls

#

\๐Ÿ˜ญ

final iron
karmic lintel
#

๐Ÿฅบ

#

ok

dreamy sluice
#

@slate swan Can you help me with my issue \w cogs?

slate swan
#

no, i'm taking a bath

karmic lintel
dreamy sluice
#

rip

unkempt canyonBOT
#

Joining Iterables

If you want to display a list (or some other iterable), you can write:

colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
    output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '

However, the separator is still added to the last element, and it is relatively slow.

A better solution is to use str.join.

colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'

An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.

integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
karmic lintel
dreamy sluice
slate swan
dreamy sluice
#

Okeh

#

Code:

class Presets(commands.Cog):
  async def check(self, member):
    id = str(member.id)
    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()
    if id not in read:
      read[id] = {"username": member, "iron": 0}
      r = open("stats.json", 'w')
      json.dump(read, r, indent=1)
      r.close()



class Economy(commands.Cog):
  def __init__(self, bot):
    self.bot = bot
  
  async def cog_check(self, ctx):
    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()
    if str(ctx.author.id) not in read:
      read[str(ctx.author.id)] = {"username": str(ctx.author), "iron": 0}
      r = open("stats.json", 'w')
      json.dump(read, r, indent=1)
      r.close()
    return True

  @commands.command(aliases=["balance"])
  async def bal(self, ctx, member:discord.Member=None):
    if member==None:
      member = ctx.author
    presets = self.bot.get_cog('Presets')
    if presets is not None:
      await presets.check()

      f = open("stats.json", 'r')
      read = json.load(f)
      f.close()

      if str(member.id) in read:
        balance = read[str(member.id)]["iron"]

        embed = discord.Embed(title=f"{member.name}'s Balance", description=f"{balance} Iron",color=ctx.author.color)
        
        await ctx.reply(embed=embed)
      else:
        await ctx.reply(f"{member.mention} isn't part of my economy yet :(")
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/runner/ElderTree-Bot/Cogs/EconomyCog.py", line 40, in bal
    await presets.check(member)
AttributeError: 'NoneType' object has no attribute 'check'
#

error^

#

@slate swan (sorry for pings btw)

slate swan
#

presets is None

dreamy sluice
#

Ye

#

Do you know what is wrong with my code or?

final iron
#

I wouldn't really recommend json as a db

dreamy sluice
final iron
dreamy sluice
#

What else do you recommend?

final iron
#

SQL

dreamy sluice
#

Hmm

final iron
#

It can be learned in less than 3 days

slate swan
#

you could just use a document type database

dreamy sluice
#

Lemme look

final iron
#

Implemented even faster

slate swan
#

it's the same data structure as json but it has a proper database handler

nimble plume
#

hi\

#

im having trouble in kick msg dm

nimble plume
final iron
#

How is knowing SQL common sense?

dreamy sluice
final iron
# dreamy sluice MySQL?

I would recommend sqlite3 but I don't know anything about databases. Thats just what I use and what I was recommended

final iron
#

Ask someone more experienced about those things

#

I don't know the pros and cons

nimble plume
dreamy sluice
nimble plume
#

Ez

dreamy sluice
nimble plume
#

Stack overflow GOD

dreamy sluice
#

no

#

stack overflow didn't help here

nimble plume
#

IT DIDNT help but IT GIVES idea of every single discord.py project u can imagine

#

just search!

#

๐Ÿ˜Ž

dreamy sluice
#

. _.

nimble plume
#

IDC im GOOd

dreamy sluice
#

You're very confusing, cool.

nimble plume
#

i just keep searching for that again and again if i didnt get!

dreamy sluice
nimble plume
#

and my last but not the least option is

dreamy sluice
#

and why is that better than just asking?

nimble plume
#

suspense begins

dreamy sluice
nimble plume
#

s ๐Ÿ’ฃ

๐Ÿš€

dreamy sluice
dreamy sluice
#

O-o

nimble plume
#

wait lemee open in vs code for better support

#

give full code json whats that json

#

@dreamy sluice give line 40 code

final iron
nimble plume
#

ur code and ur line didnt match i cant find mistake

karmic lintel
final iron
#

Why did you create a class that inherits from commands.Cog?

karmic lintel
#

โค๏ธ โค๏ธ

karmic lintel
#

โค๏ธ

final iron
#

Why not just make the function in your economy class? If you want to keep your code clean, just put it in a different file and import it

karmic lintel
#

@final ironthnx you too bro โค๏ธ โค๏ธ .... you both mde my night !!!

final iron
dreamy sluice
#

one second

#

@final iron
Code in Cog file

class Economy(commands.Cog):
  def __init__(self, bot):
    self.bot = bot
  
  async def cog_check(self, ctx):
    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()
    if str(ctx.author.id) not in read:
      read[str(ctx.author.id)] = {"username": str(ctx.author), "iron": 0}
      r = open("stats.json", 'w')
      json.dump(read, r, indent=1)
      r.close()
    return True

  @commands.command(aliases=["balance"])
  async def bal(self, ctx, member:discord.Member=None):
    if member==None:
      member = ctx.author
    #presets = self.bot.get_cog('Presets')
    #if presets is not None:
      #await presets.check()

    ps.check(member)
    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()

    if str(member.id) in read:
      balance = read[str(member.id)]["iron"]

      embed = discord.Embed(title=f"{member.name}'s Balance", description=f"{balance} Iron",color=ctx.author.color)
      
      await ctx.reply(embed=embed)
    else:
      await ctx.reply(f"{member.mention} isn't part of my economy yet :(")
#

Code in Presets.py

import json

def check(self, member):
    id = str(member.id)
    f = open("stats.json", 'r')
    read = json.load(f)
    f.close()
    if id not in read:
      read[id] = {"username": member, "iron": 0}
      r = open("stats.json", 'w')
      json.dump(read, r, indent=1)
      r.close()
#

Error

Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 979, in on_message
    await self.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
    await self.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
    await self.prepare(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 777, in prepare
    if not await self.can_run(ctx):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1078, in can_run
    ret = await discord.utils.maybe_coroutine(local_check, ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/utils.py", line 343, in maybe_coroutine
    return await value
  File "/home/runner/ElderTree-Bot/Cogs/EconomyCog.py", line 27, in cog_check
    read = json.load(f)
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 17 column 3 (char 329)
#

Imma use pastebin from next time onwards

#

Okeh

slate swan
dreamy sluice
#

oop-

final iron
#

I don't think you could do that with timeout

#

You will have to assign them a role with the restricted permissions

#

And of course add the appropriate checks

#

For adding a role?

#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

You can add the role then remove it

#

Or add the role and delete it

#

Give a better explanation of what you mean then

frank tartan
#

so how can i make it so when someone clicks a button, the message the button is attatched to gets deleted?

#

PLEASE PING WHEN TALKING TO ME

slate swan
#

hi

sweet pilot
#

well technically muting is temperary ยฏ_(ใƒ„)_/ยฏ

sweet pilot
#

well dw u'll get unmuted

dreamy sluice
slate swan
#

use the pydis pasting service

#

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

dreamy sluice
flat flower
flat flower
#

Hey, I can if you want. What do you have so far?

#

If you want I can give you what I built later today. If you can wait 3 hours or so I will give you the one I made

dreamy sluice
flat flower
#

I have a bot that has member commands, modmail, music, staff commands, and giveaways commands if you want it.

#

Itโ€™s one of my older bots, the code is simple but it works fine

#

Ok, if you need help with anything else feel free to ping me ๐Ÿ‘

sweet pilot
#

they just add a role and remove it

#

mee6 i mean

#

just like @final iron said

tough lance
#

Hi

maiden fable
#

Hi

frank tartan
#

so how can i make it so when someone clicks a button, the message the button is attatched to gets deleted?

slate swan
#

eh is it only in disnake

#

well the root symbol doesn't exist but

#

you can reference the disnake docs like that

honest shoal
#

in disnake for assets in activity, do we have to provide url for large/small image? I don't know what does this ID in docs mean

slate swan
#

im talking about the on_button_click event

slate swan
#

!d disnake.on_button_click

unkempt canyonBOT
#

disnake.on_button_click(interaction)```
Called when a button is clicked.

Warning

Consider using the callbacks associated with the [`View`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.View "disnake.ui.View") instead.

New in version 2.0.
slate swan
#

see?

slate swan
slate swan
#

discord.py doesn't have button support and never will

slate swan
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.
frank tartan
honest shoal
#

welp

frank tartan
quaint epoch
#

is there an event for message removal? like py @bot.event async def on_message_remove(message): #do stuff

slate swan
#

on_message_delete

quaint epoch
#

what arguments does it pass?

#

does it pass a message object?

slate swan
#

obviously

quaint epoch
#

alr

slate swan
#

weird, it's not a symbol

magic ore
slate swan
magic ore
#

!d discord.on_message_delete

unkempt canyonBOT
#

discord.on_message_delete(message)```
Called when a message is deleted. If the message is not found in the internal message cache, then this event will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_delete "discord.on_raw_message_delete") event instead.

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

of course i did

slate swan
tough lance
#

Hi

slate swan
frank tartan
unkempt canyonBOT
#

examples/views/button_roles.py line 29

async def callback(self, interaction: discord.Interaction):```
frank tartan
#

i just dont know how to delete the message..

slate swan
#

Interaction.message.delete() must be the thing but I'll double check it

maiden fable
#

That's a thing

#

iirc

#

!d disnake.MessageInteraction.message

slate swan
#
interaction : discord.Interaction
message = await interaction.original_message()
# delete the message
unkempt canyonBOT
maiden fable
#

Yea this returns the msg

slate swan
#

Yea but isn't MessageInteraction different from Interaction

#

!d discord.Interaction.message

unkempt canyonBOT
slate swan
#

ow that should work too

maiden fable
#

Btw

#

!d disnake.Interaction.delete_original_message already exists

unkempt canyonBOT
#

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

Deletes the original interaction response message.

This is a lower level interface to [`InteractionMessage.delete()`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionMessage.delete "disnake.InteractionMessage.delete") in case you do not want to fetch the message and save an HTTP request.
slate swan
#

WHOAAAAA Disnake's methods are always handy lol

maiden fable
#

Haha facts

#

!d discord.Interaction

unkempt canyonBOT
#

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

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

New in version 2.0.
maiden fable
#

O gotcha

#

!d discord.Interaction.guild_id imagine not returning the Guild instead ๐Ÿ˜

unkempt canyonBOT