I am trying to create a bot to run through my personal discord account, and direct message people when they join a specific discord server I am in. However, my on_member_join(member) method is not running when a member joins a server (not printing "registered" in terminal). I am curious how to make the bot listen for a specific server or just register this event in general. Note on_connect() and spam() both function properly.
import discord
import asyncio
import requests
from discord.ext import commands
yer=commands.Bot(command_prefix="!",help_command=None,self_bot=True)
token="TOKEN"
class SelfBot(commands.Cog):
def __init__(self,yer):
self.yer=yer
@yer.command()
async def spam(ctx):
for i in range(50):
await ctx.send("Hello!")
await asyncio.sleep(0.7)
@yer.event
async def on_connect():
await yer.change_presence(status=discord.Status.idle,activity=discord.Game("Game"))
@yer.event
async def on_member_join(member):
print("registered")
yer.run(token,bot=False)