You can download this code by clicking the button below.
This code is now available for download.
This code defines a simple Discord.py function that sends a random greeting message to a Discord member.
Technology Stack : Discord.py, discord, random
Code Type : The type of code
Code Difficulty : Intermediate
import discord
from discord.ext import commands
import random
def create_random_greeting_message():
greetings = ["Hello!", "Hi there!", "Hey!", "What's up?", "Greetings!"]
return random.choice(greetings)
def greet_member(ctx, member):
message = create_random_greeting_message()
await ctx.send(f"{message}, {member.mention}!")