-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Starboard - Added Regen Gmail Token feature - Added on_member_join feature - Fixed rolecolors feature. - Fixed email_verification features.
- Loading branch information
Showing
7 changed files
with
215 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import pickle | ||
from google.auth.transport.requests import Request | ||
from google_auth_oauthlib.flow import InstalledAppFlow | ||
from googleapiclient.discovery import build | ||
|
||
# If modifying these SCOPES, delete the file token.pickle. | ||
SCOPES = ['https://www.googleapis.com/auth/gmail.send'] | ||
|
||
def get_gmail_service(): | ||
creds = None | ||
if os.path.exists('token.pickle'): | ||
with open('token.pickle', 'rb') as token: | ||
creds = pickle.load(token) | ||
# If there are no (valid) credentials available, let the user log in. | ||
if not creds or not creds.valid: # Still gotta fix the not creds.valid check. | ||
if creds and creds.expired and creds.refresh_token: | ||
creds.refresh(Request()) | ||
else: | ||
flow = InstalledAppFlow.from_client_secrets_file( | ||
'credentials.json', SCOPES) | ||
creds = flow.run_local_server(port=0) | ||
|
||
with open('token.pickle', 'wb') as token: | ||
pickle.dump(creds, token) | ||
service = build('gmail', 'v1', credentials=creds) | ||
return service | ||
|
||
if __name__ == '__main__': | ||
service = get_gmail_service() | ||
print("Token.pickle file generated successfully.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import discord | ||
from discord.ext import commands | ||
from core.database import StarboardMessage | ||
|
||
class Starboard(commands.Cog): | ||
def __init__(self, bot): | ||
self.bot = bot | ||
self.starboard_channel_id = 123456789012345678 # Default starboard channel ID | ||
self.star_threshold = 5 # Default number of stars required to post to starboard | ||
|
||
@commands.Cog.listener() | ||
async def on_raw_reaction_add(self, payload): | ||
if payload.emoji.name == '⭐': # Check if the reaction is a star | ||
await self.handle_star_reaction(payload) | ||
|
||
@commands.Cog.listener() | ||
async def on_raw_reaction_remove(self, payload): | ||
if payload.emoji.name == '⭐': # Check if the reaction is a star | ||
await self.handle_star_reaction(payload) | ||
|
||
async def handle_star_reaction(self, payload): | ||
channel = self.bot.get_channel(payload.channel_id) | ||
message = await channel.fetch_message(payload.message_id) | ||
star_count = sum(1 for reaction in message.reactions if reaction.emoji == '⭐') | ||
|
||
starboard_channel = self.bot.get_channel(self.starboard_channel_id) | ||
starboard_message = StarboardMessage.get_or_none(StarboardMessage.original_message_id == message.id) | ||
|
||
if star_count >= self.star_threshold: | ||
embed = discord.Embed( | ||
description=message.content, | ||
color=discord.Color.gold() | ||
) | ||
embed.set_author(name=message.author.display_name, icon_url=message.author.avatar.url) | ||
embed.add_field(name="Jump to message", value=f"[Click Here]({message.jump_url})") | ||
embed.set_footer(text=f"⭐ {star_count} | {message.channel.name}") | ||
|
||
if starboard_message: | ||
starboard_msg = await starboard_channel.fetch_message(starboard_message.starboard_message_id) | ||
await starboard_msg.edit(embed=embed) | ||
starboard_message.star_count = star_count | ||
starboard_message.save() | ||
else: | ||
starboard_msg = await starboard_channel.send(embed=embed) | ||
StarboardMessage.create( | ||
original_message_id=message.id, | ||
starboard_message_id=starboard_msg.id, | ||
star_count=star_count | ||
) | ||
elif starboard_message: | ||
starboard_msg = await starboard_channel.fetch_message(starboard_message.starboard_message_id) | ||
await starboard_msg.delete_instance() | ||
|
||
@commands.group(name="starboard", invoke_without_command=True) | ||
async def starboard(self, ctx): | ||
await ctx.send("Available subcommands: setchannel, setthreshold") | ||
|
||
@starboard.command(name="setchannel") | ||
@commands.has_permissions(administrator=True) | ||
async def set_channel(self, ctx, channel: discord.TextChannel): | ||
"""Set the starboard channel.""" | ||
self.starboard_channel_id = channel.id | ||
await ctx.send(f"Starboard channel set to {channel.mention}") | ||
|
||
@starboard.command(name="setthreshold") | ||
@commands.has_permissions(administrator=True) | ||
async def set_threshold(self, ctx, threshold: int): | ||
"""Set the star count threshold.""" | ||
self.star_threshold = threshold | ||
await ctx.send(f"Star count threshold set to {threshold}") | ||
|
||
async def setup(bot): | ||
await bot.add_cog(Starboard(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.