-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
85 lines (67 loc) · 2.37 KB
/
Copy pathmain.py
File metadata and controls
85 lines (67 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import discord
from discord.ext import commands
import logging
from dotenv import load_dotenv
import os
load_dotenv()
token = os.getenv('DISCORD_TOKEN')
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix='/', intents=intents)
secret_role = "Gamer"
@bot.event
async def on_ready():
print(f"We are ready to go in, {bot.user.name}")
@bot.event
async def on_member_join(member):
await member.send(f"Welcome to the server {member.name}")
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if "shit" in message.content.lower():
await message.delete()
await message.channel.send(f"{message.author.mention} - dont use that word!")
await bot.process_commands(message)
@bot.command()
async def hello(ctx):
await ctx.send(f"Hello {ctx.author.mention}!")
@bot.command()
async def assign(ctx):
role = discord.utils.get(ctx.guild.roles, name=secret_role)
if role:
await ctx.author.add_roles(role)
await ctx.send(f"{ctx.author.mention} is now assigned to {secret_role}")
else:
await ctx.send("Role doesn't exist")
@bot.command()
async def remove(ctx):
role = discord.utils.get(ctx.guild.roles, name=secret_role)
if role:
await ctx.author.remove_roles(role)
await ctx.send(f"{ctx.author.mention} has had the {secret_role} removed")
else:
await ctx.send("Role doesn't exist")
@bot.command()
async def dm(ctx, *, msg):
await ctx.author.send(f"You said {msg}")
@bot.command()
async def reply(ctx):
await ctx.reply("This is a reply to your message!")
@bot.command()
async def poll(ctx, *, question):
embed = discord.Embed(title="New Poll", description=question)
poll_message = await ctx.send(embed=embed)
await poll_message.add_reaction("👍")
await poll_message.add_reaction("👎")
@bot.command()
@commands.has_role(secret_role)
async def secret(ctx):
await ctx.send("Welcome to the club!")
@secret.error
async def secret_error(ctx, error):
if isinstance(error, commands.MissingRole):
await ctx.send("You do not have permission to do that!")
bot.run(token, log_handler=handler, log_level=logging.DEBUG)