Advertisement
Guest User

main.py

a guest
Nov 19th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. from discord import app_commands
  4. import os
  5. import asyncio
  6.  
  7. intents = discord.Intents.all()
  8. intents.members = True
  9. bot = commands.Bot(command_prefix=">",intents=intents)
  10. #tree = app_commands.CommandTree(client)
  11.  
  12. asta_guild_id = 1030203387423236136
  13.  
  14. # Cogs Setup
  15. async def load():
  16. for filename in os.listdir("./Cogs"):
  17. if filename.endswith(".py"):
  18. await bot.load_extension(f"Cogs.{filename[:-3]}")
  19.  
  20.  
  21. @bot.event
  22. async def on_connect():
  23. print("Bot has connected!")
  24.  
  25. @bot.event
  26. async def on_ready():
  27. print("Bot is Ready!")
  28.  
  29.  
  30.  
  31.  
  32. #Welcome Message
  33. @bot.event
  34. async def on_member_join(member):
  35. avatar = member.avatar
  36. welc_channel = bot.get_channel(1030244468600885388)
  37. guild = bot.get_guild(asta_guild_id)
  38. embed=discord.Embed(title="",description=f"Hi {member.mention} and welcome to The Cat House. You are our {guild.member_count} member!\n\n Get yourself comfy and enjoy! :D",)
  39. embed.set_footer(text="Astartic's House", icon_url=guild.icon)
  40. embed.set_thumbnail(url=member.avatar)
  41. print(avatar)
  42. # embed.add_field(name=" ", value=f"Hi {member.mention} and welcome to The Cat House. You are our 35th member! Get yourself comfy and enjoy! :D", inline=False)
  43. await welc_channel.send(embed=embed)
  44.  
  45. #Goodbye Message
  46. @bot.event
  47. async def on_member_remove(member):
  48. avatar = member.avatar
  49. welc_channel = bot.get_channel(1030244468600885388)
  50. guild = bot.get_guild(asta_guild_id)
  51. embed=discord.Embed(title="",description=f"It seems {member.name} has left us...\n\nWe now have {guild.member_count} members. :(")
  52. embed.set_footer(text="Astartic's House", icon_url=guild.icon)
  53. embed.set_thumbnail(url=member.avatar)
  54. print(avatar)
  55. # embed.add_field(name=" ", value=f"Hi {member.mention} and welcome to The Cat House. You are our 35th member! Get yourself comfy and enjoy! :D", inline=False)
  56. await welc_channel.send(embed=embed)
  57.  
  58. async def main():
  59. await load()
  60. await bot.start("MY_TOKEN", reconnect=True)
  61.  
  62. asyncio.run(main())
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement