-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
78 lines (62 loc) · 2.69 KB
/
bot.py
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
import discord
from discord import app_commands
from discord.ext import commands
bot = commands.Bot(command_prefix="!", intents = discord.Intents.all())
@bot.event
async def on_ready():
print("Bot is up and ready!")
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} command(s)")
except Exception as e:
print (e)
### This section looks for the amount of servers the
### bot is in and displays it as a status message
servers = len(bot.guilds)
members = 0
for guild in bot.guilds:
members += guild.member_count - 1
await bot.change_presence(activity = discord.Activity(
type = discord.ActivityType.watching,
name = f'{servers} servers and {members} members'
))
@bot.command()
async def server_info(ctx):
for guild in client.guilds:
print(guild.name) # prints all server's names
@bot.tree.command(name="hello")
async def hello(interaction: discord.Interaction):
await interaction.response.send_message(f"Hello {interaction.user.mention}! This is a slash command!", ephemeral=False)
@bot.tree.command(name="say")
@app_commands.describe(thing_to_say = "What should I say?")
async def say(interaction: discord.Interaction, thing_to_say: str):
await interaction.response.send_message(f"{interaction.user.name} said: `{thing_to_say}`")
@bot.tree.command(name="isputindead")
async def hello(interaction: discord.Interaction):
await interaction.response.send_message(f"Hello {interaction.user.mention}! Putin is not dead sadly.", ephemeral=False)
@bot.command()
async def info(ctx):
await ctx.send(ctx.guild)
@bot.command() ## This is a poll function. To use it do !poll INSERT-TEXT yes no
async def poll(ctx, question, option1=None, option2=None):
if option1==None and option2==None:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**✅ = Yes**\n**❎ = No**")
await message.add_reaction('❎')
await message.add_reaction('✅')
elif option1==None:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**✅ = {option1}**\n**❎ = No**")
await message.add_reaction('❎')
await message.add_reaction('✅')
elif option2==None:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**✅ = Yes**\n**❎ = {option2}**")
await message.add_reaction('❎')
await message.add_reaction('✅')
else:
await ctx.channel.purge(limit=1)
message = await ctx.send(f"```New poll: \n{question}```\n**✅ = {option1}**\n**❎ = {option2}**")
await message.add_reaction('❎')
await message.add_reaction('✅')
bot.run('INSERT_BOT_TOKEN_HERE')