Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SocketTextChannel channel = message.Channel as SocketTextChannel;
- ulong serverId = channel.Guild.Id;
- if (parameterMessage.Content.Equals(".prefix"))
- {
- SQLiteConnection conn = new SQLiteConnection(Strings.PREFIXES_CONNECTIONSTRING);
- conn.Open();
- string sql = "SELECT * FROM prefixes WHERE serverid='{0}'";
- string sqlFormatted = string.Format(sql, serverId);
- SQLiteCommand command = new SQLiteCommand(sqlFormatted, conn);
- SQLiteDataReader rdr = command.ExecuteReader();
- while (rdr.Read())
- {
- await channel.SendMessageAsync("The prefix for this server is " + rdr["prefix"]);
- }
- conn.Close();
- return;
- }
- // Lookup the prefix for the server
- SQLiteConnection connection = new SQLiteConnection(Strings.PREFIXES_CONNECTIONSTRING);
- connection.Open();
- SQLiteDataReader reader = null;
- string prefix = null;
- try {
- string query = "SELECT * FROM prefixes WHERE serverid='{0}'";
- string queryFormatted = string.Format(query, serverId);
- SQLiteCommand command = new SQLiteCommand(queryFormatted, connection);
- reader = command.ExecuteReader();
- } catch (Exception e)
- {
- Console.WriteLine(e.Message);
- }
- while (reader.Read())
- {
- prefix = reader["prefix"].ToString();
- }
- if (prefix == null)
- {
- prefix = ".";
- }
- connection.Close();
- if (!message.HasStringPrefix(prefix, ref argPos)) return;
- // Create a Command Context
- var context = new CommandContext(client, message);
- // Execute the Command, store the result
- var result = await commands.ExecuteAsync(context, argPos, map);
- StatsService.CommandsRan++;
- // If the command failed, notify the user
- if (!result.IsSuccess)
- {
- EmbedBuilder builder = new EmbedBuilder();
- builder.Color = Colours.ERROR;
- builder.Title = "Error";
- builder.Description = result.ErrorReason;
- await message.Channel.SendMessageAsync("", false, builder);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement