Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with prefixes and config sql tables #336

Open
wants to merge 2 commits into
base: new-core
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions meowth/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,12 @@ def platform(self):

# events
async def on_guild_join(self, guild):
table = self.dbi.table('guild_settings')
table = self.dbi.table('guild_config')
insert = table.insert
d = {
'guild_id': guild.id,
'version': self.version
'version': self.version,
'config_name': 'bot_version'
}
insert.row(**d)
await insert.commit(do_update=True)
Expand Down
2 changes: 1 addition & 1 deletion meowth/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ async def tz(self):
async def version(self):
if not self.guild:
return None
table = self.bot.dbi.table('guild_settings')
table = self.bot.dbi.table('guild_config')
query = table.query('version')
try:
query.where(guild_id=self.guild.id)
Expand Down
7 changes: 4 additions & 3 deletions meowth/core/data_manager/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ def core_table_sqls():
'guild_config' : ("CREATE TABLE guild_config ("
"guild_id bigint NOT NULL, "
"config_name text NOT NULL, "
"config_value text NOT NULL, "
"CONSTRAINT guild_config_pk "
"config_value text, "
"version text NOT NULL, "
"CONSTRAINT guild_config_pkey "
"PRIMARY KEY (guild_id, config_name));"),

'restart_savedata' : ("CREATE TABLE restart_savedata ("
Expand All @@ -19,7 +20,7 @@ def core_table_sqls():
"CONSTRAINT restart_savedata_pk "
"PRIMARY KEY (restart_snowflake));"),

'prefixes' : ("CREATE TABLE prefix ("
'prefixes' : ("CREATE TABLE prefixes ("
"guild_id bigint NOT NULL, "
"prefix text NOT NULL, "
"CONSTRAINT prefixes_pkey "
Expand Down
8 changes: 4 additions & 4 deletions meowth/exts/admin/admin_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ async def enable(self, ctx, *features):
before enabling these.
"""
guild_id = ctx.guild.id
settings = ctx.bot.dbi.table('guild_settings')
settings = ctx.bot.dbi.table('guild_config')
insert = settings.insert
insert.row(guild_id=guild_id, version=ctx.bot.version)
insert.row(guild_id=guild_id, version=ctx.bot.version, config_name='enabled_raids')
await insert.commit(do_update=True)
try:
await ctx.guild.me.edit(nick='Meowth 3.0')
Expand Down Expand Up @@ -668,7 +668,7 @@ async def importconfig(self, ctx):

Usable only by server admins."""
guild_id = ctx.guild.id
settings = ctx.bot.dbi.table('guild_settings')
settings = ctx.bot.dbi.table('guild_config')
insert = settings.insert
insert.row(guild_id=guild_id, version=ctx.bot.version)
await insert.commit(do_update=True)
Expand Down Expand Up @@ -939,7 +939,7 @@ async def cleanroles(self, ctx):
async def configure(self, ctx):
"""Gives information about how to configure Meowth 3.0."""
guild_id = ctx.guild.id
settings = ctx.bot.dbi.table('guild_settings')
settings = ctx.bot.dbi.table('guild_config')
insert = settings.insert
insert.row(guild_id=guild_id, version=ctx.bot.version)
await insert.commit(do_update=True)
Expand Down