-
-
Save 0xicl33n/e5008c5865347aafc644a67455507314 to your computer and use it in GitHub Desktop.
@bot.event | |
async def on_guild_join(guild): | |
for channel in guild.text_channels: | |
if channel.permissions_for(guild.me).send_messages: | |
await channel.send('Hey there! this is the message i send when i join a server') | |
break | |
Yeah this works amazing, but it sends a message to every channel, can I fix this somehow?
looks like you forgot to add the break
so i've changed the code to work with my bot but it errors
Ignoring exception in on_guild_join Traceback (most recent call last): File "D:\The_f\python\lib\site-packages\discord\client.py", line 333, in _run_event await coro(*args, **kwargs) TypeError: on_guild_join() takes 1 positional argument but 2 were given
the code that i used was
`import discord
from discord.ext import commandsclass role(commands.Cog):
def __init__(self, client): self.client = client @commands.Cog.listener() async def on_guild_join(guild): for channel in guild.text_channels: if channel.permissions_for(guild.me).send_messages: await channel.send(f'Hey there! do `{prefix}setup` to make your moderation role') break
def setup(client):
client.add_cog(role(client))`
any ideas on how to fix it?
you need "self" before guild!
one thing I noticed about my bot's behaviour is that when it joins, if it can't send messages in the VERY TOP CHANNEL it just doesn't do anything else. Is there a workaround for this?
one thing I noticed about my bot's behaviour is that when it joins, if it can't send messages in the VERY TOP CHANNEL it just doesn't do anything else. Is there a workaround for this?
I've been using this for three years and it has always posted on the first channel it is able to regardless of its order in the list. No idea what your problem is and this gist isn't for bot support.
Wow, this works flawlessly, thanks for helping
Thanks bro!
so i've changed the code to work with my bot but it errors
Ignoring exception in on_guild_join Traceback (most recent call last): File "D:\The_f\python\lib\site-packages\discord\client.py", line 333, in _run_event await coro(*args, **kwargs) TypeError: on_guild_join() takes 1 positional argument but 2 were given
the code that i used was
`import discord
from discord.ext import commandsclass role(commands.Cog):
def __init__(self, client): self.client = client @commands.Cog.listener() async def on_guild_join(guild): for channel in guild.text_channels: if channel.permissions_for(guild.me).send_messages: await channel.send(f'Hey there! do `{prefix}setup` to make your moderation role') break
def setup(client):
client.add_cog(role(client))`
any ideas on how to fix it?
Just add "self" before guild at line 9
i doesnt work for me, i dont get even a error message.....
i'Ve enabled intents.guilds = True
maybe cuz the library (discord.py) is now dead
i doesnt work for me, i dont get even a error message.....
i'Ve enabled intents.guilds = Truemaybe cuz the library (discord.py) is now dead
hmmmm me is work how you not work?
Yes, possible. Try the new library "Py-Cord" and go through their docs, it's pretty similar to DPY but Py-Cord is what I recommend to use now, after all, discord.py is discontinued.
@0xicl33n the thing is that, this gist is just super super useful
@0xicl33n the thing is that, this gist is just super super useful
i agree, im using discord.py still and was trying to figure this out exactly lmao, very helpful indeed <3
@0xicl33n Bro you commented though?
Thank you
Yeah this works amazing, but it sends a message to every channel, can I fix this somehow?