Files
discord_bot/test2.py
2022-06-26 08:10:49 +03:00

33 lines
1.0 KiB
Python

import discord
import dislash
from discord.ext import commands
from dislash.slash_commands import check
bot = commands.Bot(command_prefix="!")
inter_client = dislash.InteractionClient(bot)
class Greetings(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._last_member = None
@commands.Cog.listener()
async def on_member_join(self, member):
channel = member.guild.system_channel
if channel is not None:
await channel.send('Welcome {0.mention}.'.format(member))
@commands.command()
async def hello(self, ctx, *, member: discord.Member = None):
"""Says hello"""
member = member or ctx.author
if self._last_member is None or self._last_member.id != member.id:
await ctx.send('Hello {0.name}~'.format(member))
else:
await ctx.send('Hello {0.name}... This feels familiar.'.format(member))
self._last_member = member
bot.add_cog(Greetings(bot))
bot.run("OTQ3OTUzOTAxNzgzNjIxNjYy.GTXbMv.KrztaTO7-ivsPEAVjsyikSQ-GP-ANwULmDraig")