#discord-bots

1 messages · Page 451 of 1

jagged aurora
#

does anyone know a working lastfm cog for discord.py

magic stump
compact eagle
#

What's kwarg

jagged aurora
#

I've tried a couple but they are usually for redbot or disco bot

#

and i want a cog that I can just use

full lily
#

!kwarg

#

hm that's not super helpful

kindred epoch
#

read the button structure

compact eagle
#

So if custom emojis are allowed in buttons, then i can create a very thin emoji that matches the background of discord, to align the buttons?

#

@kindred epoch

slate swan
#

It's hard to align buttons, they can vary from device to device.. Also once have a look at buttons in mobile lol

kindred epoch
#

the text inside the buttons is the reason

slate swan
#

also thin emoji is nothing.. discord allows emoji to take a particular area and it's almost fixed ig

analog ether
#

hi, how do i add charge as soon as a person joins my server?

analog ether
dire shadow
#

im making a command so i can send anon messages to my staff-chat to troll my friends but the replace() does not seems to work for some reason. Any idea why?

dire shadow
#

f string

full lily
#

hm is it because the slash is an escape char?

dire shadow
#

here is the full f string

slate swan
#

Replace the outer ' with "

full lily
#

what are the ` for?

slate swan
#

if i define more than one argument it says that the argument is missing, for example here "async def example(ctx, message):" it says "message is a required argument that is missing." even though it is there

full lily
dire shadow
full lily
slate swan
#

You only need one tho?

#

`hello`

dire shadow
full lily
#

try ...replace(r'g/staffchat', '')

slate swan
#

Ah must be bc I'm on mobile

slate swan
dire shadow
full lily
dire shadow
#

i think it worked

#

okok it worked, thanks a lot

full lily
#

be careful when you have / in a string

slate swan
# full lily yes

wait so why wouldn't it work though? sorry to bother just curious

full lily
daring locust
#

I guess that's how the font renders it

full lily
#

they have unicode representations I assume

somber musk
#

theres a error that says invalid syntax where it says Optional, useful function

slate swan
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
somber musk
#

so im not allowed to make a music bot?

plucky shoal
#

Please delete this message, as it contains tos breaking code this

plucky shoal
slate swan
slate swan
#

Also I believe using other apis is allowed

#

Like some official

somber musk
#

ok

#
if msg.content.startswith('!dm '):
    await message.channel.send("Dming user")
        dm = await message.author.create_dm()    
        await dm.send("What you want to send")```
#

it says unindent doesnt match any indentation level, for the if statement

#

help

slate swan
#

@somber musk this

somber musk
#

wut

hasty iron
#

an indentation error is the basic of the basics

#

if you can’t even solve that yourself, you should revisit python basics

bold dawn
#

Anyone have any idea why I keep getting this?

AttributeError: 'CommandInvokeError' object has no attribute 'channel'```
hasty iron
#

you’re probably using on_command_error which iirc ctx should be the first argument

#

and the second is the error

#

!d discord.on_command_error

unkempt canyonBOT
#

discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
hasty iron
#

yeah

bold dawn
#

Ahhh I’ll have a read. Thank you

wet chasm
#

how do i create a bot?

stoic flicker
#

can someone send me code to an economy bot

vale pendant
#

No, but you can code one yourself.

crisp pine
#

How Do I make the bot track server daily joins and messages?

kindred epoch
#

I would do it as weeks or month

crisp pine
#

What About Day?

kindred epoch
#

Average amount of joins and messages per week for month

#

Use datetime

#

!e
import datetime
print(datetime.datetime.day)

rapid pebble
#

if i save a await ctx.send into a variable, is there a way i can use that var to delete that specific msg?

crisp pine
#

I have datetime but how i make the command?

crisp pine
#
messagecounts = {}

@bot.command()
async def serverstats(ctx):
    embed=discord.Embed(title=f"Statystyki serwera {ctx.guild.name}")
    embed.add_field(name="Users:", value=ctx.guild.member_count, inline=False)
    embed.add_field(name="Channels:", value=len(ctx.guild.channels), inline=False)
    embed.add_field(name="Messages sent:", value=messagecounts[ctx.guild.id], inline=False)
    await ctx.send(embed=embed)```

had this and it does not work
rapid pebble
#

thanks

kindred epoch
rapid pebble
#

thank you

kindred epoch
#

If you don't, then learn that first before doing all this

crisp pine
#

what it has to do with data base..

#

@kindred epoch

slate swan
#

Because if your bot restarts all of your data is lost

#

The message count would be reset

#

Using a database is to keep storing it even if the bot dies

crisp pine
slate swan
#

Using SQL

high flame
#

is there an event when a channel is deleted?

slate swan
#

Or if u want a NoSQL database use MongoDB

high flame
#

ugh

#

please tell me there's an event for it blobpain

crisp pine
slate swan
high flame
#

nah

crisp pine
#

like whats its about

high flame
#

!d discord.on_guild_channel_update

unkempt canyonBOT
#

discord.on_guild_channel_update(before, after)```
Called whenever a guild channel is updated. e.g. changed name, topic, permissions.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
high flame
#

i dont think it will work for it

slate swan
slate swan
#

!d discord.on_guild_channel_delete

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
high flame
#

thanks!

slate swan
#
import discord
import random

TOKEN = ''
client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}' .format(client))

@client.event
async def on_message(message):
    username = str(message.author).split('#')[0]
    user_message = str(message.content)
    channel = str(message.channel.name)
    print(f'{username}: {user.message} ({channel})')

    if message.author  == client.user:
        return
    if message.channel.name == 'забавление':
        if user.message.lower() == 'zdr':
            await message.channel.send(f'zdr, {username}, az obicham jelqzo')
            return
        elif usermessage.lower() == 'kosta':
            await message.channel.send(f'nishto brat, pri teb')
            return
        elif user.message.lower() == 'na kolko si':
            response = f'az sam na {random.randrange(100)}'
            await message.channel.send(response)
            return

client.run(TOKEN)
#

it wont start

slate swan
slate swan
slate swan
#

Making a database and managing it is part of #databases btw, although i recommend TechWithTim's tutorial on MongoDB and python, it's really helpful and easy to understand

#

thats the eror

#
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\User\Downloads\DiscordBot\main.py", line 16, in on_message
    print(f'{username}: {user.message} ({channel})')
NameError: name 'user' is not defined
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\User\Downloads\DiscordBot\main.py", line 16, in on_message
    print(f'{username}: {user.message} ({channel})')
NameError: name 'user' is not defined
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\User\Downloads\DiscordBot\main.py", line 16, in on_message
    print(f'{username}: {user.message} ({channel})')
NameError: name 'user' is not defined
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event```
#

Read the error again

#

yes...

#

it says user not definded

#

Yup

#

And looking over your code you haven't defined user

#

how to defind it xD

#

user = message.author

#

Wait

#

im new

#

Why are u doing user.message

#

sorry for my fooling

#

What's that supposed to be

#

i watched it on yt

#

idk, im new and i dont know that

#

I can't help you if you don't know what user.message is supposed to be

crisp pine
empty quartz
#

Hello?

#

i have a question.

slate swan
empty quartz
#

what is wrong whit this

@bot.command()
async def poll(ctx,*,message):
emb=discord.Embed(title=" poll ", description=f"{message}")
msg=await ctx.channel.send(embed=emb)
await msg.add_reaction('👍')
await msg.add_reaction('👎')

slate swan
#

He'll show you the basics of connecting and working with mongodb with python

empty quartz
#

no.

slate swan
#

What's wrong then

empty quartz
#

my bot works.

#

but the poll is not.

slate swan
#

user.message is the discord message

#

That's message

#

Not user.message

#

To get the message's content you do message.content

empty quartz
covert igloo
#

can anyone guide me through using git

empty quartz
#

import discord
import os
from discord import embeds
from discord import message

from discord.ext import commands
bot = commands.Bot(command_prefix='?')

@bot.event
async def on_ready():
print(f'We have logged in as {bot}')

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

#

@bot.command()
async def poll(ctx,*,message):
emb=discord.Embed(title=" poll ", description=f"{message}")
msg=await ctx.channel.send(embed=emb)
await msg.add_reaction('👍')
await msg.add_reaction('👎')

#

so whats wrong whit it?

slate swan
#

Bc of your on_message

empty quartz
#

what do i do to it?

slate swan
#

Add await bot.process_commands(message) at the end of it

empty quartz
#

so

@bot.event
async def on_message(message):

#

await bot.process_commands(message)

#

like that?

crisp pine
#

@slate swan when i choose the middle one it brings me to payment

slate swan
#

Shared

#

Pick shared

crisp pine
#

And then press?

slate swan
crisp pine
#

ok i pressed it and it carry me to sum else

empty quartz
#

ok.

slate swan
crisp pine
#

"New clusters take between 1-3 minutes to provision"

slate swan
#

Yes

crisp pine
slate swan
#

Oh

#

Understandable

empty quartz
#

yes it works thx.

crisp pine
#

ima wait for it to load so ethier i dm you or text here

#

it loaded

empty quartz
#

but its not reacting?

cyan star
#

Are python bots any good?

slate swan
#

Wdym

slate swan
cyan star
empty quartz
#

i made it react

msg=await ctx.channel.send(embed=emb)
await msg.add_reaction('👍')
await msg.add_reaction('👎')

slate swan
#

Everything any bot can do

cyan star
empty quartz
#

its not doing it!

slate swan
#

It should add the reactions

#

It sends the embed right?

empty quartz
#

yes.

slate swan
#

Then idk what's wrong 😔

empty quartz
#

oh yay i fixed it!

slate swan
#

Gj

#
#purge command
@bot.command(pass_context=True, name="purge")
@commands.has_permissions(manage_messages=True)
async def purge(ctx, limit: int):
        await ctx.message.delete()
        await ctx.channel.purge(limit=limit)
        await ctx.send('Successfully Cleared {} messages'.format(ctx.author.mention))```
how can i change the `        await ctx.send('Successfully Cleared {} messages'.format(ctx.author.mention))` bit to say the number that they typed in?
empty quartz
#

thanks for helping.

slate swan
slate swan
covert igloo
#

what would cause my bot to be offline all through it says its on

#

on heroku

slate swan
#

you have to use a 3rd party lib or a fork

odd gorge
#

Hey, why do pings look like this when I'm pinging a leaving member?

blazing beacon
#

how do i publish a message using a bot

blazing beacon
odd gorge
odd gorge
blazing beacon
pliant gulch
unkempt canyonBOT
#

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

Publishes this message to your announcement channel.

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

If the message is not your own then the [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is also needed.
polar dirge
#

i have a config cmd which takes a bit to grab items from a db, so i want to send an embed saying loading then edit it to the new embed.

async def config(self, ctx)
      embed1=discord.Embed(description='**Loading...**')
      msg = await ctx.send(embed1)

       grab from db
      blah blah
      
      embed=discord.Embed()
      embed.add_field(name='stuff from db')

      await msg.edit(embed=embed)```

but it sends me <discord.embeds.Embed object at 0x000001EBC8DD1A60> as my first loading embed
covert igloo
#

if i was trying to make a trigger word in a cog

#

whats the decorator

visual island
#

*replying to the message above it

#

I dont think you need a decorator for that

covert igloo
#

it came back as an error Cog has no attribute 'listner'

visual island
#

should be listener

covert igloo
#

jesus bro i can spell 💀

visual island
#

@commands.Cog.listener

covert igloo
#

yea ik lmfao

#

@visual island now this sadge

visual island
#

self, message

covert igloo
covert igloo
visual island
#

!d discord.on_command

unkempt canyonBOT
#

discord.on_command(ctx)```
An event that is called when a command is found and is about to be invoked.

This event is called regardless of whether the command itself succeeds via error or completes.
visual island
polar dirge
#
        for i in data:
          member = self.client.get_member(i)
          print(member.name)```

`AttributeError: 'Bot' object has no attribute 'get_member'`
visual island
polar dirge
#

works thank you

#

what is the difference between member and user?

visual island
#

member is a guild specific user, while user is a discord user account

polar dirge
#

ah i see

#

thank you mm_hug

visual island
#

like I'm here as pydis member, while I'm a discord user too

polar dirge
crisp pine
#

how can i track daily messages?

dapper cobalt
unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
covert igloo
#

how do i add an emoji to a status, if it is possible

dapper cobalt
covert igloo
#

thats what i thought, just wanted to be sure

visual island
#

i think you can

visual island
dapper cobalt
#

I think he meant that emoji thing.

#

But if he means inside the status's content, yes you can, but only default emojis.

#

If you're on Windows 10 you can click win + period and a small thing will pop out which you can search for emojis with.

dapper cobalt
visual island
#

wait let me try

dapper cobalt
#

Wait you can.

#

If you give it the activity as a discord.CustomActivity.

#

!d discord.CustomActivity

unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.

`x == y` Checks if two activities are equal.

`x != y` Checks if two activities are not equal.

`hash(x)` Returns the activity’s hash.

`str(x)` Returns the custom status text.

New in version 1.3.
dapper cobalt
#

It has an emoji attribute.

visual island
#

um, how do i change my status potatopopcorn

dapper cobalt
#

!d discord.ext.commands.Bot.change_presence

unkempt canyonBOT
#

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

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
visual island
#

no, my status potatopopcorn

dapper cobalt
#

What?

visual island
#

not my bot

#

my user status

dapper cobalt
#

You already have a status tho..

#

potatowhat ?

visual island
covert igloo
dapper cobalt
#

Click on your avatar on bottom left.

visual island
#

i only found about me

#

oh

dapper cobalt
#

You never knew? potatocrycloseup

covert igloo
#

lol

visual island
#

i cant.. use custom emoji in my status potatothink?

dapper cobalt
#

But not in the content tho. Only the emoji.

visual island
dapper cobalt
#

@visual island Working on a

visual island
dapper cobalt
visual island
#

switched yea

hollow agate
#
async def on_message(message):
    guild1 = client.get_guild(884150367884025897)
    invites = await guild1.invites()
    for invite in invites:
        if invite.code == code:
            pass
    else:
        await message.delete()``` Is my code currently, I'm trying to make it to where it deletes all invites besides for invites from a certain guild... this code currently does nothing because I'm not sure what to add in the `if invite.code == code:` area.
lament mesa
#

You will have to take code as an input from the user

#

Use ext.commands that will make stuff a lot more easier

hollow agate
#

Could you explain a bit further, sorry

lament mesa
dapper cobalt
unkempt canyonBOT
#

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

Gets an [`Invite`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Invite "discord.Invite") from a discord.gg URL or ID.

Note

If the invite is for a guild you have not joined, the guild and channel attributes of the returned [`Invite`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Invite "discord.Invite") will be [`PartialInviteGuild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PartialInviteGuild "discord.PartialInviteGuild") and [`PartialInviteChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PartialInviteChannel "discord.PartialInviteChannel") respectively.
lament mesa
hollow agate
#

I see, kinda... I'm just not sure how to parse it

lament mesa
#

what do you want the prefix and the command name to be?

hollow agate
#

Does it need to be a command? I'm not sure if that'll allow me to block users from sending an invite and delete it instantly?

lament mesa
#

oh wait my bad i misread your question

#

you will need to parse the invite code the user sent

#

You can use regex

hollow agate
#

Eek, I've never used regex, this could be a challenge

lament mesa
#
import re

INVITE_RE = re.compile(
    r"(?:discord(?:[\.,]|dot)gg|"                     # Could be discord.gg/
    r"discord(?:[\.,]|dot)com(?:\/|slash)invite|"     # or discord.com/invite/
    r"discordapp(?:[\.,]|dot)com(?:\/|slash)invite|"  # or discordapp.com/invite/
    r"discord(?:[\.,]|dot)me|"                        # or discord.me
    r"discord(?:[\.,]|dot)li|"                        # or discord.li
    r"discord(?:[\.,]|dot)io"                         # or discord.io.
    r")(?:[\/]|slash)"                                # / or 'slash'
    r"([a-zA-Z0-9\-]+)",                              # the invite code itself
    flags=re.IGNORECASE
)```
hollow agate
#

Oh wonderful! py for invite in invites: if What would I place here then?

covert igloo
#

@visual island did i already ask u how i could make an error handle for this

covert igloo
#

pepeOK i am now

visual island
#

error handler?

#

on_command_error?

covert igloo
#

yes

lament mesa
covert igloo
#

its happens when a command is used with member @ but no reason

visual island
#
if isinstance(error, TypeError):
#

or you can do if reason is None *in the command

hollow agate
#
@client.event
async def on_message(message):
    guild1 = client.get_guild(884150367884025897)
    invites = await guild1.invites()
    INVITE_RE = re.compile(
        r"(?:discord(?:[\.,]|dot)gg|"
        r"discord(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discordapp(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discord(?:[\.,]|dot)me|"
        r"discord(?:[\.,]|dot)li|"
        r"discord(?:[\.,]|dot)io"
        r")(?:[\/]|slash)"
        r"([a-zA-Z0-9\-]+)",
        flags=re.IGNORECASE
    )
    codes = INVITE_RE.findall(message.content)
    for invite in invites:
        if invite.code == codes:
            return
        else:
            await message.delete()``` Would be everything, unless I'm missing something, right?
#

Yeah, that's definitely broken 😂 It's trying to spam delete the message- no bypass either at this time

lament mesa
#

You will have to do py guild_invites = tuple(map(lambda i: i.code, await guild1.invites())) for invite in codes: if invite not in guild_invites: await message.delete()

#

That should work

hollow agate
#

It does, thank you so much

lament mesa
#

👍

hollow agate
#
@client.event
async def on_message(message):
    guild1 = client.get_guild(764574130863079424)
    invites = await guild1.invites()
    guild_invites = tuple(map(lambda i: i.code, await guild1.invites()))
    INVITE_RE = re.compile(
        r"(?:discord(?:[\.,]|dot)gg|"
        r"discord(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discordapp(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discord(?:[\.,]|dot)me|"
        r"discord(?:[\.,]|dot)li|"
        r"discord(?:[\.,]|dot)io"
        r")(?:[\/]|slash)"
        r"([a-zA-Z0-9\-]+)",
        flags=re.IGNORECASE
    )
    codes = INVITE_RE.findall(message.content)
    for invite in codes:
        if invite not in guild_invites:
            await message.delete()
    await client.process_commands(message)``` One last thing, is there any possibility that I can make it "whitelist" certain guild id's invites if the bot isn't in the server?
lament mesa
#

you will have to store the whitelisted guild ids

hollow agate
#

guild1 = client.get_guild(764574130863079424) is a whitelisted guild id

lament mesa
#

is that the only whitelisted guild?

hollow agate
#

For now, yes - I'll add more eventually

pliant gulch
unkempt canyonBOT
#

discord.utils.resolve_invite(invite)```
Resolves an invite from a [`Invite`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Invite "discord.Invite"), URL or code.
pliant gulch
#

No real need to write all this regex yourself

lament mesa
hollow agate
#

Hmmm, using resolve_invite?

lament mesa
#

to get the guild id the invite leads to you will have to use client.fetch_invite

hollow agate
#
    pp = await client.fetch_invite(guild1)``` Okay, so this
#

What's the if statement determining if it's from that guild though?

lament mesa
#

you will have to do something like py for invite in codes: guild_id = (await bot.fetch_invite(invite)).id if guild_id not in whitelist: await message.delete()

lament mesa
spring flax
#

Why not check if guild id not in Whitelist first pikathink

lament mesa
#

isnt the if statement doing that?

#

if guild_id not in whitelist:

lament mesa
#

codes is a list

hollow agate
#
AttributeError: 'NoneType' object has no attribute 'invites'``` Error
#
@client.event
async def on_message(message):
    guild1 = client.get_guild(764574130863079424)
    invites = await guild1.invites()
    pp = await client.fetch_invite(guild1)
    whitelist = '764574130863079424'
    guild_invites = tuple(map(lambda i: i.code, await guild1.invites()))
    INVITE_RE = re.compile(
        r"(?:discord(?:[\.,]|dot)gg|"
        r"discord(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discordapp(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discord(?:[\.,]|dot)me|"
        r"discord(?:[\.,]|dot)li|"
        r"discord(?:[\.,]|dot)io"
        r")(?:[\/]|slash)"
        r"([a-zA-Z0-9\-]+)",
        flags=re.IGNORECASE
    )
    codes = INVITE_RE.findall(message.content)
    for invite in codes:
        guild_id = (await client.fetch_invite(invite)).id
        if guild_id not in whitelist:
            await message.delete()
    await client.process_commands(message)``` Unless I'm doing it wrong
vagrant brook
#

wrong id prob

kindred epoch
#

guild1 is None

lament mesa
hollow agate
lament mesa
#

whitelist = (764574130863079424,)

hollow agate
#

Ahh, that makes a lot more sense

#
    invites = await guild1.invites()
AttributeError: 'NoneType' object has no attribute 'invites'``````py
@client.event
async def on_message(message):
    guild1 = client.get_guild(764574130863079424)
    invites = await guild1.invites()
    pp = await client.fetch_invite(guild1)
    whitelist = (764574130863079424)
    INVITE_RE = re.compile(
        r"(?:discord(?:[\.,]|dot)gg|"
        r"discord(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discordapp(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discord(?:[\.,]|dot)me|"
        r"discord(?:[\.,]|dot)li|"
        r"discord(?:[\.,]|dot)io"
        r")(?:[\/]|slash)"
        r"([a-zA-Z0-9\-]+)",
        flags=re.IGNORECASE
    )
    codes = INVITE_RE.findall(message.content)
    for invite in codes:
        guild_id = (await client.fetch_invite(invite)).id
        if guild_id not in whitelist:
            await message.delete()
    await client.process_commands(message)```
#

Hmmm, I think we have the order of the for loop wrong

hollow agate
#

Right, right, I'm stupid 😂

#
@client.event
async def on_message(message):
    guild1 = client.get_guild(884150367884025897)
    whitelist = [884150367884025897]
    INVITE_RE = re.compile(
        r"(?:discord(?:[\.,]|dot)gg|"
        r"discord(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discordapp(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discord(?:[\.,]|dot)me|"
        r"discord(?:[\.,]|dot)li|"
        r"discord(?:[\.,]|dot)io"
        r")(?:[\/]|slash)"
        r"([a-zA-Z0-9\-]+)",
        flags=re.IGNORECASE
    )
    codes = INVITE_RE.findall(message.content)
    for invite in codes:
        guild_id = (await client.fetch_invite(invite)).id
        if guild_id not in whitelist:
            await message.delete()
    await client.process_commands(message)``` Now this is removing all the invites even the whitelisted server ones
#

No error ^^

vagrant brook
#

Try printing guild_id

lament mesa
hollow agate
#

It prints test if I used discord.gg/test

#

If I use an invite from the whitelisted server, it still deletes it and says the invite code I used

hollow agate
vagrant brook
#

(await client.fetch_invite(invite))

#

This returns an Invite object

#

not a Guild object, so you need to get the guild with invite.guild

hollow agate
vagrant brook
#

(await client.fetch_invite(invite)) is not a guild

#

Doing .id doesn't return the guild ID

#

However you can get the guild with (await client.fetch_invite(invite)).guild

hollow agate
#
@client.event
async def on_message(message):
    guild1 = client.get_guild(884150367884025897)
    whitelist = [884150367884025897]
    INVITE_RE = re.compile(
        r"(?:discord(?:[\.,]|dot)gg|"
        r"discord(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discordapp(?:[\.,]|dot)com(?:\/|slash)invite|"
        r"discord(?:[\.,]|dot)me|"
        r"discord(?:[\.,]|dot)li|"
        r"discord(?:[\.,]|dot)io"
        r")(?:[\/]|slash)"
        r"([a-zA-Z0-9\-]+)",
        flags=re.IGNORECASE
    )
    codes = INVITE_RE.findall(message.content)
    for invite in codes:
        guild_id = (await client.fetch_invite(invite)).guild
        if guild_id not in whitelist:
            await message.delete()
    await client.process_commands(message)``` This still deletes all of the invite codes, so sorry if I read it wrong
vagrant brook
#

guild_id would be a discord.Guild object, not an ID

#

So that doesn't work

#

Try to figure out how to make it work on your own

hollow agate
#

Isn't guild_id the thing that you said that it would work with, no?

vagrant brook
#

I didn't say that it is going to be the guild id

hollow agate
#

guild_id = (await client.fetch_invite(invite)).guild this, not like the actual guild_id

lament mesa
vagrant brook
#

try printing it out

hollow agate
#

Ah, true

vagrant brook
#

To see what it actually is

hollow agate
#

The hecc, it prints TEST Squadron with discord.gg/test very weird

#

OH! That's the guild name wait

lament mesa
#

guild_id = getattr((await client.fetch_invite(invite)).guild, "id", None)

sweet pilot
#

how can I overwrite a cog or command?

hollow agate
#

Oh my, thank you so much, Rush!

vagrant brook
#

Why spoonfeed smh

heavy folio
#

how do i make a command cooldown

crisp pine
#

Is it possible for a steal emoji command?

silver wolf
unkempt canyonBOT
#

discord.ext.commands.cooldown(rate, per, type=<BucketType.default: 0>)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.on_command_error "discord.on_command_error") and the local error handler.

A command can only have a single cooldown.
lament mesa
heavy folio
#

ty

oak quest
#

for like a leveling system how would i set it up like do i just add the user and the guildto the database
and in on_message add +1 to the point for the user in the database,
and after that i check if t he user reached the specific number send an level up message

is this wrong ? i came up with this just right now

tough lance
#

Its good

#

You can also check if the user is spamming for more precision

#

or add exp randomly

slate swan
#

anyone wanna collab in my bots rewrite?

oak quest
slate swan
#

looool

#

its a fun project that id maintain for long i think

#

itll be my only bot

oak quest
#

what are you trying to do ?

slate swan
#

economy

#

i have coded over 1.5k lines before in the old version

oak quest
#

my english is bad so i don't know what that word kidna means

slate swan
#

but yeah since almost everything needs rewrite id do it

oak quest
#

are you rewriting because of slash commands ?

slate swan
#

so id rewrite over all of them again

#

into a new one

oak quest
slate swan
oak quest
#

it has slash commands, its written so that it turn the normal commands to slash commands

oak quest
slate swan
#

so do you wanna collab?

oak quest
#

kinda but like i don't have the idea

#

you need to tell me what you REALLY want

slate swan
#

just a person that helps me rewriting it

#

ill also give you the github repo of the old bot

#

its messy trust me

oak quest
silver wolf
slate swan
#

its private rn

oak quest
#

my problem right now with you is like, i don't know how to do economy stuff, you need you explain and give me the idea, and how you want it

#

sorry if that was rude

slate swan
#

so id use mongodb for the data (user data) and json files for the rest of the stuff that is long

#

idk how to describe

#

no idea

#

but i use json for it

#

idfk man :(

oak quest
#

i don't know mongodb, cause i heard it's kinda bad for json stuff, i prefer postgresql, and by explaining, i mean like explain the commands

slate swan
#

i have no budget for hosting postgresql and my pc has no space for self hosting postgresql

oak quest
#

wdym space ?

slate swan
#

storage

#

on my pc

oak quest
#

you don't need storage for postgresql server i think

slate swan
#

wdym

#

doesnt it store the data on your computer

oak quest
#

no ? i don't think so

#

it's called a database, not a pcbase, afaik

slate swan
#

thatd be good but i dont really think so, its too good to believe lol

#

free, no storing on pc, too good to believe

oak quest
#

what do you think mongodb does ? :/

slate swan
#

uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

btw im in online class rn sorry

#

dm me if u wanna collab

oak quest
#

ok

slate swan
#

i can code in afternoon (like 3 to 5 hours later)

oak quest
#

me myself might make some economy commands as well

#

i will explain the postgresql to you as well

slate swan
#

what time is it for u

#

i need your time to determine if our timezone is perfect

oak quest
#

8:34 am 🤣

slate swan
#

ooh

oak quest
#

but i'm awake till 6:00 pm

slate swan
#

not far away

slate swan
#

so you cant code after 6pm?

oak quest
#

no like i'm awake,

#

i'm not sleeping at that time

slate swan
#

why do you sleep at 6pm

#

just curious

oak quest
#

i don't sleep at that time

slate swan
#

but you said it

round quarry
#

What do I need to install to configure the bot?

oak quest
#

i can't write that word facepalm

slate swan
#

How to get resent message.content from a channel by name

oak quest
slate swan
#

Channel name

oak quest
slate swan
#

Channel name fixed need to get message.content and store it as a variable

oak quest
#

do await ctx.send(F"{ctx.channel.name} - {ctx.message.content}") i think

slate swan
#

@oak quest

oak quest
round quarry
oak quest
#

have you ever installed any packages ?

slate swan
#

But it is not correct need to store message.content from a channel and make it as variable and process it

oak quest
slate swan
#

Making an command

#

@oak quest

oak quest
#

don't ping me

slate swan
#

Ok

round quarry
oak quest
slate swan
#

See the code I had done so far

#
@client.event
async def on_message(message):

    if message.channel.name == "to rmb":
      messages = await channel.history(limit=1).flatten      print(messages)
      ```
#

@oak quest

oak quest
#

DON"T PING ME

slate swan
#

Ok

oak quest
#

and this is an event not command

slate swan
#

Is it correct

oak quest
#

i don't know wtf is this await channel.history(limit=1).flatten print(messages)

slate swan
lament mesa
slate swan
#

Ok

oak quest
#

do channel message.channel ?

slate swan
#
@client.event
async def on_message(message):

    if message.channel.name == "to rmb":
      messages = channel.last_message
      print(messages)```
#

This code not working

slate swan
#

No error no response

oak quest
slate swan
#

Whre

slate swan
oak quest
oak quest
#

do you now know what to do ?

slate swan
#

Want to get recent message from channel to-rmb and print

spring flax
#

Look at the code and check if you defined channel

thorny pagoda
#

i thought discord.py was discontinued i switched to js lmfao

slate swan
#

Defined by line 3 is it not

thorny pagoda
#

oh

spring flax
oak quest
thorny pagoda
spring flax
#

you never did channel = so how did you define channel?

oak quest
#

use edpy cause they even have slash commadns

thorny pagoda
#

theyre forks?

oak quest
slate swan
oak quest
slate swan
#

@spring flax

spring flax
#

okay and?

oak quest
#

it's easy python

#

people can't just spoonfeed you

#

learn python first than dpy

thorny pagoda
#

what happened to ctx.send

#

and stuff

#

y they gotta do on message

spring flax
#

!resources @slate swan

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

thorny pagoda
#

yh ik but why tho

spring flax
#

you don't have ctx in an on_message event

thorny pagoda
#

cant you do this

#

ohhh wait

spring flax
#

wait

thorny pagoda
#

wait yeah he can

spring flax
#

okay well no that is not what he wants

oak quest
thorny pagoda
#

well what is he trying to do

oak quest
thorny pagoda
#

yh ik i switched so kinda weird

slate swan
#

Trying to get message.content from a channel

thorny pagoda
#

like printing the content of every message sent in a channel?

oak quest
#

you still haven't seen it ?

#
@client.event
async def on_message(message):

    if message.channel.name == "to rmb":
      messages = channel.last_message
      print(messages)```
error = channel not defined
oak quest
oak quest
thorny pagoda
#

message.channel.last_message

oak quest
thorny pagoda
#

i'm back

proper acorn
#

I just make a bot

#

How to add my bot in a sever

#

Teach me pls

proud shoal
#

how do I make a bot send a dm to a user who joins the server

proper acorn
#

Omg tys?!

stark bobcat
#

and

#

await ctx.user.send

rich valve
#

Which library do you use for discord bot

proud shoal
#

tyy

proud shoal
rich valve
shy schooner
#

it takes member arg

#

you can do member.send('stuff')

stark bobcat
#

ohh mb

proper acorn
#

Where select bot?

stark bobcat
#

member.send

#

@proud shoal member.send btw

proud shoal
#

o ok

proper acorn
#

@tawdry perch i enable all :)

#

OMG TYSSM

#

TYSM

#

I GOT IT

#

@tawdry perch

#

Im using python

#

Can you teach me

#

Or give me

#

A code to

rich valve
proper acorn
#

Do the command

#

'(

#

If user send !rickroll
My bot do a rickroll gif

#

Can you give me code to do it?

#

Cuz it discontinue

thorny pagoda
#

what did u learn then

proper acorn
#

I only know some

hollow agate
#

Do you have any knowledge of python? It's pretty simple of what you're trying to do

proper acorn
#

Ex: @client.event
@bot.event

thorny pagoda
#

...

hollow agate
thorny pagoda
#

you should watch a tutorial my friend

#

why?

halcyon folio
#

outdated code

thorny pagoda
#

eh ig

slate swan
#

should i use heroku's postgresql? just wanna know if there are any limits or bad things before i start using it

halcyon folio
#

heroku is bad for hosting

hollow agate
#

if coucil or creator in interaction.user.roles: how can I make it check if the user has either one of those roles? Right now it requires the user to have both.

shy schooner
thorny pagoda
#

true

proper acorn
#

:(

thorny pagoda
#

what have you made in python @tawdry perch

#

like what kinda bots

#

im rewriting my economy bot to js :p i am a noob xd

rich valve
#

nodejs?

thorny pagoda
#

yea im making an economy bot in d.js

#

tbh ive been loving it more than python

hollow agate
hollow agate
halcyon folio
#

interaction.user.roles returns a list of roles right

hollow agate
#

I believe so

halcyon folio
#

so you just do the normal way

#

if something in list and the other thing in list:

#

pretty sure theres no shortcut

proper acorn
#

@tawdry perch i learned python

vocal plover
halcyon folio
#

theres probably gonna be a decent fork

vocal plover
#

It hasnt been taken down, and there are maintained forks

halcyon folio
#

theres already a fork that im looking forward too and it kind of works lol

vocal plover
#

which one 👁️

#

nothing

hollow agate
#

I just need the user to have one

vocal plover
#

I was a project lead for a while

halcyon folio
#

instead of and

vocal plover
hollow agate
#

Still requires both

hollow agate
#

It's for a button

vocal plover
#

ahh

hollow agate
#
class TicketClose(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
    
    @discord.ui.button(emoji='🔒', style=discord.ButtonStyle.gray, custom_id='ticketclose')
    async def ticketclose(self, button: discord.ui.Button, interaction: discord.Interaction):
        coucil = discord.utils.get(interaction.guild.roles,name='The Coucil')
        creator = discord.utils.get(interaction.guild.roles,name='The Creator')

        if coucil in interaction.user.roles or creator in interaction.user.roles:```
halcyon folio
#

huh did you rerun your bot

hollow agate
halcyon folio
#

then idk cause it looks fine to me

thorny pagoda
#

tu is on mobile

halcyon folio
#

ouch

maiden fable
#

Well, for me. I am moving to disnake haha

thorny pagoda
#

i kinda feel bad tbh

vale pendant
maiden fable
vocal plover
#

I'm tempted to set up some sort of discord bot hosting service

thorny pagoda
#

i thought alot of the discord.py people switched to d.js but ig not

maiden fable
#

Hmm

maiden fable
hollow agate
#

It might be an error with buttons then?

visual island
#

wait

halcyon folio
vocal plover
maiden fable
thorny pagoda
maiden fable
hollow agate
#

I spelt something wrong aha

vocal plover
#

I wonder if you can connect to discord via IPv6

thorny pagoda
#

oh it doesnt exist

#

i was happy for a second there

vocal plover
#

last i remember discord still wasnt using ipv6 which is annoying

#
vcokltfre@antares ~ $ dig -6 discord.com

; <<>> DiG 9.16.1-Ubuntu <<>> -6 discord.com
;; global options: +cmd
;; connection timed out; no servers could be reached
```pain
thorny pagoda
#

what even is mod mail

#

never used it

vocal plover
#

I'm actually making a thing with modmail currently

#

Modmail as a service

slate swan
#

guys, are rows limit a problem?

#

heroku offers me 10k rows

vocal plover
#

it depends

#

are you gonna use more than 10k rows?

slate swan
#

idk

#

so it counts the total rows i use right

hollow agate
#

Is there a way to get the first message ever in a specific channel?

vocal plover
#

modmail...?

vocal plover
#

you go on the website, buy a subscription, and voila hosted modmail

#

with your own log viewer/etc.

thorny pagoda
#

add the premium pateron features?

maiden fable
#

Alec becoming the next millionaire

vocal plover
slate swan
thorny pagoda
slate swan
#

for an users id, will i use a row or a column? i cant differ these 2

#

so if i get a 10k rows limit will i be able to store 10k users or something

vocal plover
#

I've been learning CSS, so my plan is to as closely as possible recreate discord messages in the browser for logs

hollow agate
#
    @discord.ui.button(emoji='🔒', style=discord.ButtonStyle.gray, custom_id='ticketclose')
    async def ticketclose(self, button: discord.ui.Button, interaction: discord.Interaction):

        await interaction.channel.history(oldest_first=True, limit=1).flatten()``` Okay so, how could I filter out the mention and get the mentioned user's ID using the `channel.history(oldest_first)`?
vocal plover
#

doesnt work for me either

hollow agate
#

Ehh, I would have to rewrite hundreds of lines of code because I need to store the channel id too

#

I think the history would work best in this instance

hollow agate
vocal plover
#

yes

slate swan
maiden fable
hollow agate
#

How could I yoink the mentioned user's ID out of the message then?

maiden fable
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

slate swan
#

A database?

hollow agate
#

Sorry, just I don't see any way of using it 😅

maiden fable
coral flame
hollow agate
#

Hmmm- super confused. I'll try a few things though :)

maiden fable
slate swan
#

await interaction.channel.history(oldest_first=True, limit=1).flatten() returns a list of discord.Message like [Message1, Message2, ...]
Since you are only requesting one, it'll be like [Message], index it to 0 to get the first message object.
Then use .mentions on it, which will again return a List of Member/User objects, like [Member1, Member2], and index it again

hollow agate
#

Oh jeez, that made my brain even more confused 😂

slate swan
maiden fable
#

Haha

#

Look @hollow agate, I know sometimes it can be too much. You should think about it yourself

hollow agate
#

xD yeah for sure, I'm gonna try to break it down

#

So, what is index used for? I've rarely used it and I don't understand what it'll do in this instance.

coral flame
#

getting an item in a list

coral flame
round quarry
#

Can I make a command in which only a certain person can use it?

coral flame
#

yeah, just check id. if its invalid, return

slate swan
hollow agate
#

interaction.mentions[0].id is a start?

pale turtle
hollow agate
#

author = interaction.mentions[0].id possibly maybe unless I'm not understanding it

vale pendant
#

Is there a get_category method?

lament mesa
#

no

round quarry
serene lynx
#

how to check if nick already exists in ctx.guild?

vale pendant
#

Damn.

lament mesa
slate swan
serene lynx
# serene lynx how to check if nick already exists in ctx.guild?
@slash.slash(description='to change nickname')
async def changenick(ctx: SlashContext, member: Member, *, nick):
    embed = mbed(
        description=f"**Information :**\n```\nAuthor : {ctx.author}\nUser : {member}\nNickname : {nick}```", color=ctx.author.colour,)
    embed.set_author(name=f'Change Username',
                     icon_url=str(member.avatar_url))
    embed.set_footer(text=f'command used by : {ctx.author}',
                     icon_url=str(ctx.author.avatar_url))
    if nick == member.display_name:
        await ctx.send('username must different')

    else:
        try:
            if ctx.author.guild_permissions.administrator:
                user_nick = ctx.guild.members
                if nick in user_nick.nick:
                    await ctx.send('nick already exists')
                    return

                await member.edit(nick=nick)
                await ctx.send(embed=embed)

            else:
                await ctx.send('you are missing permissions')

        except discord.errors.Forbidden:
            await ctx.send(f'{ctx.author.mention}, @hallow urchin missing permissions')

        except Exception as e:
            print(e)
            await ctx.send(e)
            e = sys.exc_info()
            print(e)```
coral flame
vale pendant
#

Ahhhh, Thanks to you both!

hollow agate
#

Basically just message.mention[0].id

slate swan
coral flame
hollow agate
#

Yep, it doesn't lol

coral flame
#

nice, what is it?

serene lynx
#

how to check if nick already exists in ctx.guild?

round quarry
#

Oh, thanks

coral flame
#

very nice

lament depotBOT
#
**What feature would you be the most interested in making?**

Suggest more topics here!

hollow agate
#

I'll return to my issue later, my brain hurts 😂

serene lynx
maiden fable
coral flame
#

maybe

serene lynx
slate swan
serene lynx
coral flame
#

.nick

serene lynx
#

okey i try

coral flame
#

!d discord.Member.nick

unkempt canyonBOT
broken turtle
#

for any of you who doesnt know how to code an unban command found this online. tested and works

@bot.command(name='unban')
@commands.has_permissions(ban_members = True)
async def unban(ctx, id: int):
    user = await bot.fetch_user(id)
    await ctx.guild.unban(user)
#

could replace name='unban' with aliases if need be

slate swan
#

A better way would be making a discord.Object instead, saves an API call

broken turtle
#

now i want to code it so the bot sends a messages when soemone has been baned

#

but idk how

slate swan
#

!d discord.on_member_ban

unkempt canyonBOT
#

discord.on_member_ban(guild, user)```
Called when user gets banned from a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").

This requires [`Intents.bans`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.bans "discord.Intents.bans") to be enabled.
broken turtle
#
intents = discord.Intents.default()

this a good placeholder?

serene lynx
coral flame
#

is it bad to use Intents.all()?

slate swan
#

Depends, it consumes more memory if you have all enabled

#

If you don't need any intent, just disable it

#

Especially Presence Intent notlikeblob it takes a lot of memory and most of the time you don't need it

broken turtle
#

i have presence enbaled A_omg

proper acorn
broken turtle
#

hey so im heree for discord bots

spring flax
broken turtle
slate swan
#

Intent allows the gateway to receive others presence data too

broken turtle
#
@bot.command()
async def funhelp(ctx):
    channel = ctx.message.channel
    embed = discord.Embed(
        title = 'Economy bot commands do ~help',
        colour = discord.Color.blue()

    )

    embed.set_thumbnail(url= r'https://i.pinimg.com/originals/65/b1/ef/65b1ef4ae4a802082e0956e7848e953b.gif')
    embed.set_author(name= f"You have done .funhelp")
    embed.add_field(name='Fun Commands', value= '.dailyastronomy, .hug, .kiss, .slap, .spit, .coinflip, .fortune', inline=True)
    embed.add_field(name='Important Commands', value= '.version, .funhelp, .welcome', inline=True)
    embed.add_field(name='Custom Commsands', value='.w, .l, .f, .taco, .cringe, .fish, .ayoo, .gay', inline=True)
    embed.add_field(name='Economy', value='.balance, .deposit, .get, .send, .slots, .shop, .sell, .buy, .rob, .beg', inline=True)
    embed.add_field(name='Moderation', value= 'MODS ONLY: Do .modhelp', inline=True)
    await ctx.send(embed=embed)

Worked jsut fine before i added the last field

#

visable confuusion

spring flax
#

indents

#

can you put your code here

#

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

drifting venture
#

W

#

who tryna make me a nuke bot

slate swan
drifting venture
#

💀

spring flax
#

!rule 5

unkempt canyonBOT
#

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

spring flax
#

bruh

covert igloo
#

why do i get this error

maiden fable
#

<@&831776746206265384>

slate swan
spring flax
#

welp was going to double ping

slate swan
#

spelled incorrectly

spring flax
#

Lol

drifting venture
covert igloo
#

oh my god.

#

imma kms

spring flax
#

bruh

lone aurora
#
@client.event 
async def on_command_error(ctx, error): 
    if isinstance(error, commands.CommandNotFound): 
        em = discord.Embed(title=f"Error!!!", description=f"Command not found. Try using **.cmds**", color=ctx.author.colour) 
        await ctx.send(embed=em)``` what do i add so that it deletes the message which includes the non existing command
#

diabolical is alive

coral flame
#

ummmm

vale pendant
deep sorrel
#

!ban 784074403871719484 Racism

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @drifting venture permanently.

lament mesa
maiden fable
#

Thanks :D

heavy folio
#

so i have a command where each time someone runs it it increases by 1

lone aurora
coral flame
#

very lovely

heavy folio
#

e.g. i run !hi and the bot will say cmd ran by 1 person and when another person does the command bot would add on by one and say cmd ran by 2 people

#

and when my bot restarts it wont reset the count

lament mesa
#

save the count in a db

heavy folio
#

i dont have a db + its just a bot for 1 server

lament mesa
#

the server count doesnt matter

#

use sqlite

slate swan
#

Use a local db like sqlite

lament mesa
slate swan
#

Is there a help channel dedicated to docker related stuff? notlikeblob

spring flax
#

help channel?

slate swan
#

Yes

#

Like this

#

Idk what channel does this topic belongs to

spring flax
#

i mean you can ask there ig

slate swan
#

Ah yea, I forget about that lol

#

Thanks

heavy folio
#

could i use json i know it aint good but could i

slate swan
#

What's devops rooThink nvm off topic

lament mesa
lament mesa
spring flax
#

you can use sqlite

#

and use the auto-increment feature

lament mesa
heavy folio
heavy folio
#

any other ways tho?

lament mesa
#

Scaling is the process of increasing or decreasing the capacity of the system by changing the number of processes available to service requests

vocal plover
silver wolf
#

How much does a database cost nowadays? For like 1 guild with a couple thousand members

lament mesa
#

free

vocal plover
#

Yeah, my database has about ~550k user records and uses about 200MB of disk space and 0.1% CPU, so given the server cost $5 a month... basically zero

slate swan
#

Is using redis in a discord bot any good? Like I don't think a bot needs so fast handling of cache.. rooThink
Any advantage of using it?

#

Should be enough, also apply constraints like NOT NULL to prevent improper data

lament mesa
#

and maybe a unique constraint also

slate swan
#

Unique is.. I don't think their model can have anything in unique rooThink Like with 1 guild id, there can be multiple tickets

lament mesa
slate swan
#

Uh what's channel_id btw?

#

Dms are itself channels in modmail fl_panik

#

Oh okay

#

Yes it'll be unique

lone aurora
#

can i make it so that each command needs a specific permission?

#

eh

slate swan
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
lone aurora
#
@client.command()
async def modcmds(ctx):
    if (ctx.author.guild_permissions.view_audit_log):
        embed = discord.Embed(
        title = '',
        description = '',
        colour = ctx.author.colour
        
    )

    embed.set_footer(text='By oSeatch#6969')
    embed.set_author(name=ctx.message.author)
    embed.add_field(name='Mod Commands', value='__mute__ , __kick__ , __ban__ , __unmute__ , __purge__', inline=False)

    await ctx.send(embed=embed)

    elif (not ctx.author.guild_permissions_view_audit_log):
        await ctx.send("This command requires a higher rank!")``` eh i tried this but the elif breaks
#

anyone know what im doing wrong at elif?

slate swan
#
@client.command(administrator = True)
async def ticketsetupp(ctx, *, message):
    if message is None:
        return await ctx.send("please add a description for your ticket")
    tick = discord.Embed(title= f"{ctx.guild.name}", description = message, color = 0x01BDFE)``` can anyone help me ? the if messsage doesnt work
hasty iron
lone aurora
#

yea thats correct though

limber mountain
#

still can you help

slate swan
hasty iron
#

mobile sucks and my brain too

lone aurora
lone aurora
lone aurora
#

if i remove the elif, it works, it doesn't show the msg

hasty iron
#

it’s throwing AttributeErrror

lone aurora
#

still not working

slate swan
#
@bot.command()
async def invite(ctx):
    embed = discord.embeds(color=0x2983c7,)
    embed.add_field(name="INVITE:", value="[click here to invite the bot:](https://discord.com/api/oauth2/authorize?client_id=)")
    await ctx.send(embed=embed)```
hasty iron
#

what is "not working"

lone aurora
#

it just shows an error

hasty iron
#

ok then send the error?

slate swan
lone aurora
#

same as before

slate swan
#

im dumb lol

hasty iron
#

indents are basic

#

if you can’t even fix that

#

return to the basics

lament mesa
#

!indent

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

lone aurora
#

i still dont get whats wrong in it..

hasty iron
#

reload your window

lone aurora
#

if i remove this

    elif (not ctx.guild.permissions.view_audit_logs):
        await ctx.send("This command requires a higher rank")``` it gets fixed
reef shell
#

why are you using those parenthesis after elif

pale turtle
#

I want to make an API request right after the bot logs in, any idea how?

lament mesa
#

do it in on_connect

#

!d discord.on_connect

unkempt canyonBOT
#

discord.on_connect()```
Called when the client has successfully connected to Discord. This is not the same as the client being fully prepared, see [`on_ready()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_ready "discord.on_ready") for that.

The warnings on [`on_ready()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_ready "discord.on_ready") also apply.
lone aurora
#

do i do then

hasty iron
#

you can override start and do it inside of there

reef shell
#

elif condition:

#

not
elif (condition):

slate swan
#

Do commands.Group follows same structure as commands.Command since it inherits from the latter..
Can I use same kwargs as I do in a command?

reef shell
#

yes afaik

slate swan
#

Since a lot of them are missing in the docs in the group but is there in command

#

Ah yes docs have this mentioned too, didn't notice

lone aurora
#

na still the same

#

pain

slate swan
#

Im trying to do banned words system with .db.
How do i check the words
My code:

banned_words = await self.db.execute("Select Count(*) from blwords guild_id=? and words = ?", (guild_id, words))
hasty iron
pale turtle
boreal ravine
lament mesa
slate swan
#

ik. I mean how do i get the words from the db

#

yea

lone aurora
#

i mean if u dont have the perm, it doesnt show the msg, i just wanted to make it so that if u dont have perm it shows that you need a higher rank

slate swan
#

no

pale turtle
#

Like to subclass Bot and all that

#

on_connect can be called only once per-session right? Unlike on_ready

slate swan
#

yea

#

Ok. thx (idk .db that much)

#

ik some sql

scenic lark
#

Hello, is there a way to ban members who are already in a guild with less than 5 days old? this is my code but it keeps on giving me error "ban() missing 1 required positional argument: 'member'"

code:

@tasks.loop(seconds=5)
async def ban(member):
    for member in client.guilds:
        created_at = (datetime.datetime.now() - member.created_at)
        created_at = (datetime.datetime.now() - datetime.timedelta(days=5))
        if created_at < days:
            await member.send("You were banned for being a possible raider, if that is not the case please join the ban appeal server: ")
            await member.ban(reason="Possibly a raider account age is {} days old".format(str(created_at)))```
#

discord.Member right?

#

wdym?

#

oh yikes

slate swan
#

And why would you loop when you could just do it when they join the server

scenic lark
agile goblet
#

Show where you are calling the loop

slate swan
#

Then just do a command instead of a loop and move to on_member_join so you ban them when they join

scenic lark
#

oh yeah I did not think of that lol thanks

slate swan
#

And you redefined created_at so it won't be the member's creation date that you'll be comparing

valid patio
#

can i make this better ?

    quote = get_quote()
    await message.channel.send('Hello')```
valid patio
#

how to ?

valid patio
spring flax
#
#some imports
import discord
from discord.ext import commands

@bot.command(name="name here if you want a different one than the function name", description="describe it here", hidden=False) #set hidden to True to hide it in the help
async def mycommand(ctx, argument1, argument2):
    '''A longer description of the command
    
    Usage example:
    !mycommand hi 1
    '''
    await ctx.send(f"Got {argument1} and {argument2}")```
Example
valid patio
#

ok thanku

errant laurel
#

How can i make my bot online

spring flax
#

run the bot

valid patio
spring flax
#

!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/stable/ext/commands/api.html#discord.ext.commands.Bot.start "discord.ext.commands.Bot.start") coroutine or [`connect()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.connect "discord.ext.commands.Bot.connect") + [`login()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login").

Roughly Equivalent to...
spring flax
slate swan
#

if i do the command to add words, only the first word i add to the db is working

#

Yes. I have a command for it

#

look

#

i guess the on_message eventt

#

yea

#
    @commands.Cog.listener()
    async def on_message(self, msg):
        rows = await self.db.execute("SELECT words FROM blwords WHERE ? = guild_id", (msg.guild.id,))
        data = await rows.fetchone()
        for word in data:
            if word in msg.content:
                await msg.delete()
                await msg.channel.send("Stop swearing!")
#
    @commands.command(aliases=["addblwords"])
    @chp(administrator=True)
    async def addblacklistwords(self, ctx, *, word = None):
        if word is None:
            await ctx.send("Please provide a word")
            return
        
        await self.db.execute("INSERT INTO blwords (guild_id, words) VALUES (?, ?)", (ctx.guild.id, word))
        await ctx.send(f"The word {word} added to blacklist")
        await self.db.commit()
slate swan
#

thats the problem

#

im getting error

#
Traceback (most recent call last):
  File "C:\Users\eyal2\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\eyal2\OneDrive\Desktop\Python\Bot\bl\system.py", line 42, in on_message
    if word in msg.content:
TypeError: 'in <string>' requires string as left operand, not tuple
#

Um

#

Oh

#

Ok

manic wing
#

repost your error please

valid niche
valid niche
#

!paste if it's too long

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