Random Greeting with Mention

  • Share this:

Code introduction


This function takes a message object as an argument and returns a random greeting followed by a mention of the message sender.


Technology Stack : Discord.py

Code Type : Discord API Function

Code Difficulty : Intermediate


                
                    
import discord
import random

def create_random_greeting(message):
    greetings = ["Hello", "Hi", "Hey", "Greetings", "Salutations"]
    random_greeting = random.choice(greetings)
    return f"{random_greeting}, {message.author.mention}!"                
              
Tags: