So I am currently trying to create a Discord bot that creates a custom welcome image when someone joins the server. However, there is no output on the image selected and there are no error outputs whenever I run the bot. I assumed I did not enable Privileged Intents but I have so I am stuck as to why it is not outputting anything when I log into my test server using my test account! You can find my code below :
#importing dependencies
import numpy as np
import logging
import discord
import PIL
import asyncio
import os
#importing commands from above dependencies
from discord import client
from discord.ext import commands
from PIL import Image, ImageFont, ImageDraw
from discord.member import Member
#enabling privileged intents
intents = discord.Intents.default()
intents.members = True
intents.presences = True
client = discord.Client(intents=intents)
#for custom image welcome message
@client.event
async def on_member_join(ctx, member: discord.Member = None):
if member == None:
member = ctx.author
channel = client.get_channel("TOKEN")
#-----------------------------------------------------------------------------#
#transforming user's avatar into a circle
# Open the input image as numpy array, convert to RGB
img=Image.open(member.avatar_url).convert("RGB")
npImage=np.array(img)
h,w=img.size
# Create same size alpha layer with circle
alpha = Image.new('L', img.size,0)
draw = ImageDraw.Draw(alpha)
draw.pieslice([0,0,h,w],0,360,fill=255)
# Convert alpha Image to numpy array
npAlpha=np.array(alpha)
# Add alpha layer to RGB
npImage=np.dstack((npImage,npAlpha))
# Save with alpha
Image.fromarray(npImage).save("D:\Coding\Python\Projects\discord_moderation_bot\imgs\result.png")
#-----------------------------------------------------------------------------#
#pasting user avatar into welcome banner
img = Image.open("D:\Coding\Python\Projects\discord_moderation_bot\imgs\welcome_banner.png")
pfp = Image.open("D:\Coding\Python\Projects\discord_moderation_bot\imgs\result.png")
pfp = pfp.resize ((167, 167))
img.paste(pfp, (120, 104))
img.save("D:\Coding\Python\Projects\discord_moderation_bot\imgs\welcome.jpg")
await ctx.send(file = discord.File("welcome.jpg"))
client.run("TOKEN")
Thanks in advance!