#discord-bots

1 messages Β· Page 796 of 1

dry kelp
#

to copy paste the code

sick birch
#

No no, know where the issue is

#

typecast channel to discord.TextChannel

#

then you can store the ID

dry kelp
sick birch
#

perfect

dry kelp
#

alr

#

and i gotta use

sick birch
#

you got it

dry kelp
#

alr

#

i got 1 more question tho

sick birch
#

sure

dry kelp
#

how do iget the channel from the db?

#

channel = self.client.get_channel()

#

?

sick birch
dry kelp
#

ah

sick birch
#

since your "database" is a json, if you use the json library, it will parse the file into a python dict object

dry kelp
#

so how do i get the id?

sick birch
#
x = json.load(json_file)
x['key'] # List of channels
#

(that's only psuedocode)

#

in your case 'key' would be the part in blue

dry kelp
#

guild id

sick birch
#

i assume that's a guild ID?

dry kelp
#

ye ye

sick birch
#

so guild ID is a list of channel ids?

dry kelp
#

basically the guild id is set in a dict

#

and even tho im creating a list

#

im trying to add just 1 channel per each guild id

sick birch
#

why? why not just guild-channel pair?

dry kelp
#

how do i use that?

#

i mean that would be better

sick birch
#
{
  "guildID": "channelID",
  "12345": "67890"
}
#

each key is a guildID, each value is that guild's channel ID

dry kelp
#

that would be way better

#

but how πŸ˜‚

#

i mean i can use this way

#

and just check if there's already a channel

sick birch
#

well whenever you add an entry to the json, just add a single channel to a single guild ID

#

rather than a list of a single channel ID to a single guild ID

dry kelp
#

so like

#

wait cuz it wont add the channel directly

#

so it has to be set as none

sick birch
#

Add the entry to the json when you need

#

doesn't have to be none

dry kelp
#

i think that im going to use this way

#

and just check the list

sick birch
#

πŸ€” why?

dry kelp
#

idk i feel like it's easier

sick birch
#

quite inefficient and makes it more complicated don't you think

dry kelp
#

i'll be honest

#

this feels more easier πŸ˜‚

#

i probably need more help adding that

#

and i don't want to make u lose braincells

sick birch
#

well yeah using json as a db is never a good idea in the first place

sick birch
dry kelp
#

i use sql for other things

dry kelp
sick birch
#

could have this part of your sql database as well

dry kelp
sick birch
#

won't harm to have another table

dry kelp
#

like for welcomer i use sqlite

#

is just that json is making me lose braincells

sick birch
# dry kelp

use asqlite or aiosqlite, sqlite3 is blocking

dry kelp
#

is it?

sick birch
#

yep

dry kelp
#

i mean it works perfectly fine

sick birch
#

sure but it's still blocking

dry kelp
#

mmm

sick birch
#

it can take down your bot easily if it blocks at the right time and your client doesn't send a heartbeat

#

not to mention it's slower and blocks the entire event loop

pliant gulch
spark wigeon
pliant gulch
#

Guess it is to big πŸ˜”

dry kelp
#

@sick birch seems like is working fine

#

atleast this part

sick birch
#

you need process_command()

dry kelp
#

and because i don't want to use channel as a required parameter i am trying to get the id from json

#

can u explain to me one more time?

#

i still didn't get it

sick birch
#

change how it's stored in the json

#

without the <#>

spark wigeon
sick birch
#

that way you can just get it from json, then int() it

dry kelp
#

oh bruh

#

it still adds as <#>

#

wha-

#

why is it adding with <#>

sick birch
#

hmm

#

did you typecast properly?

dry kelp
#

yea

sick birch
dry kelp
#
    @antichannel.command()
    @commands.check_any(commands.is_owner(), is_guild_owner())
    async def add(self, ctx, channel: discord.TextChannel):

        with open(prefix_path, "r")as f:
            prefixes = json.load(f)

        prefixes[str(ctx.guild.id)]
        p = prefixes.get(str(ctx.guild.id))

        with open(channel_path, "r") as f:
            add_channel = json.load(f)

        if not str(ctx.guild.id) in add_channel:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"Turn on the antinuke logs first!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return

        if len(add_channel[str(ctx.guild.id)]) == 1:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"{channel.mention} Is currently set for the antinuke logs!\nType: `{p}Antichannel Remove` To remove the channel!", color=discord.Color.red())
            await ctx.send(embed=em)
            return
        
        if str(channel.id) not in add_channel[str(ctx.guild.id)]:
            add_channel[str(ctx.guild.id)].append(str(channel.id))

        else:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"{channel.mention} Is already set as the current channel!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return
            
        with open(channel_path, "w") as f: 
            json.dump(add_channel, f, indent=4)
        
        em = discord.Embed(title="![Ver](https://cdn.discordapp.com/emojis/858069322512859146.webp?size=128 "Ver") Antinuke Successful!", description=f"{channel.mention} Has been added set for the antinuke logs!", color=discord.Color.from_rgb(black1, black2, black3))
        await ctx.reply(embed=em, mention_author=False)

    @add.error
    async def channel_error(self, ctx, error):

        if isinstance(error, commands.MissingRequiredArgument):
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description="Please provide a channel [`Mention/ID`]!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)

        elif isinstance(error, CommandError):
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description="Only the owner can perform this action!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
#

this is how the code looks like

sick birch
#

on_message gets called before your command handlers so it's possible for user inputs to not get passed to the command handler

dry kelp
#

oh wait

#

i can use the same way i use to get the prefix

#

for the channel

sick birch
#

yeah

dry kelp
#

but still why is it adding as <#>

sick birch
#

πŸ€”

spark wigeon
dry kelp
#

should i try to print it?

sick birch
#

yes please

dry kelp
#

imma print channel and channel id

sick birch
#

channel.id

sick birch
#

make sure it's inside, not outside

spark wigeon
sick birch
#

No, it's just a coro

#

You don't have to define it yourself

#
async def on_message(...):
  ...
  await bot.process_commands(...)
nocturne bone
#

yo

pliant gulch
#

You can also just use client.listen()

sick birch
#

alternatively, inside a cog:

@commands.Cog.listener()
async def on_message(...):
  ...
  # no need for process_commands()
sick birch
dry kelp
#

wtf then

#

and yes i replaced the database

sick birch
#

that's odd, it made a new entry with <#>?

dry kelp
#

yep

#
    @antichannel.command()
    @commands.check_any(commands.is_owner(), is_guild_owner())
    async def add(self, ctx, channel: discord.TextChannel):

        with open(prefix_path, "r")as f:
            prefixes = json.load(f)

        prefixes[str(ctx.guild.id)]
        p = prefixes.get(str(ctx.guild.id))

        with open(channel_path, "r") as f:
            add_channel = json.load(f)

        if not str(ctx.guild.id) in add_channel:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"Turn on the antinuke logs first!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return

        if len(add_channel[str(ctx.guild.id)]) == 1:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"{channel.mention} Is currently set for the antinuke logs!\nType: `{p}Antichannel Remove` To remove the channel!", color=discord.Color.red())
            await ctx.send(embed=em)
            return
        
        if str(channel.id) not in add_channel[str(ctx.guild.id)]:
            add_channel[str(ctx.guild.id)].append(str(channel.id))

            print(f"{channel} This is channel")
            print(f"{channel.id} This is channel id")

        else:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"{channel.mention} Is already set as the current channel!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return
            
        with open(channel_path, "w") as f: 
            json.dump(add_channel, f, indent=4)
        
        em = discord.Embed(title="![Ver](https://cdn.discordapp.com/emojis/858069322512859146.webp?size=128 "Ver") Antinuke Successful!", description=f"{channel.mention} Has been added set for the antinuke logs!", color=discord.Color.from_rgb(black1, black2, black3))
        await ctx.reply(embed=em, mention_author=False)
#

it creates it with <#> automatically

sick birch
#

that's not right πŸ€”

dry kelp
#

i swear i used this code

#

so like idk

sick birch
#

and you're sure you deleted everything inside the .json before trying this?

dry kelp
#

yep

sick birch
#

definitely not right

dry kelp
sick birch
#

do you have an external function doing it?

dry kelp
#

wym

sick birch
#

sometimes people make helper functions and forget they still have it

dry kelp
#

lemme check again

sick birch
#

actually instead of removing everything, just remove the "<#IDHERE>", so it looks like

{
  "guildID": []
}
#

then try it

dry kelp
#

great

#

but

#

it wont remove

#
    @antichannel.command()
    @commands.check_any(commands.is_owner(), is_guild_owner())
    async def remove(self, ctx):

        with open(prefix_path, "r")as f:
            prefixes = json.load(f)

        prefixes[str(ctx.guild.id)]
        p = prefixes.get(str(ctx.guild.id))

        with open(channel_path, "r") as f:
            remove_channel = json.load(f)

        remove_channel[str(ctx.guild.id)]
        channel = remove_channel[str(ctx.guild.id)]

        if not str(ctx.guild.id) in remove_channel:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"The antinuke logs are not enabled!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return

        try:
            if str(channel) in remove_channel[str(ctx.guild.id)]:
                remove_channel[str(ctx.guild.id)].remove(str(channel))

            em = discord.Embed(title="![Ver](https://cdn.discordapp.com/emojis/858069322512859146.webp?size=128 "Ver") Antinuke Successful!", description=f"{channel.mention} Has been removed from the antinuke logs!\nType: `{p}Antichannel Add [Mention/ID]` To add a channel!", color=discord.Color.from_rgb(black1, black2, black3))
            await ctx.reply(embed=em, mention_author=False)
            
            with open(channel_path, 'w') as f:
                json.dump(remove_channel,f)
        except:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"No channel was found in the database!\nType: `{p}Antichannel Add [Mention/ID]` To add a channel!", color=discord.Color.red())
            await ctx.send(embed=em)

    @remove.error
    async def channel_error(self, ctx, error):

        if isinstance(error, CommandError):
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description="Only the owner can perform this action!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
sick birch
#

let's see

dry kelp
#

it doesn't remove

#

it even fucks jsk up

sick birch
dry kelp
#

wym

sick birch
#

well accessing dicts returns a value

#

what's the point of accessing without storing it in a variable

#
        remove_channel[str(ctx.guild.id)]
        channel = remove_channel[str(ctx.guild.id)]

this part

#

the first line there doesn't do anything

dry kelp
#

huh

#

oh yea

#

my bad

#

deleted it

#
    @antichannel.command()
    @commands.check_any(commands.is_owner(), is_guild_owner())
    async def remove(self, ctx):

        with open(prefix_path, "r")as f:
            prefixes = json.load(f)

        prefixes[str(ctx.guild.id)]
        p = prefixes.get(str(ctx.guild.id))

        with open(channel_path, "r") as f:
            remove_channel = json.load(f)
            
        channel = remove_channel[str(ctx.guild.id)]

        if not str(ctx.guild.id) in remove_channel:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"The antinuke logs are not enabled!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return

        try:
            if str(channel) in remove_channel[str(ctx.guild.id)]:
                remove_channel[str(ctx.guild.id)].remove(str(channel))

            em = discord.Embed(title="![Ver](https://cdn.discordapp.com/emojis/858069322512859146.webp?size=128 "Ver") Antinuke Successful!", description=f"{channel.mention} Has been removed from the antinuke logs!\nType: `{p}Antichannel Add [Mention/ID]` To add a channel!", color=discord.Color.from_rgb(black1, black2, black3))
            await ctx.reply(embed=em, mention_author=False)
            
            with open(channel_path, 'w') as f:
                json.dump(remove_channel,f)
        except:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Antinuke Error!", description=f"No channel was found in the database!\nType: `{p}Antichannel Add [Mention/ID]` To add a channel!", color=discord.Color.red())
            await ctx.send(embed=em)
sick birch
#

alright let's see now

dry kelp
pallid mango
#

i dont think so

dry kelp
pallid mango
#

oh wait yes it is

dry kelp
#

nope

sick birch
#

so right now it looks in the list, and tries to remove an entry with the channel's name

dry kelp
#

oh

#

l*

sick birch
#

yep

dry kelp
#

confusing af

#

and jsk not checking it

sick birch
#

your try/except catches all errors

#

try to either print the error or narrow down the error

dry kelp
#

imma remove the try and except so we can see

sick birch
#

or even better, dict.get() will return None if not found rather than throw a KeyError

dry kelp
#

ou

#

oh yea

sick birch
#

!e

myDict = {
  "x": "test1",
  "y": "test2",
}

print(myDict.get("x"))
print(myDict.get("does not exist"))
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

001 | test1
002 | None
dry kelp
#

i gotta get the object from inside the list

sick birch
#

why? just remove the ID

dry kelp
#

it wont work

sick birch
#

right get the first element of the list

#

channel[0]

dry kelp
#

str has no atr for id

#

awesome

sick birch
#

no, it's already an ID in the json

dry kelp
#

right

#

isn't it 1 ?

#

@sick birch

sick birch
#

0 is the first

dry kelp
#

then wtf

sick birch
#

and your list will only have 1 element

quaint scaffold
#

You could you use hexadecimal values for colours, less code and achieves the same effect

dry kelp
#

wait nvm

sick birch
#

maybe it tried to get the first element before there was even an element

#

this is the problem with lists, they act kind of weird

dry kelp
#

fr

#

worked but

#

it's weird cuz

#

i tried pinging the channel

#

instead of using channel

dry kelp
sick birch
#

make sure the list actually has something inside it before accessing it

royal oar
#

Would a cooldown work on a on_message command?

dry kelp
#

there is

final iron
#

You would have to implement it yourself

dry kelp
#

it doesn't make sense cuz

#

it works here

royal oar
final iron
#

Just create commands like a normal person

royal oar
#

considering this on message is for dms

#

for information from the modmail

#

isnt an actual command

royal oar
final iron
#

I know...

dry kelp
#

@sick birch

#

look

#
        if str(channel[0]) in remove_channel[str(ctx.guild.id)]:
            remove_channel[str(ctx.guild.id)].remove(str(channel[0]))

        em = discord.Embed(title="![Ver](https://cdn.discordapp.com/emojis/858069322512859146.webp?size=128 "Ver") Antinuke Successful!", description=f"<#{str(channel[0])}> has been removed from the antinuke logs!\nType: `{p}Antichannel Add [Mention/ID]` To add a channel!", color=discord.Color.from_rgb(black1, black2, black3))
        await ctx.reply(embed=em, mention_author=False)
        
        with open(channel_path, 'w') as f:
            json.dump(remove_channel,f)
sick birch
#

make sure the list is filled up before you send that message

#

it's doing that because the list is empty

#

(or use guildID <-> channel ID pairs instead of a list)

final iron
#

!d discord.ui.View.remove_item

unkempt canyonBOT
final iron
#

Β―_(ツ)_/Β―

final iron
#

Consider just disabling the buttons instead of removing them

dry kelp
#

str(channel[0])[str(ctx.guild.id)] smth like this?

#

imma just use channel

#

literally the word channel

final iron
#

ok

slate swan
#

Guys I am using discord.py for rich presence but on mobile its ok, but in pc, it shows like playing since 19k days

dry kelp
#

LOL

#

i did it

wanton cipher
#

I have a question, is there a way that a task or something similar can be run at a specific datetime?

fervent shoal
#

how would i define member here

slate swan
#

right now it doesnt know what class your talking about

fervent shoal
#

like so?

slate swan
#

no

#

member isnt a module?

fervent shoal
#

how would i do it then

slate swan
#
from discord import Member
fervent shoal
#

it shows up now

slate swan
#

nice

fervent shoal
#

without doing what you said above

slate swan
#

show your imports

fervent shoal
#

ah shit i gotta delete the client and intents line

slate swan
#

the heck

fervent shoal
#

most of it was for an auto type to troll a friend

slate swan
#

πŸšͺ🚢

fervent shoal
#

well shit

final iron
#

Imports should be at the top of the file

slate swan
#

i cant help anymore to much errorsπŸ˜”

final iron
#
Imports should be grouped in the following order:

standard library imports
related third party imports
local application/library specific imports
slate swan
#

i just import by groups

final iron
#

Well fix

fervent shoal
#

Traceback (most recent call last):
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.

#

the traceback is what i get

final iron
#

You're not in a class

slate swan
final iron
#

wdym

slate swan
# final iron wdym
from discord.ext import commands
from discord import Member

import random

import asyncio

etc

final iron
#

Also, for your project do you care if I make pull requests for tiny pep8 violations

slate swan
final iron
#
    def get_tweet(self, tweet_id: int) -> dict[Any, Any]:
        try:
            self.cache[tweet_id]
        except KeyError:
            raise "No such tweet"
#

Why type hint if you're not returning anything

slate swan
final iron
#

Not pep8 just wondering

slate swan
final iron
final iron
#

Renove self

fervent shoal
#

so delete self

final iron
#

Yes

fervent shoal
#

thats it

final iron
#

I don't know

#

Try to run your current code

slate swan
final iron
#

I'm literally the pep8 police

slate swan
final iron
#

We don't talk about that

fervent shoal
#

not accsessed

final iron
#

I follow all of it except the line character limit

fervent shoal
#

pain

slate swan
final iron
#

Nope

slate swan
#

cap

final iron
#

I don't do bare exceptions

slate swan
fervent shoal
#

halp

final iron
#

I need to fix my imports

#

I have just recently learned about the import order

slate swan
#

!d discord.ext.commands.Bot.cogs

unkempt canyonBOT
slate swan
#

returns a list, use len on it

fervent shoal
#

do i delete self here too?

slate swan
#

is it in a class?

fervent shoal
#

pardon?

slate swan
fervent shoal
#

not a cog

slate swan
#

then no need

fervent shoal
#

people make mistakes, thats why we have erasers

slate swan
#

he has a point

final iron
#

Is pytz a standard lib?

#

!pypi pytz

unkempt canyonBOT
final iron
#

I guess not

slate swan
fervent shoal
#

its jus that ive seen people get the wrong id or the wrong ping tryna ban

fervent shoal
slate swan
#

yes

fervent shoal
#

like so?

slate swan
#

yes

#

just use the default discord ban mehh

#

they added it in the slash commands recently

fervent shoal
#

Traceback (most recent call last):
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.

#

again πŸ˜”

slate swan
#

well youre missing member?

quick gust
#

do you not know your own code bruh

#

you need to give it a member

#

while invoking the command

slate swan
#

they are not in a cog but you still use self , bet

final iron
#

@slate swan py_guido

slate swan
#

!e

def function(member: str) -> str:
    return member
function()
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | TypeError: function() missing 1 required positional argument: 'member'
quick gust
#

heh

final iron
#

I follow all of pep8 except for character limit

slate swan
#

oki, just use black to format your code run

final iron
#

Fuck character limit

quick gust
slate swan
#

noone likes scrolling sideways

slate swan
quick gust
#

how could you do this

final iron
slate swan
#

i needed to

slate swan
final iron
quick gust
#

multiline strings

slate swan
#

^^

final iron
#

Those look ugly as hell

quick gust
#

if my descriptions are long I usually just make a variable with multi line strings lol

slate swan
#

better than 100 characters long single line string

final iron
#

Okay FINE

#

I'll fix it tomorrow

neat tartan
#

can i ask a quick question? one of my bot commands was working and is now no longer working and i cant see anything thats changed with it. even undoing any possible changes

final iron
#

I will 100% make my files comply with pep8

quick gust
#

I thought Krypton was typing lol

slate swan
#

i fixed all my imports yesterday mehh

royal oar
#

Hello! I am trying to hide cogs on my code from my help commands
i tried adding command_attrs=dict(hidden=True) to my code. Now the commands dont show up but the cog still does show up. Is there anyway to hide it?

slate swan
neat tartan
#

it was working and then wasnt working

slate swan
#

!d discord.ext.commands.Bot.listen

neat tartan
#

im guessing im missing something small

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").

Example...
slate swan
#

use this

slate swan
#

no dont

pliant gulch
slate swan
#

use listen

quick gust
#

oh Andy has a cat pfp too, nice

pliant gulch
#

It's brandons cat!

final iron
#

Oh damn. I have too instances of my bot running. What do I do?

slate swan
quick gust
#

close one of them lol

neat tartan
#

k hold up. i just got like 2-3 different answers there. one at a time

final iron
#

None of them are open

slate swan
slate swan
pliant gulch
slate swan
#

bro wut

#

how am i trolling

#

i recommended a listener pithink

#

no, listen is a way to fix it too

final iron
#

I always reset my token but I was wondering if there was something less annoying

quick gust
#

you can use bot.listen or process the commands, but only do one of them lol

slate swan
#

and using a listener is indeed better

#

yall really judge quickpithink

pliant gulch
#

Okimii did you see that new example I pushed to the repo

slate swan
#

ik sarthak is handsom but give me a breakπŸ₯²

neat tartan
#

ok, so use a listener right?

quick gust
#

yes

slate swan
pliant gulch
#

Yea the collectors one where I show off some anti-raid capabilities

#

Pretty cool right

pliant gulch
slate swan
pliant gulch
#

🧠

slate swan
#

jeez thats cool, would help a lot with cooldowns and other stuff

slate swan
neat tartan
# quick gust yes

ok, using the listener. would that replace the @ client.event, async def on_message(message): or await message.channel.send(response)?

pliant gulch
#

cooldowns

pliant gulch
#

πŸ‘οΈ πŸ‘οΈ no such thing in Rin

#

Only native API

slate swan
slate swan
neat tartan
quick gust
#

@bot.event will change to @bot.listen('on_message') and you can name the function whatever you want, but i think it also works if you just do @bot.listen() and keep the function name on_message

slate swan
#

if you do then you can call the function whatever

fervent shoal
#

would a mute and kick command work the same way?

fervent shoal
#

appreciated

#

oh

slate swan
#

params

#

each one takes different params

fervent shoal
#

how would i make it not have a confirmation

#

what would i delete

neat tartan
fervent shoal
#

so delete highlighted

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_channel_create(self, channel):

        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.channel_create):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(channel.guild.id)]:
                return
            
            await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Channels")
            await i.target.delete(reason=f"Anti-Nuke: Deleting user created channels")

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            if channel.guild.id not in config_channel:
                return

            channel = config_channel[str(channel.guild.id)]
            try:
                channel_id = channel[0]
            except:
                pass

            log_channel = self.angel.get_channel(channel_id)
            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**CHANNEL LOGS**\n\nMember: {i.user}\nMember ID: {i.user.id}\n\nMember created a channel!\n\nMember has been **banned** out of the guild!\nChannel has been **deleted**!")
            await log_channel.send(embed=embed)
final iron
#

json py_guido

slate swan
#

oh no json

dry kelp
#

why is the log not sending?
in the channel

#

dude is called

slate swan
#

im not going to read anything related to json already

dry kelp
#

a "test"

#

bruh

final iron
#

json code is so hard to read

slate swan
#

anyways. lemme check

final iron
#

Like actually accessing the data is hard

slate swan
final iron
dry kelp
#

wtf

dry kelp
#

nope

final iron
#

Someone made some really complicated shit and I just gave up

slate swan
fervent shoal
#

πŸ€”

final iron
#

Yup

fervent shoal
#

why is it like this

final iron
#

Speaking of sql, I still need to protect myself against injections

slate swan
slate swan
fervent shoal
dry kelp
final iron
#

.remind Fix sql injection bug and add multiline strings for embed description's over 120 lines 15h

slate swan
final iron
#

Whats the command?

fervent shoal
#

i just deleted what was highlighted as said earlier

slate swan
#

can you make a discord bot using python?

slate swan
slate swan
#

Okay ty all of you

#

this is a python server with a discord bot topic channel yes

final iron
slate swan
#

even scratch :V

#

even ruby

#

ruby ewww

slate swan
#

K_Bruh_why what made u learn ruby

final iron
#

!remind 16h Fix sql injection bug and add multiline strings for embed description's over 120 lines

unkempt canyonBOT
#
No way, JosΓ©.

Sorry, you can't do that here!

slate swan
final iron
#

aight

#

I feel you

slate swan
#

is this okay, i have just started on a bot lol

slate swan
pliant gulch
slate swan
#

not py?

final iron
final iron
slate swan
#

sorry i am dumb

final iron
slate swan
#

rs > rb

slate swan
slate swan
#

yes

#

rs syntax is just something else

#

its better for backend as well, better memory security

#

no🀸

slate swan
#

so now is it correct

slate swan
fervent shoal
#

how do i actually make it ban cuz it did earlier 😒

slate swan
slate swan
slate swan
unkempt canyonBOT
#

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

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

thanks

slate swan
slate swan
slate swan
#

vsc isnt public?

fervent shoal
#

how do i make it say who got banned

slate swan
fervent shoal
#

rn its this

slate swan
#

the member variable is the banned person's object

final iron
fervent shoal
#

thank you so much

slate swan
fervent shoal
#

fr

slate swan
final iron
slate swan
#

^ lol

slate swan
#

sorry i seem dumb

#

no need to get the token from a env file lol

#

its done since replit is public

#

its still a better practice, wont hurt

#

so i do not need client.run

#

yes you do just add your token

slate swan
#

just pass the token directly into it, instead of getting it from env

final iron
#

okimii, just for you im going to make my files be 100% pep8 compliant

slate swan
#

sarthak with the 30sec reply delayyert

fervent shoal
#

w h a t, im geniuinlly confused, also bad spelling go brr

final iron
#

When I'm sending a multiline string in an embed description will it be formatted as such? i.e

"""
a
a
"""

Gets sent as

a
a
#

Or will it get sent as ```py
a a

slate swan
#

πŸ’€ imports.

final iron
#

Good

slate swan
#

check lol

final iron
#

So it will just clean up my code, not fuck with my formatting

#

Well shit

slate swan
#

now we know lol

final iron
#

So it will fuck up my formatting

#

Guess I'm not fixing the character limit

#

Β―_(ツ)_/Β―

slate swan
#

you canpithink

slate swan
final iron
#

Should I just get black

slate swan
final iron
#

Do you use it?

slate swan
#

no

#

😳

#

i'd just do py "\n".join( ("long line1", "long line2") )

#

yeah its better

slate swan
slate swan
final iron
slate swan
fervent shoal
#

anything wrong here?

slate swan
fervent shoal
#

oh shit

#

this is why im failin english

slate swan
#

it must be in pairs
this:
' '
or this
" "

fervent shoal
#

thanks

slate swan
#

yw

final iron
#

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

final iron
#

It breaks the character limit but thats just because of indentation

neat tartan
#

im now running into this error

slate swan
unkempt canyonBOT
fervent shoal
#

Traceback (most recent call last):
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\E\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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: ban() missing 1 required positional argument: 'member'

final iron
fervent shoal
slate swan
# final iron It breaks the character limit but thats just because of indentation
embed_ = disnake.Embed(
    title="Bookmarked!",
    description=msg.content,
    colour=disnake.Colour.random(),
    timestamp=ctx.message.created_at
    ).set_author(
        name=msg.author,
        icon_url=msg.author.display_avatar.url
        ).add_field(
            name="Message Link",
             value=f"[Jump to message](https://discord.com/channels/{msg.guild.id}/{msg.channel.id}/{msg.id})"
             ).set_footer(
                 text=f"{ctx.me.name} Discord Bot",
                 icon_url=str(ctx.me.display_avatar)
                 )
slate swan
final iron
#

Yeah, I fixed it

fervent shoal
#

this ban command is giving me so much hell

final iron
#

I'm going to be doing a lot of refactoring tmr

slate swan
#

my code looks sus

fervent shoal
#

pls help

final iron
#

Your code is very bad for readability imo

slate swan
slate swan
neat tartan
final iron
#

I'll just let black go wild on my code

#

Then I'll refactor stuff myself

fervent shoal
#

what does this mean

slate swan
fervent shoal
#

i did

final iron
#

!d disnake.Member.ban

unkempt canyonBOT
#

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

Bans this member. Equivalent to [`Guild.ban()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.ban "disnake.Guild.ban").
slate swan
#

show code

final iron
#

Are you using Guild.ban()?

fervent shoal
slate swan
#

wait wtf, ban(Member)?

final iron
#

You cannot import ban from disnake.Member

#

Not how it works

fervent shoal
#

am i not supposed to >.<

slate swan
#

its either Guild.ban(Member) or Member.ban()

dry kelp
#

@slate swan imma ask here again

fervent shoal
#

that goes in async def Member.ban()

sick birch
# fervent shoal

even if you had a helper function that banned members, you're passing in a discord.Member class object, not the instance

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_channel_create(self, channel):

        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.channel_create):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(channel.guild.id)]:
                return
            
            await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Channels")
            await i.target.delete(reason=f"Anti-Nuke: Deleting user created channels")

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            if channel.guild.id not in config_channel:
                return

            channel_config = config_channel[str(channel.guild.id)]
            try:
                channel_id = channel_config[0]
            except:
                pass

            log_channel = self.angel.get_channel(channel_id)
            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**CHANNEL LOGS**\n\nMember: {i.user}\nMember ID: {i.user.id}\n\nMember created a channel!\n\nMember has been **banned** out of the guild!\nChannel has been **deleted**!")
            await log_channel.send(embed=embed)
#

why are the logs not sending

dry kelp
#

broooo those logs

#

are pissing me off fr

#

atleast i was able to fix the channel index shit

sick birch
#

working with audit logs has never been fun, yes

dry kelp
#

do you know what can cause this?

timid wagon
dry kelp
#

from not sending

timid wagon
#

You're calling self.angel instead

dry kelp
timid wagon
#

Unless it was defined in the class dead

dry kelp
#

self.client.angel

#

wtf

#

angel is just the name of my client

#

that would be the same like

timid wagon
#

oH

dry kelp
#

self.client.client

fervent shoal
#

im def doing something wrong

timid wagon
#

Nah nah I get it now

timid wagon
sick birch
dry kelp
#

you should try renaming ur command

slate swan
#

this is correct now ig

dry kelp
#

and maybe without using . in the name

maiden fable
dry kelp
fervent shoal
#

ban is not defined pithink

sick birch
fervent shoal
#

its all g

slate swan
maiden fable
fervent shoal
#

im ass at this

slate swan
#

im not going to say anything

timid wagon
fervent shoal
#

say soemthing pls

maiden fable
dry kelp
#

robin why the logs won't send pout

fervent shoal
slate swan
dry kelp
#

😭

fervent shoal
#

what am i doing wrong

sick birch
dry kelp
#

@fervent shoal i don't use .

#

in ur command

timid wagon
# fervent shoal

You're not being asked to rename the function, but the method.

dry kelp
#

DON'T USE . IN UR COMMAND**

#

just don't do that

sick birch
#

Please be respectful, they may be new but we should try to help them πŸ™‚

dry kelp
#

use ban instead of member.ban

slate swan
#

nooooo

dry kelp
#

that will make your life easier

#

that's the name of the command

sick birch
#

You're on the right track, just not yet, but I'm certain you'll get there!

slate swan
#

oh yea

#

youtube videos are always bad

sick birch
#

I wouldn't recommend those

fervent shoal
#

like so

timid wagon
#

Yep

dry kelp
fervent shoal
#

didnt work

slate swan
dry kelp
#

huh

sick birch
#

The amount of times I've seen people call a commands.Bot instance client because of YouTube videos...

sick birch
dry kelp
#

can i fix his command?

slate swan
#

and in the send , use member instance, not Member

sick birch
#

member refers to the actual instance while Member refers to the class

#

Let's not

slate swan
#

you should not :p

dry kelp
#

imma make a code that he can understand

fervent shoal
sick birch
slate swan
#

and change Member to member in the send method

sick birch
fervent shoal
timid wagon
#

And the Member you're using in the f-string should be lowercase member instead. That's the argument you defined.

slate swan
sick birch
#

that'll conflict with your command name

dry kelp
#
@bot.command()
async def ban(ctx, member):
    await member.ban() # this will ban the member
    await ctx.send(f"{member} has been banned!")  # this will be sent after the user gets banned
fervent shoal
#

ok so

slate swan
#

the member is a string by default

sick birch
dry kelp
dry kelp
timid wagon
fervent shoal
#

reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee why is brain no work

dry kelp
#

honestly i find it more easier to understand something because after u will be able to do better stuff

#

trust me

slate swan
fervent shoal
slate swan
#

prefect.

sick birch
dry kelp
sick birch
#

just use discord.Member or commands.Context

sick birch
#

You can easily get confused by lowercase/uppercase member

slate swan
#

!e import choice from random

sick birch
#

πŸ€”

fervent shoal
#

THANK YOU GUYS SO MUCH

sick birch
#

Or is it the other way around

slate swan
#

ill assume you meant from discord import Member

sick birch
#

Sorry yeah too much JavaScript

fervent shoal
#

IT WORKED AND IS ALL THANKS TO YOU

#

πŸ™

sick birch
#

It's the other way around in javascript, get quite confused

#

But yes my apologies

slate swan
#

mhm typescript uses such imports iirc

sick birch
#

ES6 modules yes

#

If I remember correctly

slate swan
#

if i remember correctly

dry kelp
#

robin?

sick birch
#

Yes?

dry kelp
#

could u help me with the logs?

sick birch
#

I suppose, let's take a look

dry kelp
#

alr awesome

#

lemme send again

#
    @commands.Cog.listener()
    async def on_guild_channel_create(self, channel):

        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.channel_create):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(channel.guild.id)]:
                return
            
            await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Channels")
            await i.target.delete(reason=f"Anti-Nuke: Deleting user created channels")

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            if channel.guild.id not in config_channel:
                return

            channel_config = config_channel[str(channel.guild.id)]
            try:
                channel_id = channel_config[0]
            except:
                pass

            log_channel = self.angel.get_channel(channel_id)
            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**CHANNEL LOGS**\n\nMember: {i.user}\nMember ID: {i.user.id}\n\nMember created a channel!\n\nMember has been **banned** out of the guild!\nChannel has been **deleted**!")
            await log_channel.send(embed=embed)
#

this should send after the channel is deleted by the bot if the logs are enabled

sick birch
#

And what's the issue?

dry kelp
#

won't send the logs

fervent shoal
#

how would i give a time

dry kelp
sick birch
#

Why is it on_guild_channel_create as opposed to on_guild_channel_delete?

dry kelp
#

huh?

#

no lol

sick birch
#

You want it to log when a channel is deleted?

dry kelp
#

the channel is getting deleted by the bot

sick birch
#

Ah

dry kelp
#

if a non-trusted member creates it

#

after that the bot should send in the log channel "if it exists" the log

sick birch
#

And it wants to log when the bot deletes it?

dry kelp
#

yea it should send after basically

#

WTF IS 6 AM

sick birch
#

I see

dry kelp
#

it was 3 am like 5 minutes ago

fervent shoal
#

for time would it be "if (insert time variable), mute member?"

dry kelp
#

i can tell logs are painful πŸ˜‚

sick birch
fervent shoal
#

how do then

#

monke brain work hard

sick birch
#

UNIX timestamps are the easiest to work with

fervent shoal
#

w h a r

sick birch
#

They're integers so it's easy to compare it with another time

#

Checking range, etc..

royal oar
#

Hello my bot responds to the word hi but everytime someone says this it responds, Is there a way to stop it?

fervent shoal
#

how would i do that >.<

sick birch
sick birch
#

Yeah, it just checks for a string within another string

#

Regardless of what's around it

fervent shoal
#

oh i need to wire it to a mute role

royal oar
#

is there a way to stop that?

fervent shoal
#

reeeeeeeeeeeeeeeeeeeee

sick birch
#

It only gets triggered if the message content is exactly "hi"

royal oar
#

Ok thank you

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_channel_create(self, channel):

        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.channel_create):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(channel.guild.id)]:
                return
            
            await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Channels")
            await i.target.delete(reason=f"Anti-Nuke: Deleting user created channels")

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            if channel.guild.id not in config_channel:
                return

            if str(channel) not in config_channel[str(channel.guild.id)]:
                return

            channel_config = config_channel[str(channel.guild.id)]
            try:
                channel_id = channel_config[0]
            except:
                pass

            log_channel = self.angel.get_channel(channel_id)
            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**CHANNEL LOGS**\n\nMember: {i.user}\nMember ID: {i.user.id}\n\nMember created a channel!\n\nMember has been **banned** out of the guild!\nChannel has been **deleted**!")
            await log_channel.send(embed=embed)
dry kelp
#

does this makes sense ?

#

if i add it?

fervent shoal
#

big words no make sense lemon_angrysad

sick birch
#

UNIX timestamps is seconds since Jan 1 1970 iirc, it's an integer so like i mentioned should be easy to work with

#

It's either seconds or milliseconds not sure

dry kelp
sick birch
dry kelp
#

yeah but still won't do shit

#

πŸ˜‚

#

is good the way im sending the embed?

#

like how im getting the log channel

fervent shoal
#

wait do i have to have a time connected to mute command

sick birch
# dry kelp

Nothing wrong with the way you're sending it

#

make sure channel_id is an int

#

Since you're doing a lot of converting to and from json

fervent shoal
#

how would i connect a role to a command

dry kelp
#

it is a id

#

it just fuckedup cuz it wont send any errors

#

πŸ™„

fervent shoal
#

ah

sick birch
#

that part looks correct

dry kelp
#

it looks

#

but is not

#

can i inv u to a testing server?

#

is that fine or?

timid wagon
#

The command's function will not be inside __init__

sick birch
#

Sorry I'm kind of at the server limit right now

#

I'll try to help you out here to the best of my ability

#

here, could you post your entire code to a pastebin and link it?

fervent shoal
#

ah shit i gotta have a role be able to do the command

timid wagon
sick birch
timid wagon
#

Yeah, basically

dry kelp
sick birch
#

great let me take a look at it

dry kelp
#

alr

fervent shoal
#

should this work

sick birch
#

And what was the problem again?

dry kelp
#

me?

sick birch
#

No errors, but it wasn't behaving as intended

sick birch
dry kelp
#

like i said the logs won't send for that event

sick birch
timid wagon
dry kelp
sick birch
#

Looks to me like something before is probably messed up

dry kelp
#

wym

sick birch
#

Perhaps it didn't find channel_id

fervent shoal
dry kelp
#

i mean it should

#

should i print?

sick birch
#

Try doing a print statement to see if it is

dry kelp
#

alr

sick birch
timid wagon
#

The conventional method is to create a role that limits the user. And then add that role when you want to mute someone.

The new method is to timeout the user. But discord.py does not support that

fervent shoal
#

i have the role i want the user to get

#

do i do add.role?

sick birch
#

If so you can easily accomplish that with aiohttp

dry kelp
#

doesn't print

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

i think something is blocking the code

sick birch
fervent shoal
#

underschore

#

score, got it

#

oh i alr have that

timid wagon
sick birch
dry kelp
#

i will do more prints

fervent shoal
sick birch
final iron
#

You're missing out on so many things if you stick with discord.py

timid wagon
slate swan
sick birch
slate swan
#

Wow

fervent shoal
#

reeeeeeeeeeeeeeeeeeeeeeeeeeee

#

im so stupid

final iron
shadow wraith
sick birch
dry kelp
#
    @commands.Cog.listener()
    async def on_guild_channel_create(self, channel):

        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.channel_create):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(channel.guild.id)]:
                return
            
            await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Channels")
            await i.target.delete(reason=f"Anti-Nuke: Deleting user created channels")
            print("channel deleted")

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            if channel.guild.id not in config_channel:
                print("first check")
                return

            if str(channel.id) not in config_channel[str(channel.guild.id)]:
                print("2nd check")
                return

            channel_config = config_channel[str(channel.guild.id)]
            print(channel_config)
            try:
                channel_id = channel_config[0]
                print(channel_id)
            except:
                pass

            log_channel = self.angel.get_channel(channel_id)
            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**CHANNEL LOGS**\n\nMember: {i.user}\nMember ID: {i.user.id}\n\nMember created a channel!\n\nMember has been **banned** out of the guild!\nChannel has been **deleted**!")
            await log_channel.send(embed=embed)
            print("sent")
#

let's see where the prints stop

timid wagon
# fervent shoal

The commands.has_permissions comes right after the bot.command decorator

slate swan
dry kelp
#

i will try to check the returns too

sick birch
fervent shoal
sick birch
# fervent shoal

Decorators need to actually decorate something, not empty space

dry kelp
#

alr

#

the code stops here

#

@sick birch

sick birch
#

That print doesn't get called?

dry kelp
#

it did

sick birch
#

oh wait it does

#

but nothing after gets called?

dry kelp
#

nope

#

just keyerrors

#

because it returns there

#

so is not checking the right thing if it returns

sick birch
#

should be an easy fix then, change up the if statement?

dry kelp
#

if not str(channel.guild.id) in config_channel:

sick birch
#

what is the goal of that if statement

#

what's it supposed to do?

dry kelp
#

to check if the logs is enabled

#

basically that part

#

logs_config is taking care of that

sick birch
#

and config_channel is a list or dict containg all the IDs of the guilds with logs enabled?

dry kelp
#

that's what adds the guild id in the json

#

config_channel is uh

#

lemme see

#

the json file

sick birch
#

Can i see Logs.json?

dry kelp
#

ofc

#

is a dic

fervent shoal
#

invalid perm

sick birch
fervent shoal
#

oh shi

#

my b

sick birch
#

Make sure the role you're assigning is configured properly (on discord)

maiden fable
fervent shoal
#

yea

maiden fable
#

Also add_roles need a snowflake

fervent shoal
#

h u h

sick birch
#

It has to limit the privileges of the user being muted (texting permission for all channels as a base)

maiden fable
#

So u should do discord.Object(id=id-here)

#

Instead of directly passing the ID

grim oar
#

Also it's a coro

dry kelp
#

awesome

#

1 step closer

unkempt canyonBOT
#

class discord.Object(id)```
Represents a generic Discord object.

The purpose of this class is to allow you to create β€˜miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.

There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.

x == y Checks if two objects are equal.

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

hash(x) Returns the object’s hash.
fervent shoal
#

add discord.Object(id=id-here) instead of?

sick birch
dry kelp
#

i will remove the 2nd check cuz it's actually useless

maiden fable
#

Wait u got pinged?

dry kelp
#

try:except pass are already taking care

maiden fable
sick birch
maiden fable
#

Ah okay. Discord being weird, I remember I disabled the ping Β―_(ツ)_/Β―

fervent shoal
slate swan
fervent shoal
#

???????

maiden fable
#

Why would it error out

dry kelp
#

and here we got the error @sick birch

slate swan
# fervent shoal

nah dude, remove the bare member.add_roles , and await the member.add_roles below

dry kelp
#

atr error

sick birch
maiden fable
sick birch
fervent shoal
#

this better?

maiden fable
#

await member.add

sick birch
#

make sure it's 100% a string and it's the channel id, not the guild id

grim oar
#

it's a coro

dry kelp
#

can u help me to fix this?

slate swan
maiden fable
#

@dry kelp in which event/function u getting the channel ID

dry kelp
#

my brain is literally 80% harmed

slate swan
sick birch
#

json is such a pain to work with

fervent shoal
#

my monke brain is no work reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

grim oar
maiden fable